giomba
660771a06b
Kernel binary optionally stripped for final distribution (and upload via slow serial cable) Custom cross-toolchain variables
40 lines
800 B
Makefile
40 lines
800 B
Makefile
.POSIX:
|
|
|
|
TOOLCHAIN=arm-none-eabi-
|
|
|
|
CCX=$(TOOLCHAIN)g++
|
|
CCFLAGS=-c -Wall -fno-stack-protector -ffreestanding -fno-exceptions -march=armv7-a -mno-unaligned-access -nostdlib -Iinclude -g
|
|
STRIP=$(TOOLCHAIN)strip
|
|
|
|
C_HDR=$(wildcard include/*.h)
|
|
C_SRC=$(wildcard src/*.cpp)
|
|
C_OBJ=$(patsubst src/%.cpp, obj/c_%.o, $(C_SRC))
|
|
|
|
A_SRC=$(wildcard src/*.s)
|
|
A_OBJ=$(patsubst src/%.s, obj/s_%.o, $(A_SRC))
|
|
|
|
.PHONY: all environ clean
|
|
|
|
all: environ bin/kernel.elf
|
|
|
|
strip: bin/kernel.elf
|
|
$(STRIP) -s bin/kernel.elf
|
|
|
|
environ:
|
|
mkdir -p bin
|
|
mkdir -p obj
|
|
|
|
bin/kernel.elf: environ $(A_OBJ) $(C_OBJ)
|
|
arm-none-eabi-ld --nmagic -nostdlib -T src/linker.ld -o bin/kernel.elf obj/*.o
|
|
|
|
obj/s_%.o: src/%.s
|
|
$(CCX) $(CCFLAGS) -o $@ $<
|
|
|
|
obj/c_%.o: src/%.cpp $(C_HDR)
|
|
$(CCX) $(CCFLAGS) -o $@ $<
|
|
|
|
clean:
|
|
rm -f bin/*
|
|
rm -f obj/*
|
|
|