summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJohnny Richard <johnny@johnnyrichard.com>2023-04-14 20:55:38 +0200
committerJohnny Richard <johnny@johnnyrichard.com>2023-04-14 20:55:38 +0200
commite0f96e02d6277f92b24ea3afaa49d6c0a7a6731c (patch)
tree0399b18a0fd6f32267fc8570e20075c9a3e3d7cd /Makefile
parentbe27abdc5d7895d612237803277766621601662a (diff)
build: Move *.c to src folder
We want to have different folders for src and objs files. Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 17 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 280c0e0..9c840cd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,18 @@
-all: pipac
+TARGET := pipac
+SRC_DIR := src
+BUILD_DIR := build
-pipac: pipac.c
- $(CC) pipac.c -o pipac
+SRCS := $(wildcard $(SRC_DIR)/*.c)
+OBJS := $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRCS))
+
+.PHONY: all
+all: $(TARGET)
+
+$(TARGET): $(BUILD_DIR) $(OBJS)
+ $(CC) $(OBJS) -o $(TARGET) $(CFLAGS)
+
+$(BUILD_DIR):
+ @mkdir -p $@
+
+$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
+ $(CC) $(CFLAGS) -c $< -o $@