-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
117 lines (94 loc) · 3.11 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
115
116
117
################################################################################
#
# kit/Makefile
# - top-level build rules and definitions
#
# vim:ts=2:sw=2:et:tw=80:ft=make
#
# Copyright (C) 2015-2021, Devyn Cairns
# Redistribution of this file is permitted under the terms of the simplified BSD
# license. See LICENSE for more information.
#
################################################################################
CC = clang
AS = as
CARGO = cargo
LD = ld
export CPATH=system/libc/include
GRUB_LIB=/usr/lib/grub
OVMF_DIR=/usr/share/edk2-ovmf/x64
GRUB_MODULES_ALL = normal iso9660 multiboot at_keyboard
GRUB_MODULES_EFI = efi_gop gfxterm
GRUB_MODULES_BIOS = biosdisk vga_text
ECHO_CC = echo "[36m CC [0m"
ECHO_AS = echo "[36m AS [0m"
ECHO_RUSTC = echo "[36m RUSTC [0m"
ECHO_LD = echo "[36m LD [0m"
all: all-deps all-kernel all-system all-iso
doc: doc-kernel
clean: clean-deps clean-kernel clean-system clean-iso clean-doc
clean-doc:
rm -rf build/doc
.PHONY: all doc clean clean-doc
build/.dir:
mkdir -p build
touch build/.dir
build/doc/.dir: build/.dir
mkdir -p build/doc
touch build/doc/.dir
include deps/deps.mk
include kernel/kernel.mk
include system/system.mk
# =ISO Image=
all-iso: build/kit.iso
clean-iso:
rm -f build/kit.iso
rm -rf build/isodir
.PHONY: all-iso clean-iso
build/kit.iso: resources/grub.cfg build/kernel.elf build/system.kit
mkdir -p build/isodir/boot/grub
mkdir -p build/efidir/EFI/BOOT
cp resources/grub.cfg build/isodir/boot/grub/grub.cfg
cp build/kernel.elf build/isodir/boot/kernel.elf
cp build/system.kit build/isodir/boot/system.kit
grub-mkimage --format=i386-pc --output=build/core.img -p '/boot/grub' \
--config=build/isodir/boot/grub/grub.cfg \
${GRUB_MODULES_ALL} ${GRUB_MODULES_BIOS}
cat ${GRUB_LIB}/i386-pc/cdboot.img build/core.img \
> build/isodir/grub.img
grub-mkimage --format=i386-efi \
--output=build/efidir/EFI/BOOT/BOOTIA32.EFI \
-p '/boot/grub' \
--config=build/isodir/boot/grub/grub.cfg \
${GRUB_MODULES_ALL} ${GRUB_MODULES_EFI}
grub-mkimage --format=x86_64-efi \
--output=build/efidir/EFI/BOOT/BOOTX64.EFI \
-p '/boot/grub' \
--config=build/isodir/boot/grub/grub.cfg \
${GRUB_MODULES_ALL} ${GRUB_MODULES_EFI}
rm -f build/isodir/efi.img
fallocate -l 16M build/isodir/efi.img
mkfs.vfat build/isodir/efi.img
mcopy -i build/isodir/efi.img -s build/efidir/* "::"
xorriso -as mkisofs \
-R -J -A "Kit" -input-charset "iso8859-1" -R \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-b grub.img \
-c boot.cat \
-eltorito-alt-boot -e efi.img \
-no-emul-boot -isohybrid-gpt-basdat \
-efi-boot-part --efi-boot-image \
-o build/kit.iso \
build/isodir
# =Testing=
run-qemu: build/kit.iso
qemu-system-x86_64 -cdrom build/kit.iso -boot d -serial stdio ${QEMUFLAGS}
build/OVMF_VARS.fd: ${OVMF_DIR}/OVMF_VARS.fd
cp $< $@
run-qemu-efi: build/kit.iso build/OVMF_VARS.fd
qemu-system-x86_64 -cdrom build/kit.iso -boot d -serial stdio \
-machine q35 \
-drive if=pflash,format=raw,readonly=on,file=${OVMF_DIR}/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=build/OVMF_VARS.fd \
${QEMUFLAGS}
.PHONY: run-qemu