-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (36 loc) · 1.51 KB
/
Makefile
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
arch ?= x86_64
linker ?= ld
build_type ?= debug
kernel := build/kernel-$(arch).bin
iso := build/serex-$(arch).iso
linker_script := src/arch/$(arch)/unique/linker.ld
grub_cfg := src/arch/$(arch)/unique/grub.cfg
assembly_source_files := $(wildcard src/arch/$(arch)/unique/*.asm)
assembly_object_files := $(patsubst src/arch/$(arch)/%.asm, build/arch/$(arch)/%.o, $(assembly_source_files))
target ?= $(arch)
serex: target/$(target)/$(build_type)/libserex.a
.PHONY: all clean run iso kernel doc disk
all: $(kernel)
clean:
rm -r build
cargo clean
run: $(iso)
qemu-system-x86_64 -cdrom $(iso) -boot menu=on -vga std -s -serial file:serial.log
iso: $(iso)
@echo "ISO made."
$(iso): $(kernel) $(grub_cfg)
@mkdir -p build/iso/boot/grub
cp $(kernel) build/iso/boot/kernel.bin
cp $(grub_cfg) build/iso/boot/grub
grub-mkrescue -o $(iso) build/iso --modules="part_msdos boot cat configfile echo elf fat gfxmenu gfxterm iso9660 ls msdospart multiboot2 normal search_fs_file search video_fb video" #2> /dev/null
@rm -r build/iso
$(kernel): kernel $(serex) $(assembly_object_files) $(linker_script)
$(linker) --gc-sections -T $(linker_script) -o $(kernel) $(assembly_object_files) target/$(target)/$(build_type)/libserex.a
kernel:
@RUST_TARGET_PATH=$(32shell pwd) cargo build --target $(arch).json
build/arch/x86_64/unique/%.o: src/arch/x86_64/unique/%.asm
@mkdir -p $(shell dirname $@)
nasm -felf64 $< -o $@
build/arch/aarch64/unique/%.o: src/arch/aarch64/unique/%.asm
@mkdir -p $(shell dirname $@)
aarch64-linux-gnu-as -c $< -o $@