From 3086e1aca0fa5015d230cb41c1bed6eff8a2f35a Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Fri, 20 May 2022 19:06:26 +0200 Subject: [PATCH] remade build.sh as makefile This is first version, I don't know if it will be used as main compilation way... so yeah --- Makefile | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..15e1170 --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +# Compiler Settings +CC=cc +CFLAGS=-Wall + +# Source Code +SRC=src/lib/*.c +SRC_APP=src/app/*.c +INCLUDE_DIR="include" +INCLUDE=$(INCLUDE_DIR)/*.h +TEST=src/lib/test/main.c +LIBS=-ljson-c -lcurl + +# Output Files +PROJECT_NAME=why2 +OUTPUT=out +OUTPUT_TEST=$(OUTPUT)/$(PROJECT_NAME)-test +OUTPUT_APP=$(OUTPUT)/$(PROJECT_NAME)-app + +# Install Files +INSTALL_INCLUDE=/usr/include +INSTALL_LIBRARY=/usr/lib +INSTALL_BIN=/usr/bin + +# Misc +DOLLAR=$ + +########## + +all: install + +install: +# Install WHY2-Lib + for file in $(INCLUDE); do install -m 755 -D $(DOLLAR)file -t $(INSTALL_INCLUDE)/$(PROJECT_NAME); done + install -m 755 $(INCLUDE_DIR)/$(PROJECT_NAME).h $(INSTALL_INCLUDE)/$(PROJECT_NAME).h + $(CC) $(CFLAGS) -fPIC -c $(SRC) + $(CC) $(CFLAGS) -shared -o lib$(PROJECT_NAME).so *.o $(LIBS) + install -m 755 lib$(PROJECT_NAME).so $(INSTALL_LIBRARY)/lib$(PROJECT_NAME).so +# Install WHY2-App + make app + install -m 755 $(OUTPUT_APP) $(INSTALL_BIN)/$(PROJECT_NAME) + make clean + +test: + $(CC) $(CFLAGS) $(TEST) -o $(OUTPUT_TEST) -l$(PROJECT_NAME) + +app: + $(CC) $(CFLAGS) $(SRC_APP) -o $(OUTPUT_APP) -l$(PROJECT_NAME) + +installTest: + make install + make test + +clean: + rm -rf $(OUTPUT)/* *.o *.so \ No newline at end of file