Removing executable bit from efi files.
[syslinux-debian/hramrach.git] / mk / efi.mk
blob02817953f297f659cd59e6734106996ebd2f5c0c
1 include $(MAKEDIR)/syslinux.mk
3 com32 = $(topdir)/com32
4 core = $(topdir)/core
6 # Support IA32 and x86_64 platforms with one build
7 # Set up architecture specifics; for cross compilation, set ARCH as apt
8 # gnuefi sets up architecture specifics in ia32 or x86_64 sub directories
9 # set up the LIBDIR and EFIINC for building for the appropriate architecture
10 # For now, the following assumptions are made:
11 # 1. gnu-efi lib for IA32 is installed in /usr/local/lib
12 # and the include files in /usr/local/include/efi.
13 # 2. gnu-efi lib for x86_64 is installed in /usr/lib
14 # and the include files in /usr/include/efi.
15 ifeq ($(ARCH),i386)
16 SARCHOPT = -march=i386
17 CARCHOPT = -m32 -march=i386
18 EFI_SUBARCH = ia32
19 endif
20 ifeq ($(ARCH),x86_64)
21 SARCHOPT = -march=x86-64
22 CARCHOPT = -m64 -march=x86-64
23 EFI_SUBARCH = $(ARCH)
24 endif
26 EFIINC = $(shell $(topdir)/efi//find-gnu-efi.sh include $(EFI_SUBARCH))
27 $(if $(EFIINC),, \
28 $(error Missing $(EFI_SUBARCH) gnu-efi header files))
30 LIBDIR = $(shell $(topdir)/efi/find-gnu-efi.sh lib $(EFI_SUBARCH))
31 $(if $(LIBDIR),, \
32 $(error Missing $(EFI_SUBARCH) gnu-efi libraries))
34 #LIBDIR=/usr/lib
35 FORMAT=efi-app-$(EFI_SUBARCH)
37 CFLAGS = -I$(EFIINC) -I$(EFIINC)/$(EFI_SUBARCH) \
38 -DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \
39 -Wall -I$(com32)/include -I$(com32)/include/sys \
40 -I$(core)/include -I$(core)/ $(CARCHOPT) \
41 -I$(com32)/lib/ -I$(com32)/libutil/include -std=gnu99 \
42 -DELF_DEBUG -DSYSLINUX_EFI \
43 $(GCCWARN) -D__COM32__ -mno-red-zone
45 # gnuefi sometimes installs these under a gnuefi/ directory, and sometimes not
46 CRT0 := $(shell find $(LIBDIR) -name crt0-efi-$(EFI_SUBARCH).o 2>/dev/null | tail -n1)
47 LDSCRIPT := $(shell find $(LIBDIR) -name elf_$(EFI_SUBARCH)_efi.lds 2>/dev/null | tail -n1)
49 LDFLAGS = -T $(SRC)/$(ARCH)/syslinux.ld -Bsymbolic -pie -nostdlib -znocombreloc \
50 -L$(LIBDIR) --hash-style=gnu -m elf_$(ARCH) $(CRT0) -E
52 SFLAGS = $(GCCOPT) $(GCCWARN) $(SARCHOPT) \
53 -fomit-frame-pointer -D__COM32__ \
54 -nostdinc -iwithprefix include \
55 -I$(com32)/libutil/include -I$(com32)/include -I$(com32)/include/sys $(GPLINCLUDE)
57 .PRECIOUS: %.o
58 %.o: %.S
59 $(CC) $(SFLAGS) -c -o $@ $<
61 .PRECIOUS: %.o
62 %.o: %.c
63 $(CC) $(CFLAGS) -c -o $@ $<
65 #%.efi: %.so
66 # $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
67 # -j .rela -j .reloc --target=$(FORMAT) $*.so $@