From 33fd8b8631bd8d5cd609935a2dd2fbb31688f2c1 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 9 May 2009 18:09:02 +0000 Subject: Modifying Makefile to generate dependencies (and .d files) automatically. Patch from Lars Immisch: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1241007184 --- cores/arduino/Makefile | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'cores/arduino/Makefile') diff --git a/cores/arduino/Makefile b/cores/arduino/Makefile index f01902b..30ea655 100755 --- a/cores/arduino/Makefile +++ b/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 depend applet_files sizebefore sizeafter +.PHONY: all build elf hex eep lss sym program coff extcoff clean applet_files sizebefore sizeafter + +include $(SRC:.c=.d) +include $(CXXSRC:.cpp=.d) -- cgit v1.2.3-18-g5258