]> code.delx.au - refind/blobdiff - filesystems/Make.tiano
Changes to Makefiles to support cross-compiling ARM64 binaries on
[refind] / filesystems / Make.tiano
index f709b3e1d7757a14f696466907e92265efe6aa54..b435c9df56ec6adfc79f41a400893e6eff1f54e2 100644 (file)
@@ -3,6 +3,11 @@
 # Build control file for rEFInd's EFI filesystem drivers
 #
 
+# This program is licensed under the terms of the GNU GPL, version 3,
+# or (at your option) any later version.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
 HOSTARCH        = $(shell uname -m | sed s,i[3456789]86,ia32,)
 ARCH            ?= $(HOSTARCH)
 
@@ -14,7 +19,7 @@ ifeq ($(ARCH),ia64)
 endif
 
 ifeq ($(ARCH),ia32)
-  ARCH_C_FLAGS = -m32 -malign-double
+  ARCH_C_FLAGS = -m32 -malign-double -g
   ARCHDIR = Ia32
   UC_ARCH = IA32
   FILENAME_CODE = ia32
@@ -22,14 +27,22 @@ ifeq ($(ARCH),ia32)
 endif
 
 ifeq ($(ARCH),x86_64)
-  ARCH_C_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -mcmodel=large -m64
+  ARCH_C_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -mcmodel=large -m64 -mno-red-zone
   ARCHDIR = X64
   UC_ARCH = X64
   FILENAME_CODE = x64
   LD_CODE = elf_x86_64
 endif
 
-EDK2BASE = /usr/local/UDK2010/MyWorkSpace
+ifeq ($(ARCH),aarch64)
+  ARCH_C_FLAGS = -DEFIAARCH64 -mcmodel=large
+  ARCHDIR = AArch64
+  UC_ARCH = AARCH64
+  FILENAME_CODE = aa64
+  LD_CODE = aarch64elf
+endif
+
+EDK2BASE = /usr/local/UDK2014/MyWorkSpace
 #EDK2BASE = /usr/local/edk2
 
 # Below file defines TARGET (RELEASE or DEBUG) and TOOL_CHAIN_TAG (GCC44, GCC45, or GCC46)
@@ -49,6 +62,10 @@ ALL_EFILIBS     = $(EFILIB)/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevel
                  $(EFILIB)/UefiLib/UefiLib/OUTPUT/UefiLib.lib \
                  $(EFILIB)/UefiDriverEntryPoint/UefiDriverEntryPoint/OUTPUT/UefiDriverEntryPoint.lib
 
+ifeq ($(ARCH),aarch64)
+  ALL_EFILIBS +=  $(EFILIB)/BaseStackCheckLib/BaseStackCheckLib/OUTPUT/BaseStackCheckLib.lib
+endif
+
 INCLUDE_DIRS    = -I $(EDK2BASE)/MdePkg \
                   -I $(EDK2BASE)/MdePkg/Include \
                   -I $(EDK2BASE)/MdePkg/Include/$(ARCHDIR) \
@@ -56,22 +73,22 @@ INCLUDE_DIRS    = -I $(EDK2BASE)/MdePkg \
                  -I $(EDK2BASE)/EdkCompatibilityPkg/Foundation/Library/Dxe/Include
 
 FSW_NAMES       = fsw_efi fsw_core fsw_efi_lib fsw_lib AutoGen
-OBJS            = $(FSW_NAMES:=.o)
+OBJS            = $(FSW_NAMES:=.obj)
 #DRIVERNAME      = ext2
 BUILDME          = $(DRIVERNAME)_$(FILENAME_CODE).efi
 
-OPTIMFLAGS      = -fno-strict-aliasing -mno-red-zone -Wno-address -Os
+OPTIMFLAGS      = -fno-strict-aliasing -Wno-address -Os
 DEBUGFLAGS      = -Wall -Wno-missing-braces -Wno-array-bounds -ffunction-sections -fdata-sections
 CFLAGS          = $(OPTIMFLAGS) -g -fshort-wchar -fno-stack-protector $(DEBUGFLAGS) -c -include AutoGen.h -DHOST_EFI_EDK2
 
-prefix          = /usr/bin/
-CC              = $(prefix)gcc
-AS              = $(prefix)as
-LD              = $(prefix)ld
-AR              = $(prefix)ar
-RANLIB          = $(prefix)ranlib
-OBJCOPY         = $(prefix)objcopy
-GENFW           = $(EDK2BASE)/BaseTools/Source/C/bin/GenFw
+prefix          ?= /usr/bin/
+CC              ?= $(prefix)gcc
+AS              ?= $(prefix)as
+LD              ?= $(prefix)ld
+AR              ?= $(prefix)ar
+RANLIB          ?= $(prefix)ranlib
+OBJCOPY         ?= $(prefix)objcopy
+GENFW           ?= $(EDK2BASE)/BaseTools/Source/C/bin/GenFw
 
 
 LDSCRIPT = $(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script
@@ -79,7 +96,7 @@ LDSCRIPT = $(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script
 LDFLAGS         = -nostdlib -n -q --gc-sections --script=$(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script \
                   --entry _ModuleEntryPoint -u _ModuleEntryPoint -m $(LD_CODE)
 
-%.o: %.c
+%.obj: %.c
        $(CC) $(ARCH_C_FLAGS) $(CFLAGS) $(INCLUDE_DIRS) -DFSTYPE=$(DRIVERNAME) -DNO_BUILTIN_VA_FUNCS -c $< -o $@
 
 ifneq (,$(filter %.efi,$(BUILDME)))
@@ -88,11 +105,11 @@ DLL_TARGET = $(subst .efi,.dll,$(BUILDME))
 
 all: $(BUILDME)
 
-$(DLL_TARGET): $(OBJS) fsw_$(DRIVERNAME).o
-       $(LD) -o $(DRIVERNAME)_$(FILENAME_CODE).dll $(LDFLAGS) --start-group $(ALL_EFILIBS) $(OBJS) fsw_$(DRIVERNAME).o --end-group
+$(DLL_TARGET): $(OBJS) fsw_$(DRIVERNAME).obj
+       $(LD) -o $(DRIVERNAME)_$(FILENAME_CODE).dll $(LDFLAGS) --start-group $(ALL_EFILIBS) $(OBJS) fsw_$(DRIVERNAME).obj --end-group
 
 $(BUILDME): $(DLL_TARGET)
-       $(OBJCOPY) --strip-unneeded $(DLL_TARGET)
+       $(OBJCOPY) --strip-unneeded -R .eh_frame $(DLL_TARGET)
        $(GENFW) -e UEFI_DRIVER -o $(BUILDME) $(DLL_TARGET)
 #      $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
 #                 -j .rela -j .reloc --rename-section .data=.hii --target=efi-bsdrv-$(ARCH) $< $@