summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
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 $@