-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
35 lines (27 loc) · 919 Bytes
/
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
ARCH := x86_64
OBJS := app.o
TARGET := BOOTx64.EFI
# Required packages: gnu-efi-devel, gnu-efi
EFIINC := /usr/include/efi
EFILIB := /usr/lib
EFIINCS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
EFI_CRT_OBJS = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS = $(EFILIB)/elf_$(ARCH)_efi.lds
CFLAGS = -g -ffreestanding -fno-stack-protector -fno-stack-check \
-fpic -fshort-wchar -mno-red-zone -Wall $(EFIINCS) \
-DEFI_FUNCTION_WRAPPER -DGNU_EFI_USE_MS_ABI -O2
LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared \
-Bsymbolic -L $(EFILIB) $(EFI_CRT_OBJS)
CC = gcc
.PHONY: all clean
all: $(TARGET)
BOOTx64.so: $(OBJS)
ld $(OBJS) $(LDFLAGS) -o $@ -lefi -lgnuefi
%.EFI: %.so
objcopy -j .text -j .sdata -j .data -j .dynamic \
-j .dynsym -j .dynstr -j .rel -j .rela -j .reloc -j .rodata \
--target=efi-app-$(ARCH) $^ $@
clean:
-rm -f *.o
-rm -f *.so
-rm -f *.EFI