From 9d5c6989e2a406b75eb3a184e068e36ad54c7573 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 19 Apr 2012 20:06:02 -0300 Subject: [PATCH] b2/Makefile: add dependency generation (.d method) --- b2/Makefile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/b2/Makefile b/b2/Makefile index 781f643..078b281 100644 --- a/b2/Makefile +++ b/b2/Makefile @@ -9,6 +9,8 @@ # (at your option) any later version. # +SHELL = /bin/bash + CFLAGS = -Wall $(shell pkg-config --cflags glib-2.0) SLOPPY = -Wno-unused -Wno-implicit-function-declaration OBJS = boom.o chr.o comp.o db.o eval.o param.o util.o lex.yy.o y.tab.o @@ -61,6 +63,16 @@ y.tab.c y.tab.h: lang.y y.tab.o: y.tab.c $(CC) -c $(CFLAGS) $(SLOPPY) y.tab.c +%.o: %.c + $(CC) -c $(CFLAGS) $*.c -o $*.o + $(DEPEND) $*.c | \ + sed -e \ + '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \ + -e '$${g;p;}' -e d >$*.d; \ + [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; } + +-include $(OBJS:.o=.d) + clean: - rm -f $(OBJS) + rm -f $(OBJS) $(OBJS:.o=.d) rm -f lex.yy.c y.tab.c y.tab.h