Changes to Makefiles to support cross-compiling ARM64 binaries on
authorsrs5694 <srs5694@users.sourceforge.net>
Tue, 1 Dec 2015 00:27:21 +0000 (19:27 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Tue, 1 Dec 2015 00:27:21 +0000 (19:27 -0500)
x86-64 hardware.

Make.tiano
Makefile
debian/rules
filesystems/Make.tiano
gptsync/Make.tiano
gptsync/gptsync.c
gptsync/gptsync.h
mkcdimage
mkdistrib
refind/main.c

index 17b6984..84fba95 100644 (file)
@@ -42,7 +42,7 @@ ifeq ($(ARCH),aarch64)
   LD_CODE = aarch64elf
 endif
 
-EDK2BASE = /usr/local/UDK2014/MyWorkSpace
+#EDK2BASE = /usr/local/UDK2014/MyWorkSpace
 #EDK2BASE = /usr/local/EDK2/tianocore-edk2
 #ENTRYPOINT=_ModuleEntryPoint
 ENTRYPOINT=efi_main
@@ -66,16 +66,6 @@ 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
 
-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
 
 LDFLAGS         = -nostdlib -n -q --gc-sections --script=$(EDK2BASE)/BaseTools/Scripts/gcc4.4-ld-script \
index 550cb43..2292c51 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,8 +5,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-CC=gcc
-CXX=g++
 CXXFLAGS=-O2 -fpic -D_REENTRANT -D_GNU_SOURCE -Wall -g
 NAMES=refind
 SRCS=$(NAMES:=.c)
@@ -19,6 +17,25 @@ MOK_DIR=mok
 GPTSYNC_DIR=gptsync
 EFILIB_DIR=EfiLib
 
+export EDK2BASE        = /usr/local/UDK2014/MyWorkSpace
+export GENFW           = $(EDK2BASE)/BaseTools/Source/C/bin/GenFw
+export prefix          = /usr/bin/
+ifeq ($(ARCH),aarch64)
+  export CC            = $(prefix)aarch64-linux-gnu-gcc
+  export AS            = $(prefix)aarch64-linux-gnu-as
+  export LD            = $(prefix)aarch64-linux-gnu-ld
+  export AR            = $(prefix)aarch64-linux-gnu-ar
+  export RANLIB        = $(prefix)aarch64-linux-gnu-ranlib
+  export OBJCOPY       = $(prefix)aarch64-linux-gnu-objcopy
+else
+  export CC            = $(prefix)gcc
+  export AS            = $(prefix)as
+  export LD            = $(prefix)ld
+  export AR            = $(prefix)ar
+  export RANLIB        = $(prefix)ranlib
+  export OBJCOPY       = $(prefix)objcopy
+endif
+
 # Build rEFInd, including libeg
 all:   tiano
 
@@ -41,9 +58,17 @@ tiano:
        +make AR_TARGET=libeg -C $(LIBEG_DIR) -f Make.tiano
        +make AR_TARGET=mok -C $(MOK_DIR) -f Make.tiano
        +make BUILDME=refind DLL_TARGET=refind -C $(LOADER_DIR) -f Make.tiano
+ifneq ($(ARCH),aarch64)
        +make -C $(GPTSYNC_DIR) -f Make.tiano
+endif
 #      +make -C $(FS_DIR)
 
+gptsync:
+       +make -C $(GPTSYNC_DIR) -f Make.tiano
+
+gptsync_gnuefi:
+       +make -C $(GPTSYNC_DIR) gnuefi
+
 clean:
        make -C $(LIBEG_DIR) clean
        make -C $(MOK_DIR) clean
index 6f9c7f2..e18c5c3 100755 (executable)
@@ -8,11 +8,15 @@ ifeq (amd64, $(DEB_HOST_ARCH_CPU))
 else
 ifeq (i386, $(DEB_HOST_ARCH_CPU))
        EFI_ARCH := ia32
+else
+ifeq (arm64, $(DEB_HOST_ARCH_CPU))
+       EFI_ARCH := aa64
 else
        $(warning EFI architecture for $(DEB_HOST_ARCH_CPU) is unknown)
        EFI_ARCH := $(DEB_HOST_ARCH_CPU)
 endif
 endif
+endif
 
 %:
        dh $@
index ed838a3..b435c9d 100644 (file)
@@ -81,14 +81,14 @@ 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
index e047136..49e7787 100644 (file)
@@ -37,7 +37,7 @@ ifeq ($(ARCH),aarch64)
   LD_CODE = aarch64elf
 endif
 
-EDK2BASE = /usr/local/UDK2014/MyWorkSpace
+export EDK2BASE = /usr/local/UDK2014/MyWorkSpace
 #EDK2BASE = /usr/local/edk2
 
 # Below file defines TARGET (RELEASE or DEBUG) and TOOL_CHAIN_TAG (GCC44, GCC45, or GCC46)
@@ -83,14 +83,14 @@ DEBUGFLAGS      = -Wall -Wno-missing-braces -Wno-array-bounds -ffunction-section
 CFLAGS          = $(OPTIMFLAGS) -g -fshort-wchar -fno-stack-protector $(DEBUGFLAGS) -c -DHOST_EFI_EDK2 -D__MAKEWITH_TIANO
 #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
index 963e61c..2696e66 100644 (file)
@@ -38,6 +38,7 @@
 #include "gptsync.h"
 
 #include "syslinux_mbr.h"
+#define memcpy(a, b, c) CopyMem(a, b, c)
 
 //
 // MBR functions
index 5aeb195..1171472 100644 (file)
@@ -107,7 +107,7 @@ void Print(wchar_t *format, ...);
 
 // FUTURE: use STR(),  #define Print printf
 
-#define copy_guid(destguid, srcguid) (memcpy(destguid, srcguid, 16))
+#define copy_guid(destguid, srcguid) (CopyMem(destguid, srcguid, 16))
 #define guids_are_equal(guid1, guid2) (memcmp(guid1, guid2, 16) == 0)
 
 #define EFI_UNSUPPORTED 1
index 8e5649b..a794812 100755 (executable)
--- a/mkcdimage
+++ b/mkcdimage
@@ -35,6 +35,7 @@ cp $StartDir/shell*.efi ./
 # EFI-boot CD...
 ln ../../refind/refind_ia32.efi ./bootia32.efi
 ln ../../refind/refind_x64.efi ./bootx64.efi
+ln ../../refind/refind_aa64.efi ./bootaa64.efi
 cp ../../refind/refind.conf-sample ./refind.conf
 sed -i '/#showtools/a showtools shell,memtest,gdisk,apple_recovery,csr_rotate,windows_recovery,mok_tool,about,shutdown,reboot,firmware' refind.conf
 sed -i '/#csr_values/a csr_values 10,77' refind.conf
@@ -49,6 +50,10 @@ cd ..
 mkdir drivers_ia32
 cd drivers_ia32
 ln ../../../refind/drivers_ia32/* ./
+cd ..
+mkdir drivers_aa64
+cd drivers_aa64
+ln ../../../refind/drivers_aa64/* ./
 cd ../../..
 
 # Get the size of the binaries to go in the El Torito image in kB
index 18b3395..78fbe95 100755 (executable)
--- a/mkdistrib
+++ b/mkdistrib
@@ -57,7 +57,7 @@ mkdir -p ../snapshots/$1/refind-$1/icons/licenses ../snapshots/$1/refind-$1/icon
 cp --preserve=timestamps icons/*png icons/README ../snapshots/$1/refind-$1/icons/
 cp --preserve=timestamps -r icons/licenses/* ../snapshots/$1/refind-$1/icons/licenses/
 cp --preserve=timestamps -r icons/svg/* ../snapshots/$1/refind-$1/icons/svg/
-cp -a debian docs images keys fonts banners include EfiLib libeg mok net refind filesystems gptsync refind.spec refind-install mkrlconf mvrefind mountesp CREDITS.txt NEWS.txt BUILDING.txt COPYING.txt LICENSE.txt README.txt refind.inf Make.tiano Make.common Makefile refind.conf-sample ../snapshots/$1/refind-$1
+cp -a debian docs images keys fonts banners include EfiLib libeg mok net refind filesystems gptsync refind.spec refind-install mkrlconf mvrefind mountesp CREDITS.txt NEWS.txt BUILDING.txt COPYING.txt LICENSE.txt README.txt refind.inf Make.tiano Make.common Make.aarch64 Makefile refind.conf-sample ../snapshots/$1/refind-$1
 
 # Go there and prepare a souce code tarball....
 cd ../snapshots/$1/
@@ -68,8 +68,21 @@ gzip -9 refind-src-$1.tar
 # Remove SVG files, since they aren't needed for binary packages....
 rm -rf refind-$1/icons/svg
 
-# Build the IA32 binaries
+# Build the ARM64 binaries
 cd refind-$1
+ARCH=aarch64 make -j1
+ARCH=aarch64 make fs
+mkdir -p refind-bin-$1/refind/drivers_aa64
+cp --preserve=timestamps drivers_aa64/*_aa64.efi refind-bin-$1/refind/drivers_aa64/
+cp --preserve=timestamps filesystems/LICENSE*txt refind-bin-$1/refind/drivers_aa64/
+cp refind/refind_aa64.efi refind-bin-$1/refind/refind_aa64.efi
+cp refind/refind_aa64.efi $StartDir/
+mkdir -p refind-bin-$1/refind/tools_aa64
+# Don't copy gptsync_aa64.efi because it won't build in cross-compile environment
+# and because it's likely to be useless on ARM64.
+
+# Build the IA32 binaries
+make clean
 ARCH=ia32 make -j1
 ARCH=ia32 make fs
 mkdir -p refind-bin-$1/refind/drivers_ia32
@@ -133,7 +146,7 @@ mv ~/rpmbuild/RPMS/*/refind-$1* ./
 mv ~/rpmbuild/SRPMS/refind-$1* ./
 sudo alien --to-deb -k -c refind-$1*x86_64.rpm
 sudo chown rodsmith: refind*deb
-rm ~/rpmbuild/SOURCES/refind-src-$1.tar.gz
+rm ~/rpmbuild/SOURCES/refind-src-*
 
 # Clean up
 if [[ $SignIt == 1 ]] ; then
index c215962..e96f35b 100644 (file)
@@ -134,8 +134,8 @@ EFI_GUID gFreedesktopRootGuid = { 0xb921b045, 0x1df0, 0x41c3, { 0xaf, 0x44, 0x4c
 #define DRIVER_DIRS             L"drivers"
 #define FALLBACK_FULLNAME       L"EFI\\BOOT\\boot.efi" /* Not really correct */
 #define FALLBACK_BASENAME       L"boot.efi"            /* Not really correct */
-// Below is GUID for ARM64
-EFI_GUID gFreedesktopRootGuid = { 0xb921b045, 0x1df0, 0x41c3, { 0xaf, 0x44, 0x4c, 0x6f, 0x28, 0x0d, 0x3f, 0xae }};
+// Below is GUID for ARM32
+EFI_GUID gFreedesktopRootGuid = { 0x69dad710, 0x2ce4, 0x4e3c, { 0xb1, 0x6c, 0x21, 0xa1, 0xd4, 0x9a, 0xbe, 0xd3 }};
 #endif
 #define FAT_ARCH                0x0ef1fab9 /* ID for Apple "fat" binary */
 
@@ -204,7 +204,7 @@ static VOID AboutrEFInd(VOID)
 
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.10.0.5");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.10.0.6");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012-2015 Roderick W. Smith");