]> code.delx.au - refind/blob - filesystems/Make.tiano
Changes to Makefiles to support cross-compiling ARM64 binaries on
[refind] / filesystems / Make.tiano
1 #
2 # filesystems/Make.common
3 # Build control file for rEFInd's EFI filesystem drivers
4 #
5
6 # This program is licensed under the terms of the GNU GPL, version 3,
7 # or (at your option) any later version.
8 # You should have received a copy of the GNU General Public License
9 # along with this program. If not, see <http://www.gnu.org/licenses/>.
10
11 HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
12 ARCH ?= $(HOSTARCH)
13
14 # Note: IA64 options are untested; taken from Debian's rEFIt package.
15 ifeq ($(ARCH),ia64)
16 # EFI specs allows only lower floating point partition to be used
17 ARCH_C_CFLAGS = -frename-registers -mfixed-range=f32-f127
18 # TODO: Add ARCHDIR and FILENAME_CODE as appropriate
19 endif
20
21 ifeq ($(ARCH),ia32)
22 ARCH_C_FLAGS = -m32 -malign-double -g
23 ARCHDIR = Ia32
24 UC_ARCH = IA32
25 FILENAME_CODE = ia32
26 LD_CODE = elf_i386
27 endif
28
29 ifeq ($(ARCH),x86_64)
30 ARCH_C_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -mcmodel=large -m64 -mno-red-zone
31 ARCHDIR = X64
32 UC_ARCH = X64
33 FILENAME_CODE = x64
34 LD_CODE = elf_x86_64
35 endif
36
37 ifeq ($(ARCH),aarch64)
38 ARCH_C_FLAGS = -DEFIAARCH64 -mcmodel=large
39 ARCHDIR = AArch64
40 UC_ARCH = AARCH64
41 FILENAME_CODE = aa64
42 LD_CODE = aarch64elf
43 endif
44
45 EDK2BASE = /usr/local/UDK2014/MyWorkSpace
46 #EDK2BASE = /usr/local/edk2
47
48 # Below file defines TARGET (RELEASE or DEBUG) and TOOL_CHAIN_TAG (GCC44, GCC45, or GCC46)
49 include $(EDK2BASE)/Conf/target.txt
50
51 EFILIB = $(EDK2BASE)/Build/Mde/$(TARGET)_$(TOOL_CHAIN_TAG)/$(UC_ARCH)/MdePkg/Library
52 ALL_EFILIBS = $(EFILIB)/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib/OUTPUT/BaseDebugPrintErrorLevelLib.lib \
53 $(EFILIB)/BasePrintLib/BasePrintLib/OUTPUT/BasePrintLib.lib \
54 $(EFILIB)/BasePcdLibNull/BasePcdLibNull/OUTPUT/BasePcdLibNull.lib \
55 $(EFILIB)/UefiDebugLibConOut/UefiDebugLibConOut/OUTPUT/UefiDebugLibConOut.lib \
56 $(EFILIB)/BaseLib/BaseLib/OUTPUT/BaseLib.lib \
57 $(EFILIB)/BaseMemoryLib/BaseMemoryLib/OUTPUT/BaseMemoryLib.lib \
58 $(EFILIB)/UefiBootServicesTableLib/UefiBootServicesTableLib/OUTPUT/UefiBootServicesTableLib.lib \
59 $(EFILIB)/UefiMemoryAllocationLib/UefiMemoryAllocationLib/OUTPUT/UefiMemoryAllocationLib.lib \
60 $(EFILIB)/UefiDevicePathLib/UefiDevicePathLib/OUTPUT/UefiDevicePathLib.lib \
61 $(EFILIB)/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib/OUTPUT/UefiRuntimeServicesTableLib.lib \
62 $(EFILIB)/UefiLib/UefiLib/OUTPUT/UefiLib.lib \
63 $(EFILIB)/UefiDriverEntryPoint/UefiDriverEntryPoint/OUTPUT/UefiDriverEntryPoint.lib
64
65 ifeq ($(ARCH),aarch64)
66 ALL_EFILIBS += $(EFILIB)/BaseStackCheckLib/BaseStackCheckLib/OUTPUT/BaseStackCheckLib.lib
67 endif
68
69 INCLUDE_DIRS = -I $(EDK2BASE)/MdePkg \
70 -I $(EDK2BASE)/MdePkg/Include \
71 -I $(EDK2BASE)/MdePkg/Include/$(ARCHDIR) \
72 -I $(EDK2BASE)/EdkCompatibilityPkg/Foundation/Framework/Include \
73 -I $(EDK2BASE)/EdkCompatibilityPkg/Foundation/Library/Dxe/Include
74
75 FSW_NAMES = fsw_efi fsw_core fsw_efi_lib fsw_lib AutoGen
76 OBJS = $(FSW_NAMES:=.obj)
77 #DRIVERNAME = ext2
78 BUILDME = $(DRIVERNAME)_$(FILENAME_CODE).efi
79
80 OPTIMFLAGS = -fno-strict-aliasing -Wno-address -Os
81 DEBUGFLAGS = -Wall -Wno-missing-braces -Wno-array-bounds -ffunction-sections -fdata-sections
82 CFLAGS = $(OPTIMFLAGS) -g -fshort-wchar -fno-stack-protector $(DEBUGFLAGS) -c -include AutoGen.h -DHOST_EFI_EDK2
83
84 prefix ?= /usr/bin/
85 CC ?= $(prefix)gcc
86 AS ?= $(prefix)as
87 LD ?= $(prefix)ld
88 AR ?= $(prefix)ar
89 RANLIB ?= $(prefix)ranlib
90 OBJCOPY ?= $(prefix)objcopy
91 GENFW ?= $(EDK2BASE)/BaseTools/Source/C/bin/GenFw
92
93
94 LDSCRIPT = $(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script
95
96 LDFLAGS = -nostdlib -n -q --gc-sections --script=$(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script \
97 --entry _ModuleEntryPoint -u _ModuleEntryPoint -m $(LD_CODE)
98
99 %.obj: %.c
100 $(CC) $(ARCH_C_FLAGS) $(CFLAGS) $(INCLUDE_DIRS) -DFSTYPE=$(DRIVERNAME) -DNO_BUILTIN_VA_FUNCS -c $< -o $@
101
102 ifneq (,$(filter %.efi,$(BUILDME)))
103
104 DLL_TARGET = $(subst .efi,.dll,$(BUILDME))
105
106 all: $(BUILDME)
107
108 $(DLL_TARGET): $(OBJS) fsw_$(DRIVERNAME).obj
109 $(LD) -o $(DRIVERNAME)_$(FILENAME_CODE).dll $(LDFLAGS) --start-group $(ALL_EFILIBS) $(OBJS) fsw_$(DRIVERNAME).obj --end-group
110
111 $(BUILDME): $(DLL_TARGET)
112 $(OBJCOPY) --strip-unneeded -R .eh_frame $(DLL_TARGET)
113 $(GENFW) -e UEFI_DRIVER -o $(BUILDME) $(DLL_TARGET)
114 # $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
115 # -j .rela -j .reloc --rename-section .data=.hii --target=efi-bsdrv-$(ARCH) $< $@
116 mkdir -p ../drivers_$(FILENAME_CODE)
117 cp $(BUILDME) ../drivers_$(FILENAME_CODE)
118
119 endif
120