• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include $(MAKEDIR)/syslinux.mk
2
3com32 = $(topdir)/com32
4core = $(topdir)/core
5
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
10GCCOPT := $(call gcc_ok,-fno-stack-protector,)
11EFIINC = $(objdir)/include/efi
12LIBDIR  = $(objdir)/lib
13
14ifeq ($(ARCH),i386)
15	ARCHOPT = -m32 -march=i386
16	EFI_SUBARCH = ia32
17endif
18ifeq ($(ARCH),x86_64)
19	ARCHOPT = -m64 -march=x86-64
20	EFI_SUBARCH = $(ARCH)
21endif
22
23#LIBDIR=/usr/lib
24FORMAT=efi-app-$(EFI_SUBARCH)
25
26CFLAGS = -I$(EFIINC) -I$(EFIINC)/$(EFI_SUBARCH) \
27		-DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \
28		-Wall -I$(com32)/include -I$(com32)/include/sys \
29		-I$(core)/include -I$(core)/ $(ARCHOPT) \
30		-I$(com32)/lib/ -I$(com32)/libutil/include -std=gnu99 \
31		-DELF_DEBUG -DSYSLINUX_EFI -I$(objdir) \
32		$(GCCWARN) -D__COM32__ -D__FIRMWARE_$(FIRMWARE)__ -mno-red-zone \
33		-DLDLINUX=\"$(LDLINUX)\" -fvisibility=hidden \
34		-Wno-unused-parameter $(GCCOPT)
35
36CRT0 := $(LIBDIR)/crt0-efi-$(EFI_SUBARCH).o
37LDSCRIPT := $(LIBDIR)/elf_$(EFI_SUBARCH)_efi.lds
38
39LDFLAGS = -T $(SRC)/$(ARCH)/syslinux.ld -Bsymbolic -pie -nostdlib -znocombreloc \
40		-L$(LIBDIR) --hash-style=gnu -m elf_$(ARCH) $(CRT0) -E
41
42SFLAGS     = $(GCCOPT) $(GCCWARN) $(ARCHOPT) \
43	     -fomit-frame-pointer -D__COM32__ -D__FIRMWARE_$(FIRMWARE)__ \
44	     -nostdinc -iwithprefix include \
45	     -I$(com32)/libutil/include -I$(com32)/include -I$(com32)/include/sys $(GPLINCLUDE)
46
47LIBEFI = $(objdir)/lib/libefi.a
48
49$(LIBEFI):
50	@echo Building gnu-efi for $(EFI_SUBARCH)
51	$(topdir)/efi/check-gnu-efi.sh $(EFI_SUBARCH) $(objdir)
52
53%.o: %.S	# Cancel old rule
54
55%.o: %.c
56
57.PRECIOUS: %.o
58%.o: %.S $(LIBEFI)
59	$(CC) $(SFLAGS) -c -o $@ $<
60
61.PRECIOUS: %.o
62%.o: %.c $(LIBEFI)
63	$(CC) $(CFLAGS) -c -o $@ $<
64
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 $@
68