blob: c4fb4227992748becbe6b32366ca5a5b7288d6ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#!/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
|