#!/bin/sh # Copyright 2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # # fix library perms, mung paths in pkg-config files, libtool linker scripts, # and random -config scripts to point to our build directory, and cross-compile # symlinks for the -config scripts as autotool packages will search for # prefixed -config scripts when cross-compiling. note: the ugly ln/mv is to # work around a possible race condition if multiple make jobs are generating # the same symlink at the same time. a `mv` is "atomic" (it uses rename()) # while a `ln` is actually unlink();symlink();. # LIBDIR="usr/lib" SYSROOT=${SYSROOT:-${ROOT:-${STAGEDIR}}} CROSS_BINDIR="" if [ -n "${ROOTDIR}" ] ; then # uClinux-dist mojo CROSS_BINDIR="${ROOTDIR}/tools" fi CROSS_PREFIX=${CROSS_COMPILE} if [ -n "$1" ] && [ -e "/usr/$1" ] ; then SYSROOT="/usr/$1" CROSS_BINDIR="/usr/bin" CROSS_PREFIX="$1-" fi cd "${SYSROOT}" || exit 0 if [ -d "${LIBDIR}" ] ; then find "./${LIBDIR}/" -name 'lib*.so*' -print0 | xargs -0 -r chmod 755 find "./${LIBDIR}/" -name 'lib*.la' -o -name 'lib*.a' -print0 | xargs -0 -r chmod 644 find "./${LIBDIR}/" -name 'lib*.la' -print0 | xargs -0 -r \ sed -i \ -e "/^libdir=/s:=.*:='${SYSROOT}/usr/lib':" \ -e "/^dependency_libs=/s: /usr/lib/: ${SYSROOT}/usr/lib/:g" fi if [ -d "${LIBDIR}/pkgconfig" ] ; then find "./${LIBDIR}/pkgconfig/" -name '*.pc' -print0 | xargs -0 -r \ sed -i "/^prefix=/s:=.*:='${SYSROOT}/usr':" fi if [ -d usr/bin ] ; then find ./usr/bin/ -name '*-config' -print0 | xargs -0 -r \ sed -i "/^prefix=/s:=.*:='${SYSROOT}/usr':" if [ -n "${CROSS_BINDIR}" ] && [ -d "${CROSS_BINDIR}" ] && [ -n "${CROSS_PREFIX}" ] ; then cd usr/bin || exit 1 for config in *-config ; do ln -s "${SYSROOT}/usr/bin/${config}" "${CROSS_BINDIR}/${CROSS_PREFIX}${config}.$$" mv "${CROSS_BINDIR}/${CROSS_PREFIX}${config}.$$" "${CROSS_BINDIR}/${CROSS_PREFIX}${config}" done cd ../.. fi fi exit 0