-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
56 lines (48 loc) · 1.49 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
# SPDX-License-Identifier: GPL-3.0-only
TARGET = x86_64-unknown-uefi
BUILD = build/$(TARGET)
QEMU = qemu-system-x86_64
OVMF = /usr/share/OVMF
export BASEDIR ?= system76-firmware-update
all: $(BUILD)/boot.efi
.PHONY: clean
clean:
cargo clean
rm -rf build
.PHONY: qemu
qemu: $(BUILD)/boot.img $(OVMF)/OVMF_VARS.fd $(OVMF)/OVMF_CODE.fd
cp $(OVMF)/OVMF_CODE.fd target/
cp $(OVMF)/OVMF_VARS.fd target/
$(QEMU) -enable-kvm -M q35 -m 1024 -vga std \
-chardev stdio,mux=on,id=debug \
-device isa-serial,index=2,chardev=debug \
-device isa-debugcon,iobase=0x402,chardev=debug \
-drive if=pflash,format=raw,readonly=on,file=target/OVMF_CODE.fd \
-drive if=pflash,format=raw,readonly=on,file=target/OVMF_VARS.fd \
-net none \
$<
$(BUILD)/boot.img: $(BUILD)/efi.img
dd if=/dev/zero [email protected] bs=512 count=100352
parted [email protected] -s -a minimal mklabel gpt
parted [email protected] -s -a minimal mkpart EFI FAT16 2048s 93716s
parted [email protected] -s -a minimal toggle 1 boot
dd if=$< [email protected] bs=512 count=98304 seek=2048 conv=notrunc
mv [email protected] $@
$(BUILD)/efi.img: $(BUILD)/boot.efi res/*
dd if=/dev/zero [email protected] bs=512 count=98304
mkfs.vfat [email protected]
mmd -i [email protected] efi
mmd -i [email protected] efi/boot
mcopy -i [email protected] $< ::efi/boot/bootx64.efi
mmd -i [email protected] $(BASEDIR)
mcopy -i [email protected] -s res ::$(BASEDIR)
if [ -d firmware ]; then mcopy -i [email protected] -s firmware ::$(BASEDIR); fi
mv [email protected] $@
.PHONY: $(BUILD)/boot.efi
$(BUILD)/boot.efi:
mkdir -p $(@D)
cargo rustc \
--target $(TARGET) \
--release \
-- \
--emit link=$@