-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
executable file
·75 lines (56 loc) · 1.74 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
# This script is used to build Infinity OS and the dependent components
#
# Please make our changes on the config.mak file and not here
#
LDFLAGS = $(NO_AS_NEEDED)
LD = $(prefix)ld
# Include the default configuration file
include mk/config.mk
# Include the configuration file
-include config.mak
# Filesystem
include mk/initfs.mk
# Docker
include mk/docker.mk
arch ?= x86_64
target ?= $(arch)-unknown-pulsar
ktarget ?= $(arch)-unknown-none
kernel := build/kernel-$(arch).bin
iso := build/os-$(arch).iso
rust_os := target/$(ktarget)/debug/libinfinity_os.a
linker_script := arch/$(arch)/linker.ld
grub_cfg := arch/$(arch)/grub.cfg
assembly_source_files := $(wildcard arch/$(arch)/assembly/*.asm)
assembly_object_files := $(patsubst arch/$(arch)/assembly/%.asm, \
build/arch/$(arch)/%.o, $(assembly_source_files))
# Qemu variables
QEMU=qemu-system-$(arch)
QEMUFLAGS=-serial mon:stdio -d cpu_reset -d guest_errors
QEMUFLAGS+=-smp 4 -m 1024
.PHONY: all clean run iso cargo
all: $(kernel)
clean:
@cargo clean
@rm -rf build
run: $(iso)
$(QEMU) $(QEMUFLAGS) -cdrom $(iso) -s
debug: $(iso)
@qemu-system-x86_64 -cdrom $(iso) -s -S
r2:
@r2 -d gdb://localhost:1234
iso: $(iso)
$(iso): $(kernel) $(grub_cfg)
@mkdir -p build/isofiles/boot/grub
@cp $(kernel) build/isofiles/boot/kernel.bin
@cp $(grub_cfg) build/isofiles/boot/grub
@grub-mkrescue -o $(iso) build/isofiles 2> /dev/null
@rm -r build/isofiles
$(kernel): cargo $(rust_os) $(assembly_object_files) $(linker_script) initfs.tag
@$(LD) $(LDFLAGS) -n --gc-sections -T $(linker_script) -o $(kernel) $(assembly_object_files) $(rust_os)
cargo:
@xargo build --target $(ktarget)
# compile assembly files
build/arch/$(arch)/%.o: arch/$(arch)/assembly/%.asm
@mkdir -p $(shell dirname $@)
@nasm -felf64 $< -o $@