-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
114 lines (82 loc) · 2.52 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
NASM=nasm
QEMU=qemu-system-x86_64
LD=~/opt/cross/bin/x86_64-elf-ld
BUILD_DIR=_build/
RUST_BUILD_DIR=target
install-requirements:
rustup component add rust-src
cargo install cargo-xbuild
clean:
rm -rf $(BUILD_DIR)
rm -rf $(RUST_BUILD_DIR)
build-bootloader:
mkdir -p $(BUILD_DIR)
$(NASM) -f elf64 src/boot/loader/multiboot_header.asm -o $(BUILD_DIR)/multiboot_header.o
$(NASM) -f elf64 src/boot/loader/boot.asm -o $(BUILD_DIR)/boot.o
$(NASM) -f elf64 src/boot/loader/long_mode_init.asm -o $(BUILD_DIR)/long_mode_init.o
$(NASM) -f elf64 src/boot/loader/checks.asm -o $(BUILD_DIR)/checks.o
$(NASM) -f elf64 src/multitasking/switch_to.asm -o $(BUILD_DIR)/switch_to.o
$(LD) --nmagic \
-o $(BUILD_DIR)/kernel.bin \
--script=src/boot/loader/linker.ld \
$(BUILD_DIR)/multiboot_header.o \
$(BUILD_DIR)/boot.o \
$(BUILD_DIR)/long_mode_init.o \
$(BUILD_DIR)/checks.o \
$(BUILD_DIR)/switch_to.o \
$(RUST_BUILD_DIR)/x86_64-mos/debug/libmos.a
build-kernel:
RUST_TARGET_PATH=`pwd` xargo build --target x86_64-mos
build-os-binaries:
cd ./lib/userspace/msh && make build
cp ./lib/userspace/msh/target/x86_64-msh/debug/msh ./initrd/msh
cd ./lib/userspace/hello_world && make build
cp ./lib/userspace/hello_world/target/x86_64-hello_world/debug/hello_world ./initrd/hello_world
build-initrd:
mkdir -p $(BUILD_DIR)/isofiles/boot/
cd ./initrd/ && tar --format ustar --owner=0 --group=0 -c * > ../$(BUILD_DIR)/isofiles/boot/initrd.tar
build:
mkdir -p $(BUILD_DIR)
make build-kernel
make build-bootloader
make build-os-binaries
make build-initrd
build/%:
cargo xbuild --target x86_64-mos.json --bin $*
iso: build
# copy loader
mkdir -p $(BUILD_DIR)/isofiles/boot/grub
cp src/boot/loader/grub.cfg $(BUILD_DIR)/isofiles/boot/grub
cp $(BUILD_DIR)/kernel.bin $(BUILD_DIR)/isofiles/boot
docker-compose run build_os grub-mkrescue -o /src/$(BUILD_DIR)/os.iso /src/$(BUILD_DIR)/isofiles
unit-tests:
cargo test
cd lib/librust && cargo test
tests: unit-tests
integration-test/%:
make build/$*
-qemu-system-x86_64 \
-serial mon:stdio \
-drive format=raw,file=target/x86_64-mos/debug/bootimage-$*.bin \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-display none
exit 0
integration-tests:
bash run-tests.sh
run: iso
$(QEMU) -cdrom $(BUILD_DIR)/os.iso \
-serial mon:stdio \
-m 128M \
-boot d
run-debug: iso
$(QEMU) -cdrom $(BUILD_DIR)/os.iso \
-serial mon:stdio \
-m 128M \
-boot d \
-d int \
-monitor stdio
run-curses: iso
$(QEMU) -cdrom $(BUILD_DIR)/os.iso \
-m 128M \
-boot d \
-curses