git.asbjorn.biz
/
rapper.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Automatically calculate make dependencies
[rapper.git]
/
src
/
Makefile
diff --git
a/src/Makefile
b/src/Makefile
index
bf7dcc7
..
fbc9ad9
100644
(file)
--- 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)
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
all: crc
@@
-20,7
+23,8
@@
$(PROJECT).elf: $(OBJECTS)
%.bin: %.elf
$(PLATFORM)-objcopy -O binary $< $*.bin
%.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 $@
$(PLATFORM)-gcc -MM $< -MF $(patsubst %.o,%.d,$@) -MP
$(PLATFORM)-gcc $(CFLAGS) -c $< -o $@