From 2d526a14383939180456f64c0de7c985b2332ff4 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 13 Apr 2014 21:23:42 -0400 Subject: have the makefile generate dependencies --- .gitignore | 1 + Makefile | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 97d3851..c7267e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o +.*.d runes diff --git a/Makefile b/Makefile index 0be5373..8c5df71 100644 --- a/Makefile +++ b/Makefile @@ -4,18 +4,26 @@ LIBS = cairo cairo-xlib libuv CFLAGS ?= -g -Wall -Wextra -Werror LDFLAGS ?= -g -Wall -Wextra -Werror +ALLCFLAGS = $(shell pkg-config --cflags $(LIBS)) $(CFLAGS) +ALLLDFLAGS = $(shell pkg-config --libs $(LIBS)) $(LDFLAGS) + +MAKEDEPEND = $(CC) $(ALLCFLAGS) -M -MP -MT '$@ $(@:%.o=.%.d)' + build: $(OUT) $(OUT): $(OBJ) - $(CC) $(shell pkg-config --libs $(LIBS)) $(LDFLAGS) -o $@ $^ + $(CC) $(ALLLDFLAGS) -o $@ $^ %.o: %.c - $(CC) $(shell pkg-config --cflags $(LIBS)) $(CFLAGS) -c -o $@ $^ + @$(MAKEDEPEND) -o $(<:%.c=.%.d) $< + $(CC) $(ALLCFLAGS) -c -o $@ $< %.c: %.l - $(LEX) -o $@ $^ + $(LEX) -o $@ $< clean: - rm -f $(OUT) $(OBJ) + rm -f $(OUT) $(OBJ) $(OBJ:%.o=.%.d) + +-include $(OBJ:%.o=.%.d) .PHONY: build clean -- cgit v1.2.3-54-g00ecf