-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (67 loc) · 2.53 KB
/
Makefile
File metadata and controls
86 lines (67 loc) · 2.53 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
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
KERNEL = target/x86_64-unknown-none/release/kernel
ISO = serix.iso
ISO_ROOT = iso_root
LIMINE_DIR = limine
LIMINE_BRANCH = v10.x-binary
LIMINE_URL = https://github.com/limine-bootloader/limine.git
.PHONY: all run iso disk clean limine kernel
all: iso
kernel:
cargo build --manifest-path kernel/Cargo.toml --release --target x86_64-unknown-none
limine:
if [ ! -d $(LIMINE_DIR) ]; then \
git clone $(LIMINE_URL) --branch=$(LIMINE_BRANCH) --depth=1 $(LIMINE_DIR); \
fi
make -C $(LIMINE_DIR)
$(ISO_ROOT)/boot:
mkdir -p $@
$(ISO_ROOT)/boot/kernel: kernel | $(ISO_ROOT)/boot
cp $(KERNEL) $@
$(ISO_ROOT)/boot/limine-bios.sys $(ISO_ROOT)/boot/limine-bios-cd.bin $(ISO_ROOT)/boot/limine-uefi-cd.bin: limine | $(ISO_ROOT)/boot
cp $(LIMINE_DIR)/limine-bios.sys $(ISO_ROOT)/boot/
cp $(LIMINE_DIR)/limine-bios-cd.bin $(ISO_ROOT)/boot/
cp $(LIMINE_DIR)/limine-uefi-cd.bin $(ISO_ROOT)/boot/
$(ISO_ROOT)/limine.conf:
cp ./limine.conf $@
init:
RUSTFLAGS="-C relocation-model=static -C link-arg=-Tuser.ld -C link-arg=-no-pie" cargo build \
-p ulib \
--example init \
--release \
--target x86_64-unknown-none
rsh:
RUSTFLAGS="-C relocation-model=static -C link-arg=-Tuser.ld -C link-arg=-no-pie" cargo build \
--manifest-path ../rsh/Cargo.toml \
--release \
--target x86_64-unknown-none
iso: $(ISO_ROOT)/boot/kernel $(ISO_ROOT)/boot/limine-bios.sys $(ISO_ROOT)/boot/limine-bios-cd.bin $(ISO_ROOT)/boot/limine-uefi-cd.bin $(ISO_ROOT)/limine.conf
xorriso -as mkisofs -b boot/limine-bios-cd.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table \
--efi-boot boot/limine-uefi-cd.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
$(ISO_ROOT) -o $(ISO)
./limine/limine bios-install $(ISO)
disk:
@if [ ! -f disk.img ] || [ "$$(file disk.img | grep -c ext2)" -eq 0 ]; then \
dd if=/dev/zero of=disk.img bs=1M count=64 2>/dev/null; \
mkfs.ext2 disk.img; \
echo "Formatted disk.img as ext2"; \
else \
echo "disk.img already ext2, skipping format"; \
fi
QEMU_COMMON = -m 4G -boot d -cdrom $(ISO) \
-drive file=disk.img,if=none,format=raw,id=x0 \
-device virtio-blk-pci,drive=x0,disable-legacy=on,disable-modern=off
run: iso disk
qemu-system-x86_64 $(QEMU_COMMON) -serial stdio
run-nographic: iso disk
qemu-system-x86_64 $(QEMU_COMMON) -nographic
run-debug: iso disk
qemu-system-x86_64 $(QEMU_COMMON) -serial stdio \
-d int,cpu_reset -no-reboot
run-gdb: iso disk
qemu-system-x86_64 $(QEMU_COMMON) -serial stdio \
-s -S
clean:
rm -rf $(ISO_ROOT) $(ISO)
cargo clean --manifest-path kernel/Cargo.toml