Changes to Makefiles to support cross-compiling ARM64 binaries on
[refind] / gptsync / Make.tiano
1 #
2 # gptsync/Make.tiano
3 # Build control file for gptsync utility, built with TianoCore EDK2
4 #
5
6 HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
7 ARCH ?= $(HOSTARCH)
8
9 # Note: IA64 options are untested; taken from Debian's rEFIt package.
10 ifeq ($(ARCH),ia64)
11 # EFI specs allows only lower floating point partition to be used
12 ARCH_C_CFLAGS = -frename-registers -mfixed-range=f32-f127
13 # TODO: Add ARCHDIR and FILENAME_CODE as appropriate
14 endif
15
16 ifeq ($(ARCH),ia32)
17 ARCH_C_FLAGS = -m32 -malign-double -DEFI32
18 ARCHDIR = Ia32
19 UC_ARCH = IA32
20 FILENAME_CODE = ia32
21 LD_CODE = elf_i386
22 endif
23
24 ifeq ($(ARCH),x86_64)
25 ARCH_C_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -mcmodel=large -m64 -mno-red-zone -DEFIX64
26 ARCHDIR = X64
27 UC_ARCH = X64
28 FILENAME_CODE = x64
29 LD_CODE = elf_x86_64
30 endif
31
32 ifeq ($(ARCH),aarch64)
33 ARCH_C_FLAGS = -DEFIAARCH64 -mcmodel=large
34 ARCHDIR = AArch64
35 UC_ARCH = AARCH64
36 FILENAME_CODE = aa64
37 LD_CODE = aarch64elf
38 endif
39
40 export EDK2BASE = /usr/local/UDK2014/MyWorkSpace
41 #EDK2BASE = /usr/local/edk2
42
43 # Below file defines TARGET (RELEASE or DEBUG) and TOOL_CHAIN_TAG (GCC44, GCC45, or GCC46)
44 include $(EDK2BASE)/Conf/target.txt
45
46 EFILIB = $(EDK2BASE)/Build/Mde/$(TARGET)_$(TOOL_CHAIN_TAG)/$(UC_ARCH)/MdePkg/Library
47 ALL_EFILIBS = $(EFILIB)/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib/OUTPUT/BaseDebugPrintErrorLevelLib.lib \
48 $(EFILIB)/BasePrintLib/BasePrintLib/OUTPUT/BasePrintLib.lib \
49 $(EFILIB)/BasePcdLibNull/BasePcdLibNull/OUTPUT/BasePcdLibNull.lib \
50 $(EFILIB)/UefiDebugLibConOut/UefiDebugLibConOut/OUTPUT/UefiDebugLibConOut.lib \
51 $(EFILIB)/BaseLib/BaseLib/OUTPUT/BaseLib.lib \
52 $(EFILIB)/BaseMemoryLib/BaseMemoryLib/OUTPUT/BaseMemoryLib.lib \
53 $(EFILIB)/UefiBootServicesTableLib/UefiBootServicesTableLib/OUTPUT/UefiBootServicesTableLib.lib \
54 $(EFILIB)/UefiMemoryAllocationLib/UefiMemoryAllocationLib/OUTPUT/UefiMemoryAllocationLib.lib \
55 $(EFILIB)/UefiDevicePathLib/UefiDevicePathLib/OUTPUT/UefiDevicePathLib.lib \
56 $(EFILIB)/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib/OUTPUT/UefiRuntimeServicesTableLib.lib \
57 $(EFILIB)/UefiLib/UefiLib/OUTPUT/UefiLib.lib \
58 $(EFILIB)/UefiApplicationEntryPoint/UefiApplicationEntryPoint/OUTPUT/UefiApplicationEntryPoint.lib
59
60 ifeq ($(ARCH),aarch64)
61 ALL_EFILIBS += $(EFILIB)/BaseStackCheckLib/BaseStackCheckLib/OUTPUT/BaseStackCheckLib.lib
62 endif
63
64 INCLUDE_DIRS = -I $(EDK2BASE)/MdePkg \
65 -I $(EDK2BASE)/MdePkg/Include \
66 -I $(EDK2BASE)/MdePkg/Include/$(ARCHDIR) \
67 -I $(EDK2BASE)/EdkCompatibilityPkg/Foundation/Framework/Include \
68 -I $(EDK2BASE)/EdkCompatibilityPkg/Foundation/Library/Dxe/Include \
69 -I $(EDK2BASE)/MdeModulePkg/ \
70 -I $(EDK2BASE)/MdeModulePkg/Include \
71 -I $(EDK2BASE)/IntelFrameworkPkg/Include \
72 -I $(EDK2BASE)/MdePkg/Include/$(ARCHDIR) \
73 -I ../libeg \
74 -I ../include \
75 -I ..
76
77 GPTSYNC_NAMES = gptsync lib os_efi AutoGen ../EfiLib/BmLib
78 OBJS = $(GPTSYNC_NAMES:=.obj)
79 BUILDME = gptsync_$(FILENAME_CODE).efi
80
81 OPTIMFLAGS = -fno-strict-aliasing -Wno-address -Os
82 DEBUGFLAGS = -Wall -Wno-missing-braces -Wno-array-bounds -ffunction-sections -fdata-sections
83 CFLAGS = $(OPTIMFLAGS) -g -fshort-wchar -fno-stack-protector $(DEBUGFLAGS) -c -DHOST_EFI_EDK2 -D__MAKEWITH_TIANO
84 #CFLAGS = $(OPTIMFLAGS) -g -fshort-wchar -fno-stack-protector $(DEBUGFLAGS) -c -include AutoGen.h -DHOST_EFI_EDK2
85
86 prefix ?= /usr/bin/
87 CC ?= $(prefix)gcc
88 AS ?= $(prefix)as
89 LD ?= $(prefix)ld
90 AR ?= $(prefix)ar
91 RANLIB ?= $(prefix)ranlib
92 OBJCOPY ?= $(prefix)objcopy
93 GENFW ?= $(EDK2BASE)/BaseTools/Source/C/bin/GenFw
94
95
96 LDSCRIPT = $(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script
97
98 LDFLAGS = -nostdlib -n -q --gc-sections --script=$(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script \
99 --entry efi_main -u efi_main -m $(LD_CODE)
100
101 %.obj: %.c
102 $(CC) $(ARCH_C_FLAGS) $(CFLAGS) $(INCLUDE_DIRS) -DNO_BUILTIN_VA_FUNCS -c $< -o $@
103 +make -C ../EfiLib -f Make.tiano
104
105 ifneq (,$(filter %.efi,$(BUILDME)))
106
107 DLL_TARGET = $(subst .efi,.dll,$(BUILDME))
108
109 all: $(BUILDME)
110
111 $(DLL_TARGET): $(OBJS)
112 $(LD) -o gptsync_$(FILENAME_CODE).dll $(LDFLAGS) --start-group $(ALL_EFILIBS) $(OBJS) --end-group
113
114 $(BUILDME): $(DLL_TARGET)
115 $(OBJCOPY) --strip-unneeded -R .eh_frame $(DLL_TARGET)
116 $(GENFW) -e UEFI_APPLICATION -o $(BUILDME) $(DLL_TARGET)
117
118 endif
119