Makefile: Add automatic dependency generation
This commit is contained in:
parent
c455b1eeb3
commit
c84fd58ce4
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ aedrix-kernel.elf
|
|||||||
aedrix-kernel.img
|
aedrix-kernel.img
|
||||||
*.o
|
*.o
|
||||||
*.swp
|
*.swp
|
||||||
|
*.d
|
||||||
|
25
Makefile
25
Makefile
@ -50,21 +50,27 @@ aedrix-kernel.img: aedrix-kernel.elf
|
|||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
@echo ' CC $@'
|
@echo ' CC $@'
|
||||||
$(V)$(CC) $(KCFLAGS) -c -o $@ $<
|
$(V)$(CC) $(KCFLAGS) -MD -c -o $@ $<
|
||||||
|
@# Automatic dependency generation fixups (http://mad-scientist.net/make/autodep.html)
|
||||||
|
@cp $*.d $(*D)/.$(*F).d; \
|
||||||
|
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
||||||
|
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(*D)/.$(*F).d; \
|
||||||
|
rm -f $*.d
|
||||||
|
|
||||||
# Assembly files without preprocessor directives
|
|
||||||
%.o: %.s
|
|
||||||
@echo ' AS $@'
|
|
||||||
$(V)$(AS) -o $@ $<
|
|
||||||
|
|
||||||
# Assembly files with preprocessor directives
|
|
||||||
%.o: %.S
|
%.o: %.S
|
||||||
@echo ' AS $@'
|
@echo ' AS $@'
|
||||||
$(V)$(AS) -o $@ $<
|
$(V)$(CC) $(KCFLAGS) -MD -c -o $@ $<
|
||||||
|
@# Automatic dependency generation fixups (http://mad-scientist.net/make/autodep.html)
|
||||||
|
@cp $*.d $(*D)/.$(*F).d; \
|
||||||
|
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
|
||||||
|
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(*D)/.$(*F).d; \
|
||||||
|
rm -f $*.d
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo ' CLEAN *.o'
|
@echo ' CLEAN *.o'
|
||||||
$(V)rm -f $(KOBJS)
|
$(V)rm -f $(KOBJS)
|
||||||
|
@echo ' CLEAN .*.d'
|
||||||
|
$(V)rm -f $(DEPENDENCY_FILES)
|
||||||
@echo ' CLEAN aedrix-kernel.elf'
|
@echo ' CLEAN aedrix-kernel.elf'
|
||||||
$(V)rm -f aedrix-kernel.elf
|
$(V)rm -f aedrix-kernel.elf
|
||||||
@echo ' CLEAN aedrix-kernel.objdump'
|
@echo ' CLEAN aedrix-kernel.objdump'
|
||||||
@ -76,3 +82,6 @@ boot: aedrix-kernel.img
|
|||||||
$(V)qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.img -serial stdio
|
$(V)qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.img -serial stdio
|
||||||
boot-gdb: aedrix-kernel.img
|
boot-gdb: aedrix-kernel.img
|
||||||
$(V)qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.img -serial stdio -S -s
|
$(V)qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.img -serial stdio -S -s
|
||||||
|
|
||||||
|
DEPENDENCY_FILES = $(foreach file,$(KOBJS), $(dir $(file)).$(notdir $(basename $(file))).d)
|
||||||
|
-include $(DEPENDENCY_FILES)
|
||||||
|
Loading…
Reference in New Issue
Block a user