diff --git a/Makefile b/Makefile index 79a3af5..e60b2e5 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ ## Compile client & server CC=gcc -PROGRAMS=bin/server bin/client +PROGRAMS=$(SERVER_BINARY) $(CLIENT_BINARY) # Uncomment this line in case of linker error while building # CFLAGS=-fno-use-linker-plugin @@ -11,25 +11,22 @@ ifeq ($(OS),Windows_NT) endif ## SERVER -BINARY=bin/server -CFILES=server/main.c server/socket/socket.c server/handler/handler.c -OBJECTS=server/main.o server/socket/socket.o server/handler/handler.o +SERVER_BINARY=bin/server +SERVER_CFILES=server/main.c server/socket/socket.c server/handler/handler.c +SERVER_OBJECTS=server/main.o server/socket/socket.o server/handler/handler.o + +## CLIENT +CLIENT_BINARY=bin/client +CLIENT_CFILES=client/main.c client/socket/socket.c client/handler/handler.c +CLIENT_OBJECTS=client/main.o client/socket/socket.o client/handler/handler.o all: $(PROGRAMS) -$(BINARY): $(OBJECTS) +$(SERVER_BINARY): $(SERVER_OBJECTS) mkdir -p bin/ $(CC) $^ -o $@ -%.o:%.c - $(CC) -c $^ -o $@ $(CFLAGS) - -## CLIENT -BINARY=bin/client -CFILES=client/main.c client/socket/socket.c client/handler/handler.c -OBJECTS=client/main.o client/socket/socket.o client/handler/handler.o - -$(BINARY): $(OBJECTS) +$(CLIENT_BINARY): $(CLIENT_OBJECTS) mkdir -p bin/ $(CC) $^ -o $@ @@ -39,5 +36,5 @@ $(BINARY): $(OBJECTS) ## Global clean: rm -rf bin/ - rm server/*.o server/handler/*.o server/socket/*.o - rm client/*.o client/handler/*.o client/socket/*.o + rm $(SERVER_OBJECTS) + rm $(CLIENT_OBJECTS)