From b1fd802e89df0f25c19e6cf818feed8239c482a6 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sat, 14 Jan 2023 00:49:42 +0100 Subject: [PATCH] Add a proper makefile which automatically scans for files and only compiles new changes --- .gitignore | 1 + Makefile | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 4dfd57c..374114a 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,4 @@ dkms.conf #Code editor .vscode/* +compile_commands.json diff --git a/Makefile b/Makefile index 61aad68..c6429e5 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,17 @@ -eipaasm: - clang src/* -Wall -Wextra -o eipaasm +CC := clang +CFLAGS := -Wall -Wextra +SRC_DIR := src +BUILD_DIR := build +OBJECT_FILES := $(patsubst %.c, %.o, $(wildcard $(SRC_DIR)/*.c)) +OBJECT_FILES := $(patsubst $(SRC_DIR)/%, $(BUILD_DIR)/%, $(OBJECT_FILES)) +MAIN_EXE_NAME := eipaasm -all: eipaasm +all eipaasm: $(OBJECT_FILES) + $(CC) $(CFLAGS) $^ -o $(BUILD_DIR)/$(MAIN_EXE_NAME) -run: - ./eipaasm +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c + @mkdir -p $(BUILD_DIR) + $(CC) -c $(CFLAGS) $^ -o $@ -buildrun: compile - ./eipaasm -eipaasm_debug: - gcc src/* -g -o eipaasm_debug clean: - rm -f eipaasm eipaasm_debug \ No newline at end of file + rm -r $(BUILD_DIR)