summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2015-06-18 23:58:14 -0400
committerTavian Barnes <tavianator@tavianator.com>2015-06-18 23:58:14 -0400
commit3748fa7d7a977f4e31c52ec8b4e66aa9e736342b (patch)
tree161563b4210df2c7070b14eff3198df5c6b319fb /Makefile
parentac11476e20136976bf689acf847fdcea4e05e37a (diff)
downloadbfs-3748fa7d7a977f4e31c52ec8b4e66aa9e736342b.tar.xz
Makefile: Auto-generate dependencies.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile20
1 files changed, 14 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 2a115a4..77da3e5 100644
--- a/Makefile
+++ b/Makefile
@@ -10,19 +10,27 @@
#####################################################################
CC ?= gcc
-CFLAGS ?= -std=c99 -g -Og -Wall -D_DEFAULT_SOURCE
+CFLAGS ?= -g -Og -Wall
LDFLAGS ?=
+DEPFLAGS ?= -MD -MP -MF $(@:.o=.d)
RM ?= rm -f
-DEPS := bftw.h
+LOCAL_CPPFLAGS := -D_DEFAULT_SOURCE
+LOCAL_CFLAGS := -std=c99
+
+ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
+ALL_CFLAGS = $(ALL_CPPFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) $(DEPFLAGS)
+ALL_LDFLAGS = $(LDFLAGS)
bfs: bfs.o bftw.o
- $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
+ $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $^ -o $@
-%.o: %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+%.o: %.c
+ $(CC) $(ALL_CFLAGS) -c $< -o $@
clean:
- $(RM) bfs *.o
+ $(RM) bfs *.o *.d
.PHONY: clean
+
+-include $(wildcard *.d)