# Set the following to '0' to disable log messages:
LOG ?= 1

# Compiler/linker flags
CFLAGS += -Wall -g -pthread -I/usr/include/protobuf-c -DLOGGING_ENABLED=$(LOG)
LDLIBS += -lprotobuf-c -lreadline

src=communication.c messages.pb-c.c
obj=$(src:.c=.o)


all: client server

client: client.c communication.h $(obj)
	$(CC) $(LDLIBS) $(CFLAGS) $(obj) client.c -o client

server: server.c communication.h $(obj)
	$(CC) $(LDLIBS) $(CFLAGS) $(obj) server.c -o server

messages.pb-c.c: messages.proto
	protoc messages.proto --c_out=./

communication.o: communication.c communication.h messages.pb-c.o
messages.pb-c.o: messages.pb-c.c messages.pb-c.h messages.proto

clean:
	rm -rf client server *.o *.gch messages.pb-c.h messages.pb-c.c
