Add automatic dependencies
This commit is contained in:
parent
294553ee84
commit
24ee77720d
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
*.hex
|
||||
*.bin
|
||||
*.asm
|
||||
deps.mk
|
||||
|
6
Makefile
6
Makefile
@ -16,8 +16,10 @@ default: $(PROG).hex
|
||||
clean:
|
||||
rm -rf *.o drivers/*.o *.elf *.lst *.hex *.bin *.asm
|
||||
|
||||
# dependencies
|
||||
blink.elf: drivers/led.o
|
||||
# automatic dependencies
|
||||
include deps.mk
|
||||
deps.mk: *.c drivers/*.c
|
||||
for i in *.c; do echo $${i%.c}.elf: $$(./finddeps.sh "$$i"); echo; done > deps.mk
|
||||
|
||||
# generic rules
|
||||
%.o: %.c
|
||||
|
11
finddeps.sh
Executable file
11
finddeps.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
search() {
|
||||
echo "$1"
|
||||
prefix="$(printf "%s\n" "$1"|sed 's|[^/]*$||')"
|
||||
deps="$(grep -E '^#include "[^"]*"$' "$1"|cut '-d"' -f2|
|
||||
\sed "s|^|$prefix|;s|\.h\$|.c|"|grep -v "$1")"
|
||||
for i in $deps; do search $i; done
|
||||
}
|
||||
|
||||
search "$1"|grep -v "$1"|sed 's|\.c$|.o|'
|
Loading…
Reference in New Issue
Block a user