| 
									
										
										
										
											2012-09-03 23:44:36 -04:00
										 |  |  | # Aedrix root Makefile
 | 
					
						
							|  |  |  | # Copyright (C) 2012 Aaron Lindsay <aaron@aclindsay.com>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Config options for the code itself (should be separated from the Makefile sometime)
 | 
					
						
							|  |  |  | ARCH = arm | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Config options concerning the build process itself
 | 
					
						
							|  |  |  | VERBOSE = 0 # 1 shows all compiler flags, 0 shows cleaner output | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Define the tools to be used
 | 
					
						
							|  |  |  | TOOL_PREFIX = arm-elf- | 
					
						
							|  |  |  | AS = $(TOOL_PREFIX)as | 
					
						
							|  |  |  | CC = $(TOOL_PREFIX)gcc | 
					
						
							|  |  |  | LD = $(TOOL_PREFIX)ld | 
					
						
							| 
									
										
										
										
											2012-09-17 23:34:16 -04:00
										 |  |  | OBJCPY = $(TOOL_PREFIX)objcopy | 
					
						
							| 
									
										
										
										
											2012-09-23 01:22:49 -04:00
										 |  |  | OBJDMP = $(TOOL_PREFIX)objdump | 
					
						
							| 
									
										
										
										
											2012-09-03 23:44:36 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Define the flags we'll need for our tools
 | 
					
						
							| 
									
										
										
										
											2012-09-07 23:58:19 -04:00
										 |  |  | INCLUDES = -I include | 
					
						
							| 
									
										
										
										
											2012-09-17 23:34:16 -04:00
										 |  |  | KCFLAGS = -g -Wall -Wextra -Werror -nostdlib -nostartfiles -fno-builtin -std=gnu99 $(INCLUDES) | 
					
						
							| 
									
										
										
										
											2012-09-09 01:58:38 -04:00
										 |  |  | KLDFLAGS = -T link.ld -L /usr/lib/gcc/arm-elf/4.7.0/ | 
					
						
							|  |  |  | EXTRA_LIBS = -lgcc | 
					
						
							| 
									
										
										
										
											2012-09-03 23:44:36 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-17 23:34:16 -04:00
										 |  |  | KOBJS = | 
					
						
							| 
									
										
										
										
											2012-09-03 23:44:36 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | include boot/Makefile.inc | 
					
						
							|  |  |  | include kernel/Makefile.inc | 
					
						
							| 
									
										
										
										
											2012-09-07 23:51:04 -04:00
										 |  |  | include devices/Makefile.inc | 
					
						
							| 
									
										
										
										
											2012-09-03 23:44:36 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-21 11:48:31 -04:00
										 |  |  | .PHONY: all clean boot | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-17 23:34:16 -04:00
										 |  |  | all: aedrix-kernel.img aedrix-kernel.elf | 
					
						
							| 
									
										
										
										
											2012-09-03 23:44:36 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-17 23:34:16 -04:00
										 |  |  | aedrix-kernel.elf: $(KOBJS) | 
					
						
							| 
									
										
										
										
											2012-09-03 23:44:36 -04:00
										 |  |  | 	$(if $(VERBOSE:1=),@echo '     LD $@') | 
					
						
							| 
									
										
										
										
											2012-09-09 01:58:38 -04:00
										 |  |  | 	$(if $(VERBOSE:1=),@)$(LD) $(KLDFLAGS) -o $@ $(KOBJS) $(EXTRA_LIBS) | 
					
						
							| 
									
										
										
										
											2012-09-03 23:44:36 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-23 01:22:49 -04:00
										 |  |  | aedrix-kernel.objdump: aedrix-kernel.elf | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@echo ' OBJDMP $@') | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@)$(OBJDMP) -D $< > $@ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-17 23:34:16 -04:00
										 |  |  | aedrix-kernel.img: aedrix-kernel.elf | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@echo ' OBJCPY $@') | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@)$(OBJCPY) $< -O binary $@ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-03 23:44:36 -04:00
										 |  |  | %.o: %.c | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@echo '     CC $@') | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@)$(CC) $(KCFLAGS) -c -o $@ $< | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Assembly files without preprocessor directives
 | 
					
						
							|  |  |  | %.o: %.s | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@echo '     AS $@') | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@)$(AS) -o $@ $< | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Assembly files with preprocessor directives
 | 
					
						
							|  |  |  | %.o: %.S | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@echo '     AS $@') | 
					
						
							|  |  |  | 	$(if $(VERBOSE:1=),@)$(AS) -o $@ $< | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | clean: | 
					
						
							|  |  |  | 	@echo '  CLEAN *.o' | 
					
						
							|  |  |  | 	@rm -f $(KOBJS) | 
					
						
							| 
									
										
										
										
											2012-09-17 23:34:16 -04:00
										 |  |  | 	@echo '  CLEAN aedrix-kernel.elf' | 
					
						
							|  |  |  | 	@rm -f aedrix-kernel.elf | 
					
						
							| 
									
										
										
										
											2012-09-23 01:22:49 -04:00
										 |  |  | 	@echo '  CLEAN aedrix-kernel.objdump' | 
					
						
							|  |  |  | 	@rm -f aedrix-kernel.objdump | 
					
						
							| 
									
										
										
										
											2012-09-17 23:34:16 -04:00
										 |  |  | 	@echo '  CLEAN aedrix-kernel.img' | 
					
						
							|  |  |  | 	@rm -f aedrix-kernel.img | 
					
						
							| 
									
										
										
										
											2012-09-07 23:58:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-17 23:34:16 -04:00
										 |  |  | boot: aedrix-kernel.elf | 
					
						
							|  |  |  | 	@qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.elf -serial stdio |