1.1 --- a/tools/listlibs.sh Tue Jul 03 20:37:23 2018 +0200
1.2 +++ b/tools/listlibs.sh Tue Jul 03 20:38:40 2018 +0200
1.3 @@ -4,16 +4,82 @@
1.4
1.5 if [ ! "$CONF" ] || [ ! -e "$CONF" ] ; then
1.6 cat 1>&2 <<EOF
1.7 -Usage: $0 <configuration filename>
1.8 +Usage: $0 <module list filename> [ <arch> ] [ <build directory> ]
1.9
1.10 List modules required by the given system/payload configuration. These modules
1.11 should be added to the configuration file so that the dynamic linker can find
1.12 them in the running system.
1.13 +
1.14 +The optional build directory indicates where executable programs may be found,
1.15 +having been built. An initial build must have been performed before running this
1.16 +program.
1.17 EOF
1.18 exit 1
1.19 fi
1.20
1.21 -BIN=mybuild/bin/mips_32/l4f
1.22 +ARCH=
1.23 +ARCHDIR=
1.24 +BUILDDIR=
1.25 +
1.26 +# Look for an architecture or build directory.
1.27 +
1.28 +if [ "$2" ] ; then
1.29 + if [ -e "$2" ] ; then
1.30 + BUILDDIR="$2"
1.31 + else
1.32 + ARCH="$2"
1.33 + fi
1.34 +fi
1.35 +
1.36 +# Look for any additional build directory.
1.37 +
1.38 +if [ ! "$BUILDDIR" ] && [ "$3" ] && [ -e "$3" ] ; then
1.39 + BUILDDIR="$3"
1.40 +fi
1.41 +
1.42 +# Use a default build directory if none specified or found.
1.43 +
1.44 +if [ ! "$BUILDDIR" ] ; then
1.45 + BUILDDIR=mybuild
1.46 +fi
1.47 +
1.48 +if [ ! -e "$BUILDDIR" ] ; then
1.49 + cat 1>&2 <<EOF
1.50 +Not found (build directory): $BUILDDIR
1.51 +EOF
1.52 + exit 1
1.53 +fi
1.54 +
1.55 +# Test for architecture-specific program directories.
1.56 +
1.57 +for FILENAME in "$BUILDDIR/bin/"* ; do
1.58 + BASENAME=`basename "$FILENAME"`
1.59 +
1.60 + if [ "$FILENAME" = "$BUILDDIR/bin/*" ] ; then
1.61 + cat 1>&2 <<EOF
1.62 +No architecture-specific directories in the build directory hierarchy:
1.63 +
1.64 +$BUILDDIR/bin
1.65 +EOF
1.66 + exit 1
1.67 + elif [ ! "$ARCH" ] || [ "$ARCH" = "$BASENAME" ] ; then
1.68 + ARCHDIR="$BASENAME"
1.69 + break
1.70 + fi
1.71 +done
1.72 +
1.73 +# Exit if no architecture resources available.
1.74 +
1.75 +if [ ! "$ARCHDIR" ] ; then
1.76 + cat 1>&2 <<EOF
1.77 +No architecture specified or no appropriate program directory found.
1.78 +EOF
1.79 + exit 1
1.80 +fi
1.81 +
1.82 +# Obtain module details.
1.83 +
1.84 +BIN="$BUILDDIR/bin/$ARCHDIR/l4f"
1.85 TMPLIBS=_libs.txt
1.86
1.87 echo -n > "$TMPLIBS"
1.88 @@ -31,10 +97,17 @@
1.89 if [ "$PROG" != "$MODULE" ] ; then
1.90 continue
1.91 fi
1.92 + PROG=`basename "$MODULE" .txt`
1.93 + if [ "$PROG" != "$MODULE" ] ; then
1.94 + continue
1.95 + fi
1.96 if [ ! -e "$BIN/$PROG" ] ; then
1.97 echo "Not found: $PROG" 1>&2
1.98 exit 1
1.99 fi
1.100 +
1.101 + # NOTE: Architecture needs fixing.
1.102 +
1.103 mipsel-linux-gnu-readelf -d "$BIN/$PROG" | grep NEEDED | sed 's/.*\[//;s/\]$//' >> "$TMPLIBS"
1.104 done
1.105