From 40a76e1d4a1f46de064c28e1f32673ecd5e4cb0e Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 17 Apr 2012 17:14:24 -0300 Subject: [PATCH] genex/Makefile: add dependency generation (.d method) Straight from fped/Makefile --- genex/Makefile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/genex/Makefile b/genex/Makefile index 8a183ca..7077e17 100644 --- a/genex/Makefile +++ b/genex/Makefile @@ -9,9 +9,11 @@ # (at your option) any later version. # -CFLAGS = -Wall -g OBJS = genex.o comp.o libs.o pdf.o +SHELL = /bin/bash +CFLAGS = -Wall -g + CC_normal := $(CC) DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG @@ -36,8 +38,18 @@ all: genex genex: $(OBJS) $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDLIBS) +%.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) spotless: clean rm -f genex