SRC_DIR = code GCCFLAGS = -g -I $(SRC_DIR) -Wall -Wextra -Wno-switch -Wno-implicit-fallthrough -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable -Wno-stringop-overflow -Werror BUILD_DIR = build SOURCES = $(shell find $(SRC_DIR) -name '*.c') TARGETS = $(patsubst %.c, %.o, $(SOURCES)) TARGETS := $(addprefix $(BUILD_DIR)/, $(TARGETS)) APP_NAME = app GREEN = '\033[32;1m' RESET = '\033[0;22m' all: $(APP_NAME) $(APP_NAME): $(TARGETS) @gcc $(GCCFLAGS) -o $(APP_NAME) $(TARGETS) @echo -e $(GREEN)build done.$(RESET) $(TARGETS): $(SOURCES) @mkdir -p $(@D) @gcc $(GCCFLAGS) -c $(patsubst %.o, %.c, $(@:$(BUILD_DIR)/%=%)) -o $@ clean: @rm -r $(BUILD_DIR) $(APP_NAME) @echo -e $(GREEN)clean done.$(RESET)