PROGRAM = ol CC = clang C_FLAGS = \ -std=c17 \ -Wall \ -Wextra \ -Wpedantic \ -Wconversion \ -Wno-gnu-case-range \ -g LINKER_FLAGS = \ -fsanitize=address,undefined \ -g SOURCE_FOLDER = src BUILD_FOLDER = build C_FILES = $(shell find $(SOURCE_FOLDER) -name "*.c") H_FILES = $(shell find $(SOURCE_FOLDER) -name "*.h") C_FLAGS += -I$(SOURCE_FOLDER) OBJECT_FILES = $(patsubst $(SOURCE_FOLDER)/%.c, $(BUILD_FOLDER)/%.o, $(C_FILES)) all: build_folder $(PROGRAM) compile_flags.txt $(PROGRAM): $(OBJECT_FILES) $(CC) $^ -o $(BUILD_FOLDER)/$@ $(LINKER_FLAGS) $(BUILD_FOLDER)/%.o: $(SOURCE_FOLDER)/%.c $(H_FILES) $(CC) $< -c -o $@ $(C_FLAGS) build_folder: mkdir $(BUILD_FOLDER) -p compile_flags.txt: echo -xc $(C_FLAGS) | sed 's/\s\+/\n/g' > compile_flags.txt clean: rm -rf $(BUILD_FOLDER) compile_flags.txt