1
0
Fork 0
aedrix-kernel/Makefile

75 lines
2.0 KiB
Makefile

# 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
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
# Define the flags we'll need for our tools
INCLUDES = -I include
KCFLAGS = -g -Wall -Wextra -Werror -nostdlib -nostartfiles -fno-builtin -std=gnu99 $(INCLUDES)
KLDFLAGS = -T link.ld -L /usr/lib/gcc/arm-elf/4.7.0/
EXTRA_LIBS = -lgcc
KOBJS =
include boot/Makefile.inc
include kernel/Makefile.inc
include devices/Makefile.inc
.PHONY: all clean boot boot-gdb
all: aedrix-kernel.img aedrix-kernel.elf
aedrix-kernel.elf: $(KOBJS)
@echo ' LD $@'
$(V)$(LD) $(KLDFLAGS) -o $@ $(KOBJS) $(EXTRA_LIBS)
aedrix-kernel.objdump: aedrix-kernel.elf
@echo 'OBJDUMP $@'
$(V)$(OBJDUMP) -D $< > $@
aedrix-kernel.img: aedrix-kernel.elf
@echo 'OBJCOPY $@'
$(V)$(OBJCOPY) $< -O binary $@
%.o: %.c
@echo ' CC $@'
$(V)$(CC) $(KCFLAGS) -c -o $@ $<
# Assembly files without preprocessor directives
%.o: %.s
@echo ' AS $@'
$(V)$(AS) -o $@ $<
# Assembly files with preprocessor directives
%.o: %.S
@echo ' AS $@'
$(V)$(AS) -o $@ $<
clean:
@echo ' CLEAN *.o'
$(V)rm -f $(KOBJS)
@echo ' CLEAN aedrix-kernel.elf'
$(V)rm -f aedrix-kernel.elf
@echo ' CLEAN aedrix-kernel.objdump'
$(V)rm -f aedrix-kernel.objdump
@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