From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-ey0-f172.google.com ([209.85.215.172]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1SBWJA-0002wO-Fm for ptxdist@pengutronix.de; Sat, 24 Mar 2012 20:07:29 +0100 Received: by eaaq11 with SMTP id q11so1223451eaa.31 for ; Sat, 24 Mar 2012 12:07:14 -0700 (PDT) From: Remy Bohmer Date: Sat, 24 Mar 2012 20:07:03 +0100 Message-Id: <1332616028-32312-3-git-send-email-linux@bohmer.net> In-Reply-To: <1332616028-32312-1-git-send-email-linux@bohmer.net> References: <1332616028-32312-1-git-send-email-linux@bohmer.net> Subject: [ptxdist] [PATCH 3/8 v3] [x86_64, multilib] Make packages install their libraries at the right place Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de While cross-compiling for x86_64 in a multilib configuration we need to install the libraries conform the Filesystem Hierarchy Standard (FHS). Summarised this will be for multilib: * All libraries compiled for and used in 64-bit applications need to be installed in /lib64 or /usr/lib64. * All libraries compiled for and used in 32-bit applications need to be installed in /lib or /usr/lib. * All executables will still find its way in the regular /bin and /sbin paths. * The Operating System itself and all its libraries should only be compiled in 64 bit mode. It should not be a mix between 32 and 64 bit libraries. 32 bit support will only contain the libraries that are required by 32-bit-applications to link against. This is also conform what many distros derived from Redhat have in their setup. Note that Debian based distros follow a somewhat different setup. Note that we use the compiler toolchain to tell us at which paths we need to install the libraries. This means that if you build for a x86_64 target _without_ multilib support the libraries will likely end up in the classical /lib and /usr/lib directories, but that is completely steered by the compiler toolchain configuration. (it follows the location where the corresponding dynamic linker is expected to be installed) So, this change makes ptxdist follow the sysroot of the compiler toolchain more such that preliminary multilib support can be achieved. Preliminary in the sense that only still one C-library is being installed. In another changeset the support for a 2nd C-library installation will be added. At least after this change (and a few subsequent ptxdist makefile fixes) the /lib and /usr/lib area will only contain the contents that belong there in multilib environment. Signed-off-by: Remy Bohmer --- v2: Fixed uClibc dynamic linker name resolving Reworked review remarks from Michael Olbrich: - Do not add fix paths to lib64, but get them from ptxd_get_lib_dir - Call ptxd_get_lib_dir from the shell script in the make files v3: trivial rebase of v2 rules/pre/Rules.make | 4 +++- scripts/lib/ptxd_make_00-init.sh | 20 ++++++++++++++++++-- scripts/lib/ptxd_make_xpkg_pkg.sh | 7 +++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/rules/pre/Rules.make b/rules/pre/Rules.make index 1d6da52..018c815 100644 --- a/rules/pre/Rules.make +++ b/rules/pre/Rules.make @@ -174,6 +174,8 @@ CROSS_ENV_PROGS := \ $(CROSS_ENV_CPP_FOR_BUILD) \ $(CROSS_ENV_LINK_FOR_BUILD) +CROSS_LIB_DIR := $(shell ptxd_get_lib_dir) + # # prepare to use pkg-config with wrapper which takes care of # $(PTXDIST_SYSROOT_TARGET). The wrapper's magic doesn't work when @@ -266,7 +268,7 @@ CROSS_ENV := \ # CROSS_AUTOCONF_SYSROOT_USR := \ - --prefix=/usr --sysconfdir=/etc --localstatedir=/var + --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/$(CROSS_LIB_DIR) CROSS_AUTOCONF_SYSROOT_ROOT := \ --prefix= diff --git a/scripts/lib/ptxd_make_00-init.sh b/scripts/lib/ptxd_make_00-init.sh index eed2a2e..bd8f6a0 100644 --- a/scripts/lib/ptxd_make_00-init.sh +++ b/scripts/lib/ptxd_make_00-init.sh @@ -137,6 +137,19 @@ ptxd_init_collectionconfig() { # +# out: 'lib' or 'lib64', derived from the ld-{linux,uClibc}.so.? from the compiler toolchain +# +ptxd_get_lib_dir() { + local dl lib_dir + + dl="$(ptxd_cross_cc_v | \ + sed -n -e 's/.* -dynamic-linker \([^ ]*\).*/\1/p')" + lib_dir="${dl%%/ld-*.so.*}" + echo "${lib_dir#/}" +} +export -f ptxd_get_lib_dir + +# # setup compiler and pkgconfig environment # # in: @@ -158,6 +171,9 @@ ptxd_init_cross_env() { prefix=( ${PTXDIST_PATH_SYSROOT_PREFIX} ) IFS="${orig_IFS}" + local -a lib_dir + lib_dir=$(ptxd_get_lib_dir) + # add "-isystem /include" local -a cppflags cppflags=( "${prefix[@]/%//include}" ) @@ -165,7 +181,7 @@ ptxd_init_cross_env() { # add "-L/lib -Wl,-rpath-link -Wl," local -a ldflags - ldflags=( "${prefix[@]/%//lib}" ) + ldflags=( "${prefix[@]/%//${lib_dir}}" ) ldflags=( "${ldflags[@]/#/-L}" "${ldflags[@]/#/-Wl,-rpath-link -Wl,}" ) export \ @@ -184,7 +200,7 @@ ptxd_init_cross_env() { # add /lib/pkgconfig and /share/pkgconfig local -a pkg_libdir - pkg_libdir=( "${prefix[@]/%//lib/pkgconfig}" "${prefix[@]/%//share/pkgconfig}" ) + pkg_libdir=( "${prefix[@]/%//${lib_dir}/pkgconfig}" "${prefix[@]/%//share/pkgconfig}" ) # # PKG_CONFIG_PATH contains additional pkg-config search diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh b/scripts/lib/ptxd_make_xpkg_pkg.sh index c03f19e..73ff2c2 100644 --- a/scripts/lib/ptxd_make_xpkg_pkg.sh +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh @@ -597,6 +597,8 @@ ptxd_install_spec() { export -f ptxd_install_spec ptxd_install_package() { + local lib_dir=$(ptxd_get_lib_dir) + for dir in "${pkg_pkg_dir}/"{,usr/}{bin,sbin,libexec}; do find "${dir}" \( -type f -o -type l \) \ -perm /111 2>/dev/null | while read file; do @@ -605,7 +607,7 @@ ptxd_install_package() { done done - for dir in "${pkg_pkg_dir}/"{,usr/}lib; do + for dir in "${pkg_pkg_dir}/"{,usr/}${lib_dir}; do find "${dir}" \( -type f -o -type l \) \ -a -name "*.so*" 2>/dev/null | while read file; do ptxd_install_generic - "${file#${pkg_pkg_dir}}" || @@ -635,10 +637,11 @@ ptxd_install_shared() { export -f ptxd_install_shared ptxd_install_lib() { + local lib_dir=$(ptxd_get_lib_dir) local lib="$1" shift - local file="$(for dir in "${pkg_pkg_dir}/"{,usr/}lib; do + local file="$(for dir in "${pkg_pkg_dir}/"{,usr/}${lib_dir}; do find "${dir}" -type f -path "${dir}/${lib}.so*"; done 2>/dev/null)" if [ ! -f "${file}" ]; then -- 1.7.5.4 -- ptxdist mailing list ptxdist@pengutronix.de