forked from system76/firmware-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (59 loc) · 1.98 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
TARGET?=x86_64-unknown-uefi-drv
export LD=ld
export RUST_TARGET_PATH=$(CURDIR)/targets
BUILD=build/$(TARGET)
all: $(BUILD)/boot.efi
clean:
cargo clean
rm -rf build
update:
git submodule update --init --recursive --remote
cargo update
$(BUILD)/OVMF_VARS.fd: /usr/share/OVMF/OVMF_VARS.fd
cp $< $@
qemu: $(BUILD)/boot.img $(BUILD)/OVMF_VARS.fd
kvm -M q35 -m 1024 -net none -vga std $< \
-drive if=pflash,format=raw,readonly,file=/usr/share/OVMF/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=$(BUILD)/OVMF_VARS.fd \
-chardev stdio,id=debug -device isa-debugcon,iobase=0x402,chardev=debug
$(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
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] $< ::driver.efi
mcopy -i [email protected] res/startup.nsh ::startup.nsh
mv [email protected] $@
$(BUILD)/boot.efi: Cargo.lock Cargo.toml res/* src/* src/*/*
mkdir -p $(BUILD)
cargo rustc \
-Z build-std=core,alloc \
--target $(TARGET) \
--release \
-- \
-C soft-float \
--emit link=$@
BINUTILS=2.28.1
prefix/binutils-$(BINUTILS).tar.xz:
mkdir -p "`dirname $@`"
wget "https://ftp.gnu.org/gnu/binutils/binutils-$(BINUTILS).tar.xz" -O "[email protected]"
sha384sum -c binutils.sha384
mv "[email protected]" "$@"
prefix/binutils-$(BINUTILS): prefix/binutils-$(BINUTILS).tar.xz
mkdir -p "[email protected]"
tar --extract --verbose --file "$<" --directory "[email protected]" --strip-components=1
mv "[email protected]" "$@"
$(LD): prefix/binutils-$(BINUTILS)
rm -rf prefix/bin prefix/share "prefix/$(TARGET)"
mkdir -p prefix/build
cd prefix/build && \
../../$</configure --target="$(TARGET)" --disable-werror --prefix="$(PREFIX)" && \
make all-ld -j `nproc` && \
make install-ld -j `nproc`