-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
33 lines (25 loc) · 1.03 KB
/
Makefile
File metadata and controls
33 lines (25 loc) · 1.03 KB
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
#--------------------------------------Makefile-------------------------------------
ifeq ($(OS),Windows_NT)
MAKEFILE_DIR := $(shell powershell -Command "Split-Path -Path '$(lastword $(MAKEFILE_LIST))' -Parent")
else
MAKEFILE_DIR := $(shell pwd)
endif
GCCFLAGS = -Wall -O2 -ffreestanding -nostdinc -nostdlib
DIR_BUI = build
DIR_KER = kernel
DIR_ROOT := $(MAKEFILE_DIR)
CFILES = $(wildcard $(DIR_KER)/*.c)
OFILES = $(CFILES:$(DIR_KER)/%.c=$(DIR_BUI)/%.o)
all: $(DIR_BUI)/kernel8.img run
$(DIR_BUI)/boot.o: $(DIR_KER)/boot.S
aarch64-none-elf-gcc -I$(DIR_ROOT) $(GCCFLAGS) -c $< -o $@
$(DIR_BUI)/%.o: $(DIR_KER)/%.c
aarch64-none-elf-gcc -I$(DIR_ROOT) $(GCCFLAGS) -c $< -o $@
$(DIR_BUI)/kernel8.img: $(DIR_BUI)/boot.o $(OFILES)
aarch64-none-elf-ld -nostdlib $^ -T $(DIR_KER)/link.ld -o $(DIR_BUI)/kernel8.elf
aarch64-none-elf-objcopy -O binary $(DIR_BUI)/kernel8.elf $@
clean:
del /F /Q .\$(DIR_BUI)\*
# Run emulation with QEMU
run:
qemu-system-aarch64 -M raspi3 -kernel $(DIR_BUI)/kernel8.img -serial stdio