From 1db02182e80d3af1e74329550e35abd829bf7e8f Mon Sep 17 00:00:00 2001 From: srs5694 Date: Thu, 8 Nov 2012 13:00:31 -0500 Subject: [PATCH] Improved TianoCore build procedure; can now build both x86-64 and x86 binaries on one computer. --- BUILDING.txt | 11 ++++++++--- Make.tiano | 8 ++++++-- filesystems/Make.tiano | 10 +++++++--- refind.inf | 2 +- refind/Make.tiano | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/BUILDING.txt b/BUILDING.txt index dba98a5..f41a666 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -156,9 +156,10 @@ installed the toolkit: drivers) must be typed in the shell you use for this step. 9) Edit Conf/target.txt and change the following: - - ACTIVE_PLATFORM = MdeModulePkg/MdeModulePkg.dsc + - ACTIVE_PLATFORM = MdePkg/MdePkg.dsc - TARGET = RELEASE (DEBUG might work, but I've not tested it). - - TARGET_ARCH = X64 (on x86-64; leave this as IA32 on x86) + - TARGET_ARCH = X64 (on x86-64; leave this as IA32 on x86). If you plan + to build both architectures, you can set this to "IA32 X64". - TOOL_CHAIN_TAG = GCC46 (or other value depending on your GCC version; type "gcc -v" to learn your GCC version number). Note that GCC 4.7 doesn't have its own entry, so use GCC46 for GCC 4.7. @@ -207,7 +208,11 @@ With your development system set up, you can compile rEFInd as follows: 4) Type "make gnuefi" to build with GNU-EFI, or either "make" alone or "make tiano" to build with TianoCore EDK2. With any luck, rEFInd will compile without error, leaving the "refind_ia32.efi" or "refind_x64.efi" - file, depending on your platform, in the "refind" subdirectory. + file, depending on your platform, in the "refind" subdirectory. If you + want to build IA32 binaries on an x86-64 (X64) system, type "ARCH=ia32 + make". This works only if you're using the TianoCore build kit, and only + if you set TARGET_ARCH to either "IA32" or "IA32 X64" in target.txt when + you set up the TianoCore. 5) The default build process does NOT build the filesystem drivers. If you want to build them, you must type "make fs" in the main rEFInd source diff --git a/Make.tiano b/Make.tiano index 4b4ee92..04a3eb7 100644 --- a/Make.tiano +++ b/Make.tiano @@ -4,7 +4,7 @@ # HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) -ARCH := $(HOSTARCH) +ARCH ?= $(HOSTARCH) # Note: IA64 options are untested; taken from Debian's rEFIt package. ifeq ($(ARCH),ia64) @@ -16,13 +16,17 @@ endif ifeq ($(ARCH),ia32) ARCH_C_FLAGS = -m32 -DEFI32 -malign-double ARCHDIR = Ia32 + UC_ARCH = IA32 FILENAME_CODE = ia32 + LD_CODE = elf_i386 endif ifeq ($(ARCH),x86_64) ARCH_C_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -DEFIX64 -mcmodel=large -m64 ARCHDIR = X64 + UC_ARCH = X64 FILENAME_CODE = x64 + LD_CODE = elf_x86_64 endif EDK2BASE = /usr/local/UDK2010/MyWorkSpace @@ -56,7 +60,7 @@ 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 \ - --entry efi_main -u efi_main + --entry efi_main -u efi_main -m $(LD_CODE) %.obj: %.c $(CC) $(ARCH_C_FLAGS) $(CFLAGS) $(INCLUDE_DIRS) -DNO_BUILTIN_VA_FUNCS -D__MAKEWITH_TIANO -c $< -o $@ diff --git a/filesystems/Make.tiano b/filesystems/Make.tiano index 18c85b9..960a651 100644 --- a/filesystems/Make.tiano +++ b/filesystems/Make.tiano @@ -4,7 +4,7 @@ # HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) -ARCH := $(HOSTARCH) +ARCH ?= $(HOSTARCH) # Note: IA64 options are untested; taken from Debian's rEFIt package. ifeq ($(ARCH),ia64) @@ -16,13 +16,17 @@ endif ifeq ($(ARCH),ia32) ARCH_C_FLAGS = -m32 -malign-double ARCHDIR = Ia32 + UC_ARCH = IA32 FILENAME_CODE = ia32 + LD_CODE = elf_i386 endif ifeq ($(ARCH),x86_64) ARCH_C_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" -mcmodel=large -m64 ARCHDIR = X64 + UC_ARCH = X64 FILENAME_CODE = x64 + LD_CODE = elf_x86_64 endif EDK2BASE = /usr/local/UDK2010/MyWorkSpace @@ -31,7 +35,7 @@ EDK2BASE = /usr/local/UDK2010/MyWorkSpace # Below file defines TARGET (RELEASE or DEBUG), TARGET_ARCH (X64 or IA32), and TOOL_CHAIN_TAG (GCC44, GCC45, or GCC46) include $(EDK2BASE)/Conf/target.txt -EFILIB = $(EDK2BASE)/Build/MdeModule/$(TARGET)_$(TOOL_CHAIN_TAG)/$(TARGET_ARCH)/MdePkg/Library +EFILIB = $(EDK2BASE)/Build/Mde/$(TARGET)_$(TOOL_CHAIN_TAG)/$(UC_ARCH)/MdePkg/Library ALL_EFILIBS = $(EFILIB)/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib/OUTPUT/BaseDebugPrintErrorLevelLib.lib \ $(EFILIB)/BasePrintLib/BasePrintLib/OUTPUT/BasePrintLib.lib \ $(EFILIB)/BasePcdLibNull/BasePcdLibNull/OUTPUT/BasePcdLibNull.lib \ @@ -73,7 +77,7 @@ 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 \ - --entry _ModuleEntryPoint -u _ModuleEntryPoint + --entry _ModuleEntryPoint -u _ModuleEntryPoint -m $(LD_CODE) %.o: %.c $(CC) $(ARCH_C_FLAGS) $(CFLAGS) $(INCLUDE_DIRS) -DFSTYPE=$(DRIVERNAME) -DNO_BUILTIN_VA_FUNCS -c $< -o $@ diff --git a/refind.inf b/refind.inf index a478b0c..5df54c2 100644 --- a/refind.inf +++ b/refind.inf @@ -48,7 +48,7 @@ [Packages] MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec +# MdeModulePkg/MdeModulePkg.dec IntelFrameworkPkg/IntelFrameworkPkg.dec IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec diff --git a/refind/Make.tiano b/refind/Make.tiano index fd9f444..fa4ad1d 100644 --- a/refind/Make.tiano +++ b/refind/Make.tiano @@ -7,7 +7,7 @@ include ../Make.tiano -EFILIB = $(EDK2BASE)/Build/MdeModule/$(TARGET)_$(TOOL_CHAIN_TAG)/$(TARGET_ARCH)/MdePkg/Library +EFILIB = $(EDK2BASE)/Build/Mde/$(TARGET)_$(TOOL_CHAIN_TAG)/$(UC_ARCH)/MdePkg/Library ALL_EFILIBS = $(EFILIB)/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib/OUTPUT/BaseDebugPrintErrorLevelLib.lib \ $(EFILIB)/BasePrintLib/BasePrintLib/OUTPUT/BasePrintLib.lib \ $(EFILIB)/BasePcdLibNull/BasePcdLibNull/OUTPUT/BasePcdLibNull.lib \ -- 2.39.2