From 3c8016b302c658d20ebf8eebd5f32daf818a0531 Mon Sep 17 00:00:00 2001 From: kuqin12 <42554914+kuqin12@users.noreply.github.com> Date: Tue, 25 Apr 2023 15:48:19 -0700 Subject: BaseTools: Support custom library build for base tools on Linux ARM This change added the build script to cross compile the base tool binaries for Linux ARM/AARCH64 systems. The needed libuuid system library is pulled from source file and rebuilt to support the corresponding library dependencies. Individual tools' makefiles are also updated to link the cross compiled library as well. The EDK2 base tool build script was also updated to support such change. This was tested functional on Linux ARM host system. Cc: Rebecca Cran Cc: Liming Gao Cc: Bob Feng Cc: Yuwei Chen Signed-off-by: Kun Qin --- BaseTools/Source/C/DevicePath/GNUmakefile | 4 ++++ BaseTools/Source/C/GenFv/GNUmakefile | 11 ++++++++++- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 9 +++++++++ BaseTools/Source/C/GenFw/GNUmakefile | 4 ++++ BaseTools/Source/C/GenSec/GNUmakefile | 4 ++++ BaseTools/Source/C/Makefiles/header.makefile | 10 +++++----- 6 files changed, 36 insertions(+), 6 deletions(-) (limited to 'BaseTools/Source') diff --git a/BaseTools/Source/C/DevicePath/GNUmakefile b/BaseTools/Source/C/DevicePath/GNUmakefile index f61b1b2f17..26ae14c468 100644 --- a/BaseTools/Source/C/DevicePath/GNUmakefile +++ b/BaseTools/Source/C/DevicePath/GNUmakefile @@ -30,6 +30,10 @@ ifeq ($(CYGWIN), CYGWIN) endif ifeq ($(LINUX), Linux) +ifndef CROSS_LIB_UUID LIBS += -luuid +else + LIBS += -L$(CROSS_LIB_UUID) +endif endif diff --git a/BaseTools/Source/C/GenFv/GNUmakefile b/BaseTools/Source/C/GenFv/GNUmakefile index 872b981f6a..843eb1b291 100644 --- a/BaseTools/Source/C/GenFv/GNUmakefile +++ b/BaseTools/Source/C/GenFv/GNUmakefile @@ -14,6 +14,15 @@ include $(MAKEROOT)/Makefiles/app.makefile LIBS = -lCommon ifeq ($(CYGWIN), CYGWIN) - LIBS += -L/lib/e2fsprogs + LIBS += -L/lib/e2fsprogs -luuid +endif + +ifeq ($(LINUX), Linux) +ifndef CROSS_LIB_UUID + LIBS += -luuid +else + LIBS += -L$(CROSS_LIB_UUID) + BUILD_CFLAGS += -D__CROSS_LIB_UUID__ -I $(CROSS_LIB_UUID_INC) +endif endif diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c index 29c3363a50..3f982c529b 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c @@ -14,6 +14,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Include files // +#if defined(__FreeBSD__) +#include +#elif defined(__GNUC__) +#if !defined(__CROSS_LIB_UUID__) +#include +#else +#include +#endif +#endif #ifdef __GNUC__ #include #endif diff --git a/BaseTools/Source/C/GenFw/GNUmakefile b/BaseTools/Source/C/GenFw/GNUmakefile index 76cda7e7a3..2079835df7 100644 --- a/BaseTools/Source/C/GenFw/GNUmakefile +++ b/BaseTools/Source/C/GenFw/GNUmakefile @@ -18,6 +18,10 @@ ifeq ($(CYGWIN), CYGWIN) endif ifeq ($(LINUX), Linux) +ifndef CROSS_LIB_UUID LIBS += -luuid +else + LIBS += -L$(CROSS_LIB_UUID) +endif endif diff --git a/BaseTools/Source/C/GenSec/GNUmakefile b/BaseTools/Source/C/GenSec/GNUmakefile index 9f0844c1b8..db634e40e6 100644 --- a/BaseTools/Source/C/GenSec/GNUmakefile +++ b/BaseTools/Source/C/GenSec/GNUmakefile @@ -18,6 +18,10 @@ ifeq ($(CYGWIN), CYGWIN) endif ifeq ($(LINUX), Linux) +ifndef CROSS_LIB_UUID LIBS += -luuid +else + LIBS += -L$(CROSS_LIB_UUID) +endif endif diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile index d369908a09..f16b3297fc 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -54,11 +54,11 @@ AS ?= $(CLANG_BIN)clang AR ?= $(CLANG_BIN)llvm-ar LD ?= $(CLANG_BIN)llvm-ld else ifeq ($(origin CC),default) -CC = gcc -CXX = g++ -AS = gcc -AR = ar -LD = ld +CC = $(GCC_PREFIX)gcc +CXX = $(GCC_PREFIX)g++ +AS = $(GCC_PREFIX)gcc +AR = $(GCC_PREFIX)ar +LD = $(GCC_PREFIX)ld endif LINKER ?= $(CC) ifeq ($(HOST_ARCH), IA32) -- cgit