summaryrefslogblamecommitdiffstats
path: root/GNU_efi_HelloWorld/Makefile
blob: 63deda26a1c9049e49c2e56ed88c338d7a1508e9 (plain) (tree)
1
2
3
4
5
6
7
8
9

                                                              
                         
                           
                             

                                  

                                                                      



                                                         
                                                         


                                                 





                                                                 
                                                         
 





                                                                       
                                               




                                                  




                                                                        
                                      

      



                     
ARCH		= $(shell uname -m | sed s,i[3456789]86,ia32,)

OBJS		= hello.o
TARGET		= hello.efi
TARGET_DEBUG	= hello.debug

EFIINC		= /usr/include/efi
EFFINCS		= -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
EFILIB		= /usr/lib
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
CFLAGS		+=	-ggdb3 -O0  -DEFI_DEBUG=1
# -DDEBUG


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

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

SECTIONS	= .text .sdata .data .dynamic .dynsym .rel .rela .reloc

DEBUG_SECTIONS	= .debug_info .debug_abbrev .debug_aranges \
		  .debug_line .debug_str

all: clear $(TARGET) $(TARGET_DEBUG)
	cp hello.efi ../test_code/hda-contents/

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

%.efi: %.so
	objcopy $(foreach sec,$(SECTIONS),-j $(sec)) \
	--target=efi-app-$(ARCH) $^ $@

%.debug: %.so
	objcopy $(foreach sec,$(SECTIONS) $(DEBUG_SECTIONS),-j $(sec)) \
	--target=efi-app-$(ARCH) $^ $@

clear:
	rm -f *.efi
	rm -f *.debug
	rm -f *.o
	rm -f *.so