aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-01-08 05:09:55 -0500
committerMike Frysinger <vapier@gentoo.org>2010-01-08 05:09:55 -0500
commitdf8414a59bfc81930eef3a194d7bdfa859379d5f (patch)
treec8c1b24b28ebb84ffceacda0d2108519a39082c2 /wrappers/cross-fix-root
parentcrossdev: let people cleanup recursively (diff)
downloadcrossdev-df8414a59bfc81930eef3a194d7bdfa859379d5f.tar.gz
crossdev-df8414a59bfc81930eef3a194d7bdfa859379d5f.tar.bz2
crossdev-df8414a59bfc81930eef3a194d7bdfa859379d5f.zip
cross-fix-root: add some usage text
Be nice to users instead of exiting all the time with no output. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'wrappers/cross-fix-root')
-rwxr-xr-xwrappers/cross-fix-root64
1 files changed, 41 insertions, 23 deletions
diff --git a/wrappers/cross-fix-root b/wrappers/cross-fix-root
index 663db9f..234f2bb 100755
--- a/wrappers/cross-fix-root
+++ b/wrappers/cross-fix-root
@@ -1,16 +1,25 @@
#!/bin/sh
-# Copyright 2008-2009 Gentoo Foundation
+# Copyright 2008-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-#
-# 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();.
-#
+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}}}
@@ -20,19 +29,24 @@ if [ -n "${ROOTDIR}" ] ; then
CROSS_BINDIR="${ROOTDIR}/tools"
fi
CROSS_PREFIX=${CROSS_COMPILE}
-if [ -n "$3" ] ; then
- SYSROOT="$1"
- CROSS_BINDIR="$2"
- CROSS_PREFIX="$3"
-elif [ -n "$1" ] ; then
- if [ -e "/usr/$1" ] ; then
- SYSROOT="/usr/$1"
- CROSS_BINDIR="/usr/bin"
- CROSS_PREFIX="$1-"
- else
- exit 1
- fi
-fi
+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
@@ -61,6 +75,10 @@ if [ -d usr/bin ] ; then
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