summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile20
-rw-r--r--src/pipac.c (renamed from pipac.c)0
3 files changed, 18 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index c605a4f..7ec8def 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
pipac
+build
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 $@
diff --git a/pipac.c b/src/pipac.c
index dba6109..dba6109 100644
--- a/pipac.c
+++ b/src/pipac.c