-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
212 lines (187 loc) · 5.89 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
MAKEFLAGS += -rR
.SUFFIXES:
# Convenience macro to reliably declare user overridable variables.
override USER_VARIABLE = $(if $(filter $(origin $(1)),default undefined),$(eval override $(1) := $(2)))
# Target architecture to build for. Default to x86_64.
$(call USER_VARIABLE,ARCH,x86_64)
# Default user QEMU flags. These are appended to the QEMU command calls.
$(call USER_VARIABLE,QEMUFLAGS,-m 2G)
.PHONY: all
all: orchestros.iso
.PHONY: all-hdd
all_hdd: orchestros.hdd
.PHONY: run
run: run-$(ARCH)
.PHONY: run-hdd
run-hdd: run-hdd-$(ARCH)
.PHONY: run-x86_64
run-x86_64: ovmf/ovmf-code-$(ARCH).fd orchestros.iso
qemu-system-$(ARCH) \
-M q35 \
-drive if=pflash,unit=0,format=raw,file=ovmf/ovmf-code-$(ARCH).fd,readonly=on \
-cdrom orchestros.iso \
-debugcon stdio \
$(QEMUFLAGS)
.PHONY: run-hdd-x86_64
run-hdd-x86_64: ovmf/ovmf-code-$(ARCH).fd orchestros.hdd
qemu-system-$(ARCH) \
-M q35 \
-drive if=pflash,unit=0,format=raw,file=ovmf/ovmf-code-$(ARCH).fd,readonly=on \
-hda orchestros.hdd \
-debugcon stdio \
$(QEMUFLAGS)
.PHONY: run-aarch64
run-aarch64: ovmf/ovmf-code-$(ARCH).fd orchestros.iso
qemu-system-$(ARCH) \
-M virt \
-cpu cortex-a72 \
-device ramfb \
-device qemu-xhci \
-device usb-kbd \
-device usb-mouse \
-drive if=pflash,unit=0,format=raw,file=ovmf/ovmf-code-$(ARCH).fd,readonly=on \
-cdrom orchestros.iso \
$(QEMUFLAGS)
.PHONY: run-hdd-aarch64
run-hdd-aarch64: ovmf/ovmf-code-$(ARCH).fd orchestros.hdd
qemu-system-$(ARCH) \
-M virt \
-cpu cortex-a72 \
-device ramfb \
-device qemu-xhci \
-device usb-kbd \
-device usb-mouse \
-drive if=pflash,unit=0,format=raw,file=ovmf/ovmf-code-$(ARCH).fd,readonly=on \
-hda orchestros.hdd \
$(QEMUFLAGS)
.PHONY: run-riscv64
run-riscv64: ovmf/ovmf-code-$(ARCH).fd orchestros.iso
qemu-system-$(ARCH) \
-M virt \
-cpu rv64 \
-device ramfb \
-device qemu-xhci \
-device usb-kbd \
-device usb-mouse \
-drive if=pflash,unit=0,format=raw,file=ovmf/ovmf-code-$(ARCH).fd,readonly=on \
-cdrom orchestros.iso \
$(QEMUFLAGS)
.PHONY: run-hdd-riscv64
run-hdd-riscv64: ovmf/ovmf-code-$(ARCH).fd orchestros.hdd
qemu-system-$(ARCH) \
-M virt \
-cpu rv64 \
-device ramfb \
-device qemu-xhci \
-device usb-kbd \
-device usb-mouse \
-drive if=pflash,unit=0,format=raw,file=ovmf/ovmf-code-$(ARCH).fd,readonly=on \
-hda orchestros.hdd \
$(QEMUFLAGS)
.PHONY: run-bios
run-bios: orchestros.iso
qemu-system-$(ARCH) \
-M q35 \
-cdrom orchestros.iso \
-boot d \
-debugcon stdio \
$(QEMUFLAGS)
.PHONY: run-hdd-bios
run-hdd-bios: orchestros.hdd
qemu-system-$(ARCH) \
-M q35 \
-hda orchestros.hdd \
-debugcon stdio \
$(QEMUFLAGS)
ovmf/ovmf-code-$(ARCH).fd:
mkdir -p ovmf
curl -Lo $@ https://github.com/osdev0/edk2-ovmf-nightly/releases/latest/download/ovmf-code-$(ARCH).fd
case "$(ARCH)" in \
aarch64) dd if=/dev/zero of=$@ bs=1 count=0 seek=67108864 2>/dev/null;; \
riscv64) dd if=/dev/zero of=$@ bs=1 count=0 seek=33554432 2>/dev/null;; \
esac
limine/limine:
rm -rf limine
git clone https://github.com/limine-bootloader/limine.git --branch=v8.x-binary --depth=1
$(MAKE) -C limine
symphony-deps:
./scripts/get-deps
touch symphony-deps
symphony-docs:
cd docs && doxygen
.PHONY: symphony
symphony: symphony-deps
mkdir -p build
ln -sfr ./include/symphony/arch/$(ARCH).h include/symphony/arch/arch.h
$(MAKE) -C symphony
orchestros.iso: limine/limine symphony
rm -rf iso_root
mkdir -p iso_root
cp -v build/$(ARCH)/symphony/symphony.elf iso_root/
mkdir -p iso_root/limine
cp -v limine.conf iso_root/limine/
mkdir -p iso_root/EFI/BOOT
ifeq ($(ARCH),x86_64)
cp -v limine/limine-bios.sys limine/limine-bios-cd.bin limine/limine-uefi-cd.bin iso_root/limine/
cp -v limine/BOOTX64.EFI iso_root/EFI/BOOT/
cp -v limine/BOOTIA32.EFI iso_root/EFI/BOOT/
xorriso -as mkisofs -R -r -J -b limine/limine-bios-cd.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table -hfsplus \
-apm-block-size 2048 --efi-boot limine/limine-uefi-cd.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
iso_root -o orchestros.iso
./limine/limine bios-install orchestros.iso
endif
ifeq ($(ARCH),aarch64)
cp -v limine/limine-uefi-cd.bin iso_root/limine/
cp -v limine/BOOTAA64.EFI iso_root/EFI/BOOT/
xorriso -as mkisofs -R -r -J \
-hfsplus -apm-block-size 2048 \
--efi-boot limine/limine-uefi-cd.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
iso_root -o orchestros.iso
endif
ifeq ($(ARCH),riscv64)
cp -v limine/limine-uefi-cd.bin iso_root/limine/
cp -v limine/BOOTRISCV64.EFI iso_root/EFI/BOOT/
xorriso -as mkisofs -R -r -J \
-hfsplus -apm-block-size 2048 \
--efi-boot limine/limine-uefi-cd.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
iso_root -o orchestros.iso
endif
rm -rf iso_root
orchestros.hdd: limine/limine symphony
rm -f orchestros.hdd
dd if=/dev/zero bs=1M count=0 seek=64 of=orchestros.hdd
sgdisk orchestros.hdd -n 1:2048 -t 1:ef00
ifeq ($(ARCH),x86_64)
./limine/limine bios-install orchestros.hdd
endif
mformat -i orchestros.hdd@@1M
mmd -i orchestros.hdd@@1M ::/EFI ::/EFI/BOOT ::/limine
mcopy -i orchestros.hdd@@1M build/$(ARCH)/symphony/symphony.elf ::/
mcopy -i orchestros.hdd@@1M limine.conf ::/limine
ifeq ($(ARCH),x86_64)
mcopy -i orchestros.hdd@@1M limine/limine-bios.sys ::/limine
mcopy -i orchestros.hdd@@1M limine/BOOTX64.EFI ::/EFI/BOOT
mcopy -i orchestros.hdd@@1M limine/BOOTIA32.EFI ::/EFI/BOOT
endif
ifeq ($(ARCH),aarch64)
mcopy -i orchestros.hdd@@1M limine/BOOTAA64.EFI ::/EFI/BOOT
endif
ifeq ($(ARCH),riscv64)
mcopy -i orchestros.hdd@@1M limine/BOOTRISCV64.EFI ::/EFI/BOOT
endif
.PHONY: clean
clean:
$(MAKE) -C symphony clean
rm -rf iso_root *.iso *.hdd build
.PHONY: distclean
distclean:
$(MAKE) -C symphony distclean
rm -rf iso_root *.iso *.hdd symphony-deps deps limine ovmf build toolchain
.PHONY: distclean-keep-toolchain
distclean-keep-toolchain:
$(MAKE) -C symphony distclean
rm -rf iso_root *.iso *.hdd symphony-deps deps limine ovmf build