Makefile: generate .d dep file for init.c
authorJens Axboe <axboe@fb.com>
Thu, 26 Nov 2015 04:24:01 +0000 (21:24 -0700)
committerJens Axboe <axboe@fb.com>
Thu, 26 Nov 2015 04:24:01 +0000 (21:24 -0700)
Could be cleaner, we're duplicating the general .c rule here. But
as a quickie, let's hope it fixes up the rebuild issues when
init.c dependencies have changed.

Signed-off-by: Jens Axboe <axboe@fb.com>
Makefile

index 0b506e8e3981ac0557c2892dd2ea3f23d3c13142..e30273ce86fcd38a371913a48c825ed57c63dd5b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -324,7 +324,14 @@ parse.o: lex.yy.o y.tab.o
 endif
 
 init.o: init.c FIO-VERSION-FILE
 endif
 
 init.o: init.c FIO-VERSION-FILE
+       @mkdir -p $(dir $@)
        $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
        $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
+       @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SRCDIR)/$*.c > $*.d
+       @mv -f $*.d $*.d.tmp
+       @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
+       @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
+               sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
+       @rm -f $*.d.tmp
 
 gcompat.o: gcompat.c gcompat.h
        $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
 
 gcompat.o: gcompat.c gcompat.h
        $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<