0
|
1 ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
|
|
2 EFI_INCLUDE = /usr/include/efi
|
|
3 EFI_INCLUDES = -I$(EFI_INCLUDE) -I$(EFI_INCLUDE)/$(ARCH) -I$(EFI_INCLUDE)/protocol
|
|
4 EFI_PATH = /usr/lib64/gnuefi
|
|
5 EFI_LIB_PATH = /usr/lib64
|
|
6 LIB_GCC = $(shell $(CC) -print-libgcc-file-name)
|
|
7 EFI_LIBS = -lefi -lgnuefi $(LIB_GCC)
|
|
8 EFI_CRT_OBJS = $(EFI_PATH)/crt0-efi-$(ARCH).o
|
|
9 EFI_LDS = $(EFI_PATH)/elf_$(ARCH)_efi.lds
|
|
10 CFLAGS = -O2 -g -mno-red-zone -fno-stack-protector -fno-strict-aliasing -fpic -fshort-wchar -fno-merge-constants -Wall -Werror $(EFI_INCLUDES)
|
|
11
|
|
12 ifeq ($(ARCH),x86_64)
|
|
13 CFLAGS += -DEFI_FUNCTION_WRAPPER
|
|
14 endif
|
|
15
|
|
16 LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -L$(EFI_LIB_PATH) $(EFI_CRT_OBJS)
|
|
17 TARGET = bootx64.efi
|
|
18 OBJS = bootx64.o
|
|
19
|
|
20 all: $(TARGET)
|
|
21
|
|
22 bootx64.efi: $(OBJS)
|
|
23
|
2
|
24 exec:
|
|
25 qemu-kvm -s -L ovmf -bios ovmf/OVMF.fd -hdb disk/disk.qcow2
|
|
26
|
0
|
27 %.efi: %.o
|
|
28 $(LD) $(LDFLAGS) $^ -o $@ $(EFI_LIBS)
|
|
29 objcopy -j .text -j .sdata -j .data \
|
|
30 -j .dynamic -j .dynsym -j .rel \
|
|
31 -j .rela -j .reloc \
|
|
32 --target=efi-app-$(ARCH) $@
|
|
33 strip $@
|
2
|
34 modprobe nbd
|
3
|
35 qemu-nbd -c /dev/nbd0 disk/disk.qcow2
|
2
|
36 mount /dev/nbd0 /mnt/nbd
|
|
37 cp bootx64.efi /mnt/nbd/EFI/BOOT/
|
|
38 umount /mnt/nbd
|
|
39 qemu-nbd -d /dev/nbd0
|
|
40 rmmod nbd
|
0
|
41
|
|
42 clean:
|
|
43 rm -f $(TARGET) $(OBJS)
|