From: Asbjørn Sloth Tønnesen Date: Fri, 14 Jan 2011 21:22:24 +0000 (+0000) Subject: Automatically calculate make dependencies X-Git-Url: http://git.asbjorn.biz/?p=rapper.git;a=commitdiff_plain;h=4d6050e4ef39a538c9272b12436ca1e619f058a1 Automatically calculate make dependencies Make make use the automatically generated dependency files. Signed-off-by: Asbjørn Sloth Tønnesen --- diff --git a/src/Makefile b/src/Makefile index bf7dcc7..fbc9ad9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,6 +11,9 @@ USB_OBJS=usb/serial.o usb/core.o usb/desc.o usb/hw.o usb/user.o usb/vcom.o usb/c BOARD_OBJS=$(BPATH)/startup.o $(BPATH)/system.o boards/cortex_m3/core_cm3.o OBJECTS=main.o $(BOARD_OBJS) $(USB_OBJS) +depend=$(shell sh -c 'b=$$(echo $1|sed -e"s/\\.o$$//g");([ -f $$b.d ] \ + && sed -e":a;N;$$!ba;s/\\\\\\n//g" $$b.d|grep "^$$(basename $1):"\ + | cut -d: -f2)||echo $$b.c') all: crc @@ -20,7 +23,8 @@ $(PROJECT).elf: $(OBJECTS) %.bin: %.elf $(PLATFORM)-objcopy -O binary $< $*.bin -%.o: %.c +.SECONDEXPANSION: +%.o: $$(call depend,$$@) $(PLATFORM)-gcc -MM $< -MF $(patsubst %.o,%.d,$@) -MP $(PLATFORM)-gcc $(CFLAGS) -c $< -o $@