Makefile: Add automatic dependency generation
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -2,3 +2,4 @@ aedrix-kernel.elf | ||||
| aedrix-kernel.img | ||||
| *.o | ||||
| *.swp | ||||
| *.d | ||||
|   | ||||
							
								
								
									
										25
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								Makefile
									
									
									
									
									
								
							| @@ -50,21 +50,27 @@ aedrix-kernel.img: aedrix-kernel.elf | ||||
|  | ||||
| %.o: %.c | ||||
| 	@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 | ||||
| 	@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: | ||||
| 	@echo '  CLEAN   *.o' | ||||
| 	$(V)rm -f $(KOBJS) | ||||
| 	@echo '  CLEAN   .*.d' | ||||
| 	$(V)rm -f $(DEPENDENCY_FILES) | ||||
| 	@echo '  CLEAN   aedrix-kernel.elf' | ||||
| 	$(V)rm -f aedrix-kernel.elf | ||||
| 	@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 | ||||
| boot-gdb: aedrix-kernel.img | ||||
| 	$(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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user