summaryrefslogtreecommitdiff
path: root/Makefile
blob: 023c3834110553a8ca5df4ea247dd8b4b3ff8f4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# tashaboot
#
# build: make CROSS=aarch64-linux-gnu-
# run:   make run  (qemu virt, semihosting, Image on the host)
#
# the dtb is the board config, no board.h exists anywhere.

CROSS	?= aarch64-linux-gnu-
CC	:= $(CROSS)gcc
LD	:= $(CROSS)ld
OBJCOPY	:= $(CROSS)objcopy
DTC	?= dtc

CFLAGS	:= -nostdlib -ffreestanding -mgeneral-regs-only \
	   -fno-builtin -fno-stack-protector -fno-pie -no-pie \
	   -Wall -Werror -O2 \
	   -Iinclude -Iarch/arm64/include -Ilib/libfdt

LDFLAGS	:= -T arch/arm64/kernel/tashaboot.lds

OBJS	:= arch/arm64/kernel/start.o \
	   arch/arm64/kernel/boot.o \
	   arch/arm64/lib/cache.o \
	   arch/arm64/lib/semihosting.o \
	   common/main.o common/console.o common/image.o common/load.o \
	   drivers/serial/pl011.o \
	   lib/printf.o lib/itoa.o lib/semihosting.o \
	   $(patsubst %.c,%.o,$(wildcard lib/string/*.c)) \
	   $(patsubst %.c,%.o,$(filter-out lib/libfdt/libfdt_env.h,$(wildcard lib/libfdt/*.c)))

all: build/tashaboot.bin build/qemu-virt.dtb

build/tashaboot.elf: $(OBJS) arch/arm64/kernel/tashaboot.lds
	mkdir -p build
	$(LD) $(LDFLAGS) -o $@ $(OBJS)

build/tashaboot.bin: build/tashaboot.elf
	$(OBJCOPY) -O binary $< $@

build/qemu-virt.dtb: dts/qemu-virt.dts
	mkdir -p build
	$(DTC) -o $@ $<

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

%.o: %.S
	$(CC) $(CFLAGS) -c -o $@ $<

run: all
	qemu-system-aarch64 -M virt -cpu cortex-a57 -nographic -no-reboot \
		-semihosting config=all,enable=on -dtb build/qemu-virt.dtb \
		-kernel build/tashaboot.bin

clean:
	rm -rf build $(OBJS)

.PHONY: all run clean