diff --git a/.gitignore b/.gitignore index 5778749..0a81271 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,17 @@ .DS_Store .dumbjump +# project specific +build/* +!build/.gitkeep + +logs/* +!logs/.gitkeep + +obj/* +!obj/.gitkeep + + # ---> C # Prerequisites *.d @@ -62,7 +73,6 @@ CMakeCache.txt CMakeFiles CMakeScripts Testing -Makefile cmake_install.cmake install_manifest.txt compile_commands.json diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..73ff9f7 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +CC = gcc +AR = ar +CFLAGS += -std=c99 -Wall -Werror -pedantic -g +ARFLAGS = rvs +INCDIR = ./lib/utils -I ./lib/ini -I ./lib/threadpool -I ./src +INCLUDES = -I . -I $(INCDIR) +LDFLAGS = -L . +OPTFLAGS = #-O3 +LIBS = -lpthread +SOCKET = ./cs_sock + +BUILD_DIR = ./build +SRC_DIR = ./src +OBJ_DIR = ./obj + +OBJ_SERVER = obj/threadpool.o obj/ini.o obj/serverWorker.o obj/server.o + +.DEFAULT_GOAL = server + +# aggiungere qui altri targets +TARGETS = server + +.PHONY: all clean cleanall +.SUFFIXES: .c .h + +obj/threadpool.o: lib/threadpool/threadpool.c + $(CC) $(CFLAGS) $(INCLUDES) -c lib/threadpool/threadpool.c + @mv threadpool.o $(OBJ_DIR)/threadpool.o + +obj/ini.o: lib/ini/ini.c + $(CC) $(CFLAGS) $(INCLUDES) -c lib/ini/ini.c + @mv ini.o $(OBJ_DIR)/ini.o + +obj/serverWorker.o: src/serverWorker.c + $(CC) $(CFLAGS) $(INCLUDES) -c src/serverWorker.c + @mv serverWorker.o $(OBJ_DIR)/serverWorker.o + +obj/server.o: src/server.c + $(CC) $(CFLAGS) $(INCLUDES) -c src/server.c + @mv server.o $(OBJ_DIR)/server.o + +server: $(OBJ_SERVER) + $(CC) $(CFLAGS) $(LIBS) $(OBJ_SERVER) -o $(BUILD_DIR)/server + + + +clean : + @rm -rf $(BUILD_DIR)/* logs/*.log + +cleanall : clean + @rm -rf $(OBJ_DIR)/* + @rm -f $(SOCKET) diff --git a/build/.gitkeep b/build/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/logs/.gitkeep b/logs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/obj/.gitkeep b/obj/.gitkeep new file mode 100644 index 0000000..e69de29