summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorTom Smeding <t.j.smeding@uu.nl>2024-07-13 18:15:24 +0200
committerTom Smeding <t.j.smeding@uu.nl>2024-07-13 18:15:24 +0200
commit54b03f5073f6caa07115c764ee5688bb1cd62468 (patch)
tree83c9881b73d2dfcff3a73e764dc5446f6d217aaa /Makefile
parentb9282287aef553003c53ba89c86d6e2822f5bff8 (diff)
Multi-call binary
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile21
1 files changed, 12 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index dfa689e..e760b65 100644
--- a/Makefile
+++ b/Makefile
@@ -2,19 +2,22 @@ CC := gcc
CFLAGS := -Wall -Wextra -std=c11 -O2
LDFLAGS :=
-BINDIR := bin
+OBJDIR := obj
+TARGET := drukkedoos
-SOURCES := $(wildcard src/*.c)
-HEADERS := $(wildcard src/*.h)
-TARGETS := $(patsubst src/%.c,$(BINDIR)/%,$(SOURCES))
+SOURCES := $(shell find src -type f -name '*.c')
+HEADERS := $(shell find src -type f -name '*.h')
+OBJECTS := $(patsubst src/%.c,obj/%.o,$(SOURCES))
.PHONY: all clean
-all: $(TARGETS)
+all: $(TARGET)
clean:
- find $(BINDIR) -maxdepth 1 -type f -delete
+ rm -rf $(OBJDIR) $(TARGET)
-$(TARGETS): bin/%: src/%.c $(HEADERS)
- @mkdir -p $(dir $@)
- $(CC) $(CFLAGS) -o $@ $<
+$(TARGET): main.c $(OBJECTS)
+ $(CC) -o $@ $^ $(LDFLAGS)
+
+$(OBJECTS): obj/%.o: src/%.c $(HEADERS)
+ $(CC) $(CFLAGS) -c -o $@ $<