-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
70 lines (53 loc) · 1.58 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
# Makefile for efi-hello-world-bootloader
ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
OBJS = main.o
TARGET = hello.efi
EFIINC = /usr/include/efi
EFILIB = /usr/lib
EFI_CRT_OBJS = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS = $(EFILIB)/elf_$(ARCH)_efi.lds
CFLAGS = -nostdlib \
-fno-stack-protector \
-fno-strict-aliasing \
-fno-builtin \
-fpic \
-fshort-wchar \
-mno-red-zone \
-Wall
ifeq ($(ARCH),x86_64)
CFLAGS += -DEFI_FUNCTION_WRAPPER
endif
CFLAGS += -I$(EFIINC) \
-I$(EFIINC)/$(ARCH) \
-I$(EFIINC)/protocol
LDFLAGS = -nostdlib \
-znocombreloc \
-shared \
-no-undefined \
-Bsymbolic
LDFLAGS += -T $(EFI_LDS) \
-L$(EFILIB) \
$(EFI_CRT_OBJS)
LIBS = -lefi \
-lgnuefi
OBJCOPYFLAGS = -j .text \
-j .sdata \
-j .data \
-j .dynamic \
-j .dynsym \
-j .rel \
-j .rela \
-j .reloc \
--target=efi-app-$(ARCH)
all: $(TARGET)
install: $(TARGET)
cp $(TARGET) /boot/efi/$(TARGET)
hello.so: $(OBJS)
ld $(LDFLAGS) $(OBJS) -o $@ $(LIBS)
%.efi: %.so
objcopy $(OBJCOPYFLAGS) $^ $@
.PHONY: clean tags
tags:
ctags -R .
clean:
rm -f $(OBJS) $(TARGET) hello.so tags