-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (50 loc) · 1.49 KB
/
Makefile
File metadata and controls
63 lines (50 loc) · 1.49 KB
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
ARCH = x86_64
LD=$(TOOLCHAIN_PATH)ld
NM=$(TOOLCHAIN_PATH)nm
OBJCOPY=$(TOOLCHAIN_PATH)objcopy
CC?=$(TOOLCHAIN_PATH)gcc
CFLAGS = -Ixefi -Iinclude -flto -W -Wall -Wextra -O3 -fno-stack-protector -fno-math-errno -fno-trapping-math -fno-common -fshort-wchar -nostdlib -ffreestanding -std=c11 -m64
ifeq ($(ARCH),x86_64)
CFLAGS += -mno-red-zone
endif
EFI_SECTIONS = -j .text -j .data -j .reloc
ifeq ($(CC),clang)
CFLAGS += --target=$(ARCH)-windows-msvc
LDFLAGS += /subsystem:efi_application /entry:efi_main
else
CFLAGS += -fPIE
LDFLAGS += -Wl,-T xefi/efi-x86-64.lds -Wl,--gc-sections
endif
TARGET = bootloader.efi
OBJS = bootloader.o \
config.o \
netboot.o \
loadelf.o \
bootinfo.o \
framebuffer.o \
inet.o \
inet6.o \
netifc.o \
device_id.o \
tftp/tftp.o \
xefi/xefi.o \
xefi/guids.o \
xefi/printf.o \
xefi/console-printf.o \
xefi/ctype.o \
xefi/string.o \
xefi/strings.o \
xefi/stdlib.o \
xefi/loadfile.o
all: $(TARGET)
ifeq ($(CC),clang)
bootloader.efi: $(OBJS)
lld-link $(LDFLAGS) $^ /out:$@
if [ "`$(NM) $< | grep ' U '`" != "" ]; then echo "error: $<: undefined symbols"; $(NM) $< | grep ' U '; rm $<; exit 1; fi
else
bootloader.so: $(OBJS)
$(CC) $(LDFLAGS) $^ -o $@
%.efi: %.so
$(OBJCOPY) $(EFI_SECTIONS) --target=efi-app-$(ARCH) $^ $@
if [ "`$(NM) $< | grep ' U '`" != "" ]; then echo "error: $<: undefined symbols"; $(NM) $< | grep ' U '; rm $<; exit 1; fi
endif