comparison Makefile @ 181:5350ce9f446f

Arranged for dependencies to be generated when building object files; no more extraneous dependency rebuilds
author lost@l-w.ca
date Sat, 17 Sep 2011 11:45:13 -0600
parents 3413a88f4d09
children b6685a7ec2bd
comparison
equal deleted inserted replaced
180:11b710d231bd 181:5350ce9f446f
77 lwlib/liblw.a: $(lwlib_objs) lwlib/rules.make 77 lwlib/liblw.a: $(lwlib_objs) lwlib/rules.make
78 @echo Linking $@ 78 @echo Linking $@
79 @$(AR) rc $@ $(lwlib_objs) 79 @$(AR) rc $@ $(lwlib_objs)
80 @$(RANLIB) $@ 80 @$(RANLIB) $@
81 81
82 %.d: %.c
83 @echo "Building dependencies for $@"
84 @$(CC) -MM $(CPPFLAGS) -o $*.d $<
85 @mv -f $*.d $*.d.tmp
86 @sed -e 's|.*:|$*.o $*.d:|' < $*.d.tmp > $*.d
87 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
88 @rm -f $*.d.tmp
89
90 alldeps := $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) ($lwobjdump_deps) 82 alldeps := $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) ($lwobjdump_deps)
91 83
92 -include $(alldeps) 84 -include $(alldeps)
93 85
94 extra_clean := $(extra_clean) *~ */*~ 86 extra_clean := $(extra_clean) *~ */*~
95 87
96 %.o: %.c 88 %.o: %.c
89 @echo "Building dependencies for $@"
90 @$(CC) -MM $(CPPFLAGS) -o $*.d $<
91 @mv -f $*.d $*.d.tmp
92 @sed -e 's|.*:|$*.o $*.d:|' < $*.d.tmp > $*.d
93 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
94 @rm -f $*.d.tmp
97 @echo Building $@ 95 @echo Building $@
98 @$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< 96 @$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
99 97
100 98
101 .PHONY: clean 99 .PHONY: clean