summaryrefslogtreecommitdiffstats
path: root/GNU_efi_HelloWorld/Makefile
blob: 4f00d4aa1a62a8019050f966e3517b154f3b712b (plain) (blame)
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
ARCH		= $(shell uname -m | sed s,i[3456789]86,ia32,)

OBJS		= main.o
TARGET		= hello.efi

EFIINC		= /usr/include/efi
EFFINCS		= -I$(EFFINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
LIB		= /usr/lib64
EFILIB		= /usr/lib64/gnuefi
EFI_CRT_OBJS	= $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS		= $(EFILIB)/elf_$(ARCH)_efi.lds

CFLAGS		= $(EFFINCS) -fno-stack-protector -fpic \
			-fshort-wchar -mno-red-zone -Wall

ifeq ($(ARCH),x86_64)
	CFLAGS += -DEFI_FUNCTION_WRAPPER
endif

LDFLAGS		= -nostdlib -znocombreloc -T $(EFI_LDS) -shared \
			-Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS)

all: $(TARGET)

hello.so: $(OBJS)
	ld $(LDFLAGS) $(OBJS) -o $@ -lefi -lgnuefi

%.efi: %.so
	objcopy -j .text -j .sdata -j .data -j .dynamic \
	-j .dynsym -j .rel -j .rela -j .reloc \
	--target=efi-app-$(ARCH) $^ $@