1
0

Makefile: Generalize flags and tools in preparation for i386 arch

This commit is contained in:
Aaron Lindsay 2012-11-15 00:30:17 -05:00
parent ccd5a9025a
commit c76991b1b5
2 changed files with 30 additions and 14 deletions

View File

@ -2,25 +2,26 @@
# Copyright (C) 2012, Aaron Lindsay <aaron@aclindsay.com>
# 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
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
# Define the tools to be used
TOOL_PREFIX = arm-elf-
AS = $(TOOL_PREFIX)as
CC = $(TOOL_PREFIX)gcc
LD = $(TOOL_PREFIX)ld
OBJCOPY = $(TOOL_PREFIX)objcopy
OBJDUMP = $(TOOL_PREFIX)objdump
AS = $(CROSS_COMPILE)as
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
# Define the flags we'll need for our tools
INCLUDES = -I include -I arch/$(ARCH)/include
KCFLAGS = -g -Wall -Wextra -Werror -nostdlib -nostartfiles -fno-builtin -std=gnu99 -include config.h $(INCLUDES)
KLDFLAGS = -T arch/$(ARCH)/kernel.ld -L /usr/lib/gcc/arm-elf/4.7.0/
EXTRA_LIBS = -lgcc
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/ $(ARCH_KLDFLAGS)
EXTRA_LIBS = $(ARCH_EXTRA_LIBS)
# Include the config file so we don't compile/link unnecessary objects
include config
@ -92,10 +93,18 @@ clean:
@echo ' CLEAN aedrix-kernel.img'
$(V)rm -f aedrix-kernel.img
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
boot-elf: aedrix-kernel.elf
$(V)$(ARCH_QEMU_CMD) -kernel aedrix-kernel.elf -serial stdio
boot-img: aedrix-kernel.img
$(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)
-include $(DEPENDENCY_FILES)

View File

@ -3,8 +3,15 @@ SUBDIRS := kernel
include $(BASEDIR)/header.mk
# Architecture-specific definitions
CROSS_COMPILE ?= arm-elf-
ARCH_KCFLAGS =
ARCH_EXTRA_LIBS = -lgcc
OBJS_$(d) := $(d)/start.o
KOBJS += $(OBJS_$(d))
include $(BASEDIR)/footer.mk
ARCH_QEMU_CMD = qemu-system-arm -m 1024 -M vexpress-a9