From 60ad594d7b053c7a7c84e842fbaec3a255cbbe01 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 9 May 2009 18:09:02 +0000 Subject: [PATCH] Modifying Makefile to generate dependencies (and .d files) automatically. Patch from Lars Immisch: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1241007184 --- hardware/cores/arduino/Makefile | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/hardware/cores/arduino/Makefile b/hardware/cores/arduino/Makefile index f01902b20..30ea655fa 100755 --- a/hardware/cores/arduino/Makefile +++ b/hardware/cores/arduino/Makefile @@ -1,4 +1,4 @@ -# Arduino 0011 Makefile +# Arduino 0015 Makefile # Arduino adaptation by mellis, eighthave, oli.keller # # This makefile allows you to build sketches from the command line @@ -35,7 +35,7 @@ # $Id$ TARGET = $(notdir $(CURDIR)) -INSTALL_DIR = /Users/dmellis/Source/arduino/trunk/build/macosx/build/work +INSTALL_DIR = ../../.. PORT = /dev/tty.usb* UPLOAD_RATE = 19200 AVRDUDE_PROGRAMMER = stk500v1 @@ -223,6 +223,13 @@ applet/core.a: $(OBJ) $(CC) -c $(ALL_ASFLAGS) $< -o $@ +# Automatic dependencies +%.d: %.c + $(CC) -M $(ALL_CFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@ + +%.d: %.cpp + $(CXX) -M $(ALL_CXXFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@ + # Target: clean project. clean: @@ -230,15 +237,7 @@ clean: applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \ $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) -depend: - if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ - then \ - sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ - $(MAKEFILE).$$$$ && \ - $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ - fi - echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ - >> $(MAKEFILE); \ - $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE) +.PHONY: all build elf hex eep lss sym program coff extcoff clean applet_files sizebefore sizeafter -.PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter +include $(SRC:.c=.d) +include $(CXXSRC:.cpp=.d)