From d142bb6337b7df78c45130b03d5e4f0288ad5f9d Mon Sep 17 00:00:00 2001 From: jljusten Date: Mon, 31 Oct 2011 15:56:28 +0000 Subject: [PATCH] EmulatorPkg Linux: Improve detection of libraries for host executable build.sh will detect the locations of the libraries required by the host executable, and sets the HOST_DLINK_PATHS environment variable. In EmulatorPkg/Unix/Host/Host.inf, this environment variable is used in the linking build step. Signed-off-by: jljusten Reviewed-by: andrewfish git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12612 6f19259b-4bc3-4df7-8a09-765794883524 --- EmulatorPkg/Unix/Host/Host.inf | 8 +++++--- EmulatorPkg/build.sh | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/EmulatorPkg/Unix/Host/Host.inf b/EmulatorPkg/Unix/Host/Host.inf index c2d16697c9..018ed8673f 100644 --- a/EmulatorPkg/Unix/Host/Host.inf +++ b/EmulatorPkg/Unix/Host/Host.inf @@ -113,19 +113,21 @@ [BuildOptions] - GCC:*_*_IA32_DLINK_FLAGS == -o $(BIN_DIR)/Host -m elf_i386 -dynamic-linker /lib$(LIB_ARCH_SFX)/ld-linux.so.2 /usr/lib$(LIB_ARCH_SFX)/crt1.o /usr/lib$(LIB_ARCH_SFX)/crti.o -L/usr/X11R6/lib -lXext -lX11 /usr/lib$(LIB_ARCH_SFX)/crtn.o - GCC:*_*_*_DLINK2_FLAGS == -lpthread -lc + GCC:*_*_IA32_DLINK_FLAGS == -o $(BIN_DIR)/Host -m elf_i386 -dynamic-linker $(HOST_DLINK_PATHS) -L/usr/X11R6/lib -lXext -lX11 GCC:*_*_IA32_CC_FLAGS == -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings GCC:*_*_IA32_PP_FLAGS == -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h GCC:*_*_IA32_ASM_FLAGS == -m32 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h - GCC:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/Host -m elf_x86_64 -dynamic-linker /lib$(LIB_ARCH_SFX)/ld-linux-x86-64.so.2 /usr/lib$(LIB_ARCH_SFX)/crt1.o /usr/lib$(LIB_ARCH_SFX)/crti.o -L/usr/X11R6/lib -lXext -lX11 /usr/lib$(LIB_ARCH_SFX)/crtn.o + GCC:*_*_X64_DLINK_FLAGS == -o $(BIN_DIR)/Host -m elf_x86_64 -dynamic-linker $(HOST_DLINK_PATHS) -L/usr/X11R6/lib -lXext -lX11 GCC:*_*_X64_CC_FLAGS == -m64 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings GCC:*_GCC44_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" GCC:*_GCC45_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" + GCC:*_GCC46_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))" GCC:*_*_X64_PP_FLAGS == -m64 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h GCC:*_*_X64_ASM_FLAGS == -m64 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h + GCC:*_*_*_DLINK2_FLAGS == -lpthread -lc + # # Need to do this link via gcc and not ld as the pathing to libraries changes from OS version to OS version # diff --git a/EmulatorPkg/build.sh b/EmulatorPkg/build.sh index 06ec37a4c1..ecf56e6402 100755 --- a/EmulatorPkg/build.sh +++ b/EmulatorPkg/build.sh @@ -159,19 +159,27 @@ case $PROCESSOR in IA32) ARCH_SIZE=32 BUILD_OUTPUT_DIR=$WORKSPACE/Build/Emulator32 - if [ -d /lib32 ]; then - export LIB_ARCH_SFX=32 - fi + LIB_NAMES="ld-linux.so.2 crt1.o crti.o crtn.o" + LIB_SEARCH_PATHS="/usr/lib/i386-linux-gnu /usr/lib32 /lib32 /usr/lib /lib" ;; X64) ARCH_SIZE=64 BUILD_OUTPUT_DIR=$WORKSPACE/Build/Emulator - if [ -d /lib64 ]; then - export LIB_ARCH_SFX=64 - fi + LIB_NAMES="ld-linux-x86-64.so.2 crt1.o crti.o crtn.o" + LIB_SEARCH_PATHS="/usr/lib/x86_64-linux-gnu /usr/lib64 /lib64 /usr/lib /lib" ;; esac +for libname in $LIB_NAMES +do + for dirname in $LIB_SEARCH_PATHS + do + if [ -e $dirname/$libname ]; then + export HOST_DLINK_PATHS="$HOST_DLINK_PATHS $dirname/$libname" + break + fi + done +done PLATFORMFILE=$WORKSPACE/EmulatorPkg/EmulatorPkg.dsc BUILD_ROOT_ARCH=$BUILD_OUTPUT_DIR/DEBUG_"$TARGET_TOOLS"/$PROCESSOR -- 2.39.5