diff --git a/app b/app new file mode 100755 index 0000000..41458ae Binary files /dev/null and b/app differ diff --git a/build.sh b/build.sh index 43d8a2c..5797bd4 100755 --- a/build.sh +++ b/build.sh @@ -2,10 +2,11 @@ SCRIPT_NAME=$(basename "$0") BUILD_DIR="build" -OBJ_DIR="obj" SRC_DIR="src" -APP_NAME="APP" -GCC_OPTIONS="-c -O3" +APP_NAME="app" +GCC_OPTIONS="-Wall -Wextra -I $SRC_DIR -Wno-unused-parameter -Wno-unused-but-set-variable" +GREEN='\033[0;32m' +RESET='\033[0m' # Display functions function show_success { @@ -41,7 +42,7 @@ fi # Clean generated files function clean { - local command="rm -rf $OBJ_DIR $BUILD_DIR" + local command="rm -r $BUILD_DIR $APP_NAME" echo -e "➔ Cleaning..." show_command "$command" make clean > /dev/null || show_error "Error during cleaning." @@ -50,7 +51,7 @@ function clean { # Build function build { - local command="gcc $GCC_OPTIONS -o $OBJ_DIR/main.o $SRC_DIR/main.c" + local command="make" echo -e "➔ Building..." show_command "$command" make > /dev/null || show_error "Error during compilation." @@ -59,7 +60,7 @@ function build { # Execute the executable function execute { - local executable="$BUILD_DIR/$APP_NAME" + local executable="$APP_NAME" local command="./$executable" echo -e "➔ Executing the executable..." show_command "$command" @@ -118,4 +119,4 @@ while [ "$#" -gt 0 ]; do ;; esac shift -done +done \ No newline at end of file diff --git a/makefile b/makefile index 6de9008..67fa35b 100644 --- a/makefile +++ b/makefile @@ -1,43 +1,21 @@ -CC = gcc -SRC_DIR = src -OBJ_DIR = obj -SOURCES = $(wildcard $(SRC_DIR)/*.c) -OBJECTS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SOURCES)) -EXECUTABLE = APP +GCCFLAGS = -Wall -Wextra -I src -Wno-unused-parameter -Wno-unused-but-set-variable BUILD_DIR = build -LDFLAGS = -CFLAGS_RELEASE = -O3 -CFLAGS_DEBUG = -g -O0 +SOURCES = $(shell find src -name '*.c') +TARGETS = $(patsubst %.c, %.o, $(SOURCES)) +TARGETS := $(addprefix $(BUILD_DIR)/, $(TARGETS)) +APP_NAME = app -# Generate dependency files -DEPS = $(OBJECTS:.o=.d) --include $(DEPS) +all: $(APP_NAME) -# Commands -all: build +$(APP_NAME): $(TARGETS) + @gcc $(GCCFLAGS) -o $(APP_NAME) $(TARGETS) + @echo -e $(GREEN)build done.$(RESET) -build: $(BUILD_DIR)/$(EXECUTABLE) +$(TARGETS): $(SOURCES) + @mkdir -p $(@D) + @gcc $(GCCFLAGS) -c $(patsubst %.o, %.c, $(@:$(BUILD_DIR)/%=%)) -o $@ -$(BUILD_DIR)/$(EXECUTABLE): $(OBJECTS) - @mkdir -p $(BUILD_DIR) - $(CC) $(LDFLAGS) -o $@ $^ - -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c - @mkdir -p $(OBJ_DIR) - $(CC) -c $(CFLAGS_RELEASE) -MMD -MP -o $@ $< - -debug: - $(MAKE) CFLAGS_RELEASE="$(CFLAGS_DEBUG)" build clean: - rm -rf $(OBJ_DIR) $(BUILD_DIR) - -run: build - $< - -doc_doxygen: - @echo "Doxygen build started" - @$(MAKE) -C docs - -.PHONY: all build debug clean run doc_doxygen - + @rm -r $(BUILD_DIR) $(APP_NAME) + @echo -e $(GREEN)clean done.$(RESET) \ No newline at end of file diff --git a/src/app/interface/client/interface_client.c b/src/app/interface/client/interface_client.c deleted file mode 100644 index 5398fcf..0000000 --- a/src/app/interface/client/interface_client.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "interface_client.h" - diff --git a/src/app/interface/client/interface_client.h b/src/app/interface/interface_client.c similarity index 74% rename from src/app/interface/client/interface_client.h rename to src/app/interface/interface_client.c index 89a5f92..74fffb7 100644 --- a/src/app/interface/client/interface_client.h +++ b/src/app/interface/interface_client.c @@ -1,7 +1,6 @@ -#include +#include "interface_client.h" -void affiche_client() -{ +void affiche_client(){ printf("\n"); printf("--------------- \n"); printf("|| Bonjour ! ||\n") ; @@ -9,6 +8,6 @@ void affiche_client() printf("\n"); printf("-------------------------------------------------------------------\n"); printf("|| Que voulez-vous faire ? \t \t \t \t \t || \n") ; - printf("||\t1 : Afficher le récapitulatif de votre panier. \t \t \t \t || \n") ; + printf("||\t1 : Afficher le récapitulatif du panier. \t \t || \n") ; printf("-------------------------------------------------------------------\n"); } \ No newline at end of file diff --git a/src/app/interface/interface_client.h b/src/app/interface/interface_client.h new file mode 100644 index 0000000..c7e8589 --- /dev/null +++ b/src/app/interface/interface_client.h @@ -0,0 +1,3 @@ +#include + +void affiche_client(); \ No newline at end of file diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c new file mode 100644 index 0000000..f1afd34 --- /dev/null +++ b/src/app/interface/interface_resp.c @@ -0,0 +1 @@ +#include "interface_resp.h" diff --git a/src/app/interface/resp/interface_resp.h b/src/app/interface/interface_resp.h similarity index 100% rename from src/app/interface/resp/interface_resp.h rename to src/app/interface/interface_resp.h diff --git a/src/app/interface/resp/interface_resp.c b/src/app/interface/resp/interface_resp.c deleted file mode 100644 index b62b362..0000000 --- a/src/app/interface/resp/interface_resp.c +++ /dev/null @@ -1 +0,0 @@ -#include "interface_resp.h" \ No newline at end of file diff --git a/src/main.c b/src/main.c index 78fcf98..5a5f8fd 100644 --- a/src/main.c +++ b/src/main.c @@ -1,8 +1,9 @@ #include #include -#include "app/interface/client/interface_client.h" -#include "app/interface/resp/interface_resp.h" +#include "app/interface/interface_client.h" +#include "app/interface/interface_resp.h" int main(){ - printf("Hello World\n"); + + affiche_client(); }