Makefile: Generalize flags and tools in preparation for i386 arch
This commit is contained in:
		
							
								
								
									
										37
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								Makefile
									
									
									
									
									
								
							| @@ -2,25 +2,26 @@ | |||||||
| # Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com> | # Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com> | ||||||
|  |  | ||||||
| # Config options for the code itself (should be separated from the Makefile sometime) | # Config options for the code itself (should be separated from the Makefile sometime) | ||||||
| ARCH = arm | ARCH ?= arm | ||||||
|  | #ARCH_KCFLAGS defined (if at all) in arch/$(ARCH)/kernel.mk | ||||||
|  | #CROSS_COMPILE defined (if at all) in arch/$(ARCH)/kernel.mk | ||||||
|  |  | ||||||
| # Config options concerning the build process itself | # Config options concerning the build process itself | ||||||
| VERBOSE ?= 0 # 1 shows all compiler flags, 0 shows cleaner output | VERBOSE ?= 0 # 1 shows all compiler flags, 0 shows cleaner output | ||||||
| V = $(if $(VERBOSE:1=),@) # Use this to prefix commands that should only be shown when VERBOSE==1 | V = $(if $(VERBOSE:1=),@) # Use this to prefix commands that should only be shown when VERBOSE==1 | ||||||
|  |  | ||||||
| # Define the tools to be used | # Define the tools to be used | ||||||
| TOOL_PREFIX = arm-elf- | AS = $(CROSS_COMPILE)as | ||||||
| AS = $(TOOL_PREFIX)as | CC = $(CROSS_COMPILE)gcc | ||||||
| CC = $(TOOL_PREFIX)gcc | LD = $(CROSS_COMPILE)ld | ||||||
| LD = $(TOOL_PREFIX)ld | OBJCOPY = $(CROSS_COMPILE)objcopy | ||||||
| OBJCOPY = $(TOOL_PREFIX)objcopy | OBJDUMP = $(CROSS_COMPILE)objdump | ||||||
| OBJDUMP = $(TOOL_PREFIX)objdump |  | ||||||
|  |  | ||||||
| # Define the flags we'll need for our tools | # Define the flags we'll need for our tools | ||||||
| INCLUDES = -I include -I arch/$(ARCH)/include | INCLUDES = -I include -I arch/$(ARCH)/include | ||||||
| KCFLAGS = -g -Wall -Wextra -Werror -nostdlib -nostartfiles -fno-builtin -std=gnu99 -include config.h $(INCLUDES) | KCFLAGS = -g -Wall -Wextra -Werror -nostdlib -nostartfiles -fno-builtin -std=gnu99 $(ARCH_KCFLAGS) -include config.h $(INCLUDES) | ||||||
| KLDFLAGS = -T arch/$(ARCH)/kernel.ld -L /usr/lib/gcc/arm-elf/4.7.0/ | KLDFLAGS = -T arch/$(ARCH)/kernel.ld -L /usr/lib/gcc/arm-elf/4.7.0/ $(ARCH_KLDFLAGS) | ||||||
| EXTRA_LIBS = -lgcc | EXTRA_LIBS = $(ARCH_EXTRA_LIBS) | ||||||
|  |  | ||||||
| # Include the config file so we don't compile/link unnecessary objects | # Include the config file so we don't compile/link unnecessary objects | ||||||
| include config | include config | ||||||
| @@ -92,10 +93,18 @@ clean: | |||||||
| 	@echo '  CLEAN   aedrix-kernel.img' | 	@echo '  CLEAN   aedrix-kernel.img' | ||||||
| 	$(V)rm -f aedrix-kernel.img | 	$(V)rm -f aedrix-kernel.img | ||||||
|  |  | ||||||
| boot: aedrix-kernel.img | boot-elf: aedrix-kernel.elf | ||||||
| 	$(V)qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.img -serial stdio | 	$(V)$(ARCH_QEMU_CMD) -kernel aedrix-kernel.elf -serial stdio | ||||||
| boot-gdb: aedrix-kernel.img | boot-img: aedrix-kernel.img | ||||||
| 	$(V)qemu-system-arm -m 1024 -M vexpress-a9 -kernel aedrix-kernel.img -serial stdio -S -s | 	$(V)$(ARCH_QEMU_CMD) -kernel aedrix-kernel.img -serial stdio | ||||||
|  | boot-hda: aedrix-boot.img | ||||||
|  | 	$(V)$(ARCH_QEMU_CMD) -hda aedrix-boot.img -serial stdio | ||||||
|  | boot-elf-gdb: aedrix-kernel.elf | ||||||
|  | 	$(V)$(ARCH_QEMU_CMD) -kernel aedrix-kernel.elf -serial stdio -S -s | ||||||
|  | boot-img-gdb: aedrix-kernel.img | ||||||
|  | 	$(V)$(ARCH_QEMU_CMD) -kernel aedrix-kernel.img -serial stdio -S -s | ||||||
|  | boot-hda-gdb: aedrix-boot.img | ||||||
|  | 	$(V)$(ARCH_QEMU_CMD) -hda aedrix-boot.img -serial stdio -S -s | ||||||
|  |  | ||||||
| DEPENDENCY_FILES = $(foreach file,$(KOBJS), $(dir $(file)).$(notdir $(basename $(file))).d) | DEPENDENCY_FILES = $(foreach file,$(KOBJS), $(dir $(file)).$(notdir $(basename $(file))).d) | ||||||
| -include $(DEPENDENCY_FILES) | -include $(DEPENDENCY_FILES) | ||||||
|   | |||||||
| @@ -3,8 +3,15 @@ SUBDIRS := kernel | |||||||
|  |  | ||||||
| include $(BASEDIR)/header.mk | include $(BASEDIR)/header.mk | ||||||
|  |  | ||||||
|  | # Architecture-specific definitions | ||||||
|  | CROSS_COMPILE ?= arm-elf- | ||||||
|  | ARCH_KCFLAGS = | ||||||
|  | ARCH_EXTRA_LIBS = -lgcc | ||||||
|  |  | ||||||
| OBJS_$(d) := $(d)/start.o | OBJS_$(d) := $(d)/start.o | ||||||
|  |  | ||||||
| KOBJS += $(OBJS_$(d)) | KOBJS += $(OBJS_$(d)) | ||||||
|  |  | ||||||
| include $(BASEDIR)/footer.mk | include $(BASEDIR)/footer.mk | ||||||
|  |  | ||||||
|  | ARCH_QEMU_CMD = qemu-system-arm -m 1024 -M vexpress-a9 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user