-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
55 lines (47 loc) · 1.25 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
TARGET?=x86_64-unknown-uefi
export BASEDIR?=system76-firmware-update
export LD=ld
export RUST_TARGET_PATH=$(CURDIR)/targets
BUILD=build/$(TARGET)
QEMU?=qemu-system-x86_64
QEMU_FLAGS=\
-accel kvm \
-M q35 \
-m 1024 \
-net none \
-vga std \
-bios /usr/share/OVMF/OVMF_CODE.fd
all: $(BUILD)/boot.img
clean:
cargo clean
rm -rf build
update:
git submodule update --init --recursive --remote
cargo update
qemu: $(BUILD)/boot.img
$(QEMU) $(QEMU_FLAGS) $<
$(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] $@
$(BUILD)/boot.efi: Cargo.lock Cargo.toml src/* src/*/*
mkdir -p $(BUILD)
cargo rustc \
--target $(TARGET) \
--release \
-- \
-C soft-float \
--emit link=$@