2008-12-03 05:40:16 +00:00
|
|
|
# How to build automatic dependencies
|
|
|
|
|
|
|
|
# Don't include dependencies if $(no_deps) is set; the master makefile
|
|
|
|
# does this for clean and other such targets that don't need
|
|
|
|
# dependencies. That then avoids rebuilding dependencies.
|
|
|
|
|
|
|
|
ifneq ($(no_deps),t)
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
ifneq ($(MAKECMDGOALS),mrproper)
|
|
|
|
ifneq ($(MAKECMDGOALS),menuconfig)
|
|
|
|
|
|
|
|
# For each .o file we need a .d file.
|
2008-12-03 06:10:03 +00:00
|
|
|
-include $(subst .o,.d,$(filter %.o,$(OBJECTS)))
|
2008-12-05 14:17:04 +00:00
|
|
|
-include $(subst .o,.d,$(filter %.o,$(OBJECTS_SIM)))
|
2008-12-03 05:40:16 +00:00
|
|
|
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Here is how to build those dependency files
|
|
|
|
|
|
|
|
define make-deps
|
2008-12-03 06:10:03 +00:00
|
|
|
echo "checking dependencies for $<"
|
|
|
|
if [ ! -d obj_avr ]; then mkdir obj_avr ; fi
|
2008-12-03 05:40:16 +00:00
|
|
|
set -e; $(CC) $(CFLAGS) $(CPPFLAGS) -M -MM $< | \
|
2008-12-03 06:10:03 +00:00
|
|
|
sed > $@.new -e 's;$(*F)\.o:;$@ obj_avr/$*.o obj_avr/$*.E $*.s:;' \
|
2008-12-03 05:40:16 +00:00
|
|
|
-e 's% [^ ]*/gcc-lib/[^ ]*\.h%%g'
|
|
|
|
if test -s $@.new; then mv -f $@.new $@; else rm -f $@.new; fi
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Here is how to make .d files from .c files
|
2008-12-03 06:10:03 +00:00
|
|
|
obj_avr/%.d: %.c ; @ $(make-deps)
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2008-12-03 06:10:03 +00:00
|
|
|
obj_avr/%.d: %.S ; @ $(make-deps)
|
2008-12-05 14:17:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
define make-deps-sim
|
|
|
|
echo "checking dependencies for $<"
|
|
|
|
if [ ! -d obj_sim ]; then mkdir obj_sim ; fi
|
|
|
|
set -e; $(HOSTCC) $(SIM_CFLAGS) -M -MM $< | \
|
|
|
|
sed > $@.new -e 's;$(*F)\.o:;$@ obj_sim/$*.o obj_sim/$*.E $*.s:;' \
|
|
|
|
-e 's% [^ ]*/gcc-lib/[^ ]*\.h%%g'
|
|
|
|
if test -s $@.new; then mv -f $@.new $@; else rm -f $@.new; fi
|
|
|
|
endef
|
|
|
|
|
|
|
|
|
|
|
|
obj_sim/%.d: %.c ; $(make-deps-sim)
|