blob: 97bb783080a3c3b7a438994e1482677e9435f48c (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#!/bin/sh
# Copyright 2008-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
usage() {
cat <<-EOF
Usage: cross-fix-root <sysroot> <cross-bindir> <cross-prefix>
cross-fix-root <cross-prefix>
cross-fix-root # takes settings from env
Environment variables:
CROSS_COMPILE=<cross-prefix>
(SYSROOT|ROOT|STAGEDIR)=<sysroot>
Description:
Fix library perms and mung paths in libtool linker scripts & random -config
scripts to point to our SYSROOT directory. Add symlinks for the -config
with cross-compiler prefixes as autotool packages will search for them first
when cross-compiling.
EOF
exit 1
}
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}
case $# in
3)
SYSROOT="$1"
CROSS_BINDIR="$2"
CROSS_PREFIX="$3"
;;
1)
if [ -e "/usr/${1:-..........}" ] ; then
SYSROOT="/usr/$1"
CROSS_BINDIR="/usr/bin"
CROSS_PREFIX="$1-"
else
usage
fi
;;
0) [ -z "${SYSROOT}" ] && usage ;;
*) usage ;;
esac
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
# we don't touch .pc files anymore as we require pkg-config 0.23+ and PKG_CONFIG_SYSROOT_DIR
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
# 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() followed by a symlink().
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
|