# provides generic rules for C dependeny generation using # 'makedepend', 'gcc -MM' or similar mechanisms # # requires: # - compilers CC # - INCLUDEDIRS # - OBJS and BIN_OBJS # - TEST_BINS, TEST_BIN_OBJS # # provides: # - included dependency files # # author: Andreas Baumann, abaumann at yahoo dot com ifeq "$(COMPILER)" "gcc" %.d : %.c @echo Generating dependencies for $< @$(CC) -DMAKE_DEPENDENCIES -MM -MT $(@:.d=.o) $(ALL_CFLAGS) $< | \ sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ endif ifeq "$(COMPILER)" "tcc" %.d : %.c @echo Generating dependencies for $< @makedepend -DMAKE_DEPENDENCIES $(PLATFORM_COMPILE_FLAGS) -D__TINYC__ $(INCLUDE_DIRS) -I/usr/lib/tcc/include -f - $< > $@ endif ifeq "$(COMPILER)" "icc" %.d : %.c @echo Generating dependencies for $< @$(CC) -DMAKE_DEPENDENCIES -MM -MT $(@:.d=.o) $(ALL_CFLAGS) $< | \ sed "s,\($*\.o\)[ :]*\(.*\),$@ : $$\(wildcard \2\)\&\&\&\1 : \2,g" | tr -s '&' "\n" > $@ endif ifeq "$(COMPILER)" "spro" %.d : %.c @echo Generating dependencies for $< @$(CC) -DMAKE_DEPENDENCIES -xM1 $(ALL_CFLAGS) $< > $@ endif ifeq "$(COMPILER)" "pcc" # FIXME: platform in path of compiler include files, mmh, how to fix? %.d : %.c @echo Generating dependencies for $< @$(CC) -DMAKE_DEPENDENCIES $(ALL_CFLAGS) -M $< > $@ endif ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),distclean) -include $(OBJS:.o=.d) -include $(BIN_OBJS:.o=.d) -include $(TEST_BIN_OBJS:.o=.d) .PHONY: depend depend: $(OBJS:.o=.d) $(BIN_OBJS:.o=.d) $(TEST_BIN_OBJS:.o=.d) endif endif