1 #!/bin/sh 2 3 CONF="$1" 4 5 if [ ! "$CONF" ] || [ ! -e "$CONF" ] ; then 6 cat 1>&2 <<EOF 7 Usage: $0 <module list filename> [ <arch> ] [ <build directory> ] 8 9 List modules required by the given system/payload configuration. These modules 10 should be added to the configuration file so that the dynamic linker can find 11 them in the running system. 12 13 The optional build directory indicates where executable programs may be found, 14 having been built. An initial build must have been performed before running this 15 program. 16 EOF 17 exit 1 18 fi 19 20 ARCH= 21 ARCHDIR= 22 BUILDDIR= 23 24 # Look for an architecture or build directory. 25 26 if [ "$2" ] ; then 27 if [ -e "$2" ] ; then 28 BUILDDIR="$2" 29 else 30 ARCH="$2" 31 fi 32 fi 33 34 # Look for any additional build directory. 35 36 if [ ! "$BUILDDIR" ] && [ "$3" ] && [ -e "$3" ] ; then 37 BUILDDIR="$3" 38 fi 39 40 # Use a default build directory if none specified or found. 41 42 if [ ! "$BUILDDIR" ] ; then 43 BUILDDIR=mybuild 44 fi 45 46 if [ ! -e "$BUILDDIR" ] ; then 47 cat 1>&2 <<EOF 48 Not found (build directory): $BUILDDIR 49 EOF 50 exit 1 51 fi 52 53 # Test for architecture-specific program directories. 54 55 for FILENAME in "$BUILDDIR/bin/"* ; do 56 BASENAME=`basename "$FILENAME"` 57 58 if [ "$FILENAME" = "$BUILDDIR/bin/*" ] ; then 59 cat 1>&2 <<EOF 60 No architecture-specific directories in the build directory hierarchy: 61 62 $BUILDDIR/bin 63 EOF 64 exit 1 65 elif [ ! "$ARCH" ] || [ "$ARCH" = "$BASENAME" ] ; then 66 ARCHDIR="$BASENAME" 67 break 68 fi 69 done 70 71 # Exit if no architecture resources available. 72 73 if [ ! "$ARCHDIR" ] ; then 74 cat 1>&2 <<EOF 75 No architecture specified or no appropriate program directory found. 76 EOF 77 exit 1 78 fi 79 80 # Obtain module details. 81 82 BIN="$BUILDDIR/bin/$ARCHDIR/l4f" 83 TMPLIBS=_libs.txt 84 85 echo -n > "$TMPLIBS" 86 87 for MODULE in `grep '^module ' "$CONF" | sed 's/module //'` ; do 88 PROG=`basename "$MODULE" .cfg` 89 if [ "$PROG" != "$MODULE" ] ; then 90 continue 91 fi 92 PROG=`basename "$MODULE" .io` 93 if [ "$PROG" != "$MODULE" ] ; then 94 continue 95 fi 96 PROG=`basename "$MODULE" .so` 97 if [ "$PROG" != "$MODULE" ] ; then 98 continue 99 fi 100 PROG=`basename "$MODULE" .txt` 101 if [ "$PROG" != "$MODULE" ] ; then 102 continue 103 fi 104 if [ ! -e "$BIN/$PROG" ] ; then 105 echo "Not found: $PROG" 1>&2 106 exit 1 107 fi 108 109 # NOTE: Architecture needs fixing. 110 111 mipsel-linux-gnu-readelf -d "$BIN/$PROG" | grep NEEDED | sed 's/.*\[//;s/\]$//' >> "$TMPLIBS" 112 done 113 114 # Explicitly add undetected module. 115 116 echo "libl4sys-direct.so" >> "$TMPLIBS" 117 118 sort -u "$TMPLIBS" | sed 's/^/module /' 119 rm "$TMPLIBS"