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> [ --ignore-missing ] [ <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 shift 1 21 22 # Get flag. 23 24 if [ "$1" ] && [ "$1" = '--ignore-missing' ] ; then 25 IGNORE_MISSING="$1" 26 shift 1 27 else 28 IGNORE_MISSING= 29 fi 30 31 # Get other options. 32 33 ARCHDIR= 34 BUILDDIR= 35 36 # Look for an architecture or build directory. 37 38 if [ "$1" ] && [ ! -e "$1" ] ; then 39 ARCH="$1" 40 shift 1 41 else 42 ARCH= 43 fi 44 45 # Look for any additional build directory. 46 47 if [ "$1" ] && [ -e "$1" ] ; then 48 BUILDDIR="$1" 49 fi 50 51 # Use a default build directory if none specified or found. 52 53 if [ ! "$BUILDDIR" ] ; then 54 BUILDDIR=mybuild 55 fi 56 57 if [ ! -e "$BUILDDIR" ] ; then 58 cat 1>&2 <<EOF 59 Not found (build directory): $BUILDDIR 60 EOF 61 exit 1 62 fi 63 64 # Test for architecture-specific program directories. 65 66 for FILENAME in "$BUILDDIR/bin/"* ; do 67 BASENAME=`basename "$FILENAME"` 68 69 if [ "$FILENAME" = "$BUILDDIR/bin/*" ] ; then 70 cat 1>&2 <<EOF 71 No architecture-specific directories in the build directory hierarchy: 72 73 $BUILDDIR/bin 74 EOF 75 exit 1 76 elif [ ! "$ARCH" ] || [ "$ARCH" = "$BASENAME" ] ; then 77 ARCHDIR="$BASENAME" 78 break 79 fi 80 done 81 82 # Exit if no architecture resources available. 83 84 if [ ! "$ARCHDIR" ] ; then 85 cat 1>&2 <<EOF 86 No architecture specified or no appropriate program directory found. 87 EOF 88 exit 1 89 fi 90 91 # Obtain module details. 92 93 BIN="$BUILDDIR/bin/$ARCHDIR/l4f" 94 TMPLIBS=_libs.txt 95 96 echo -n > "$TMPLIBS" 97 98 for MODULE in `grep '^module ' "$CONF" | sed 's/module //'` ; do 99 PROG=`basename "$MODULE" .cfg` 100 if [ "$PROG" != "$MODULE" ] ; then 101 continue 102 fi 103 PROG=`basename "$MODULE" .io` 104 if [ "$PROG" != "$MODULE" ] ; then 105 continue 106 fi 107 PROG=`basename "$MODULE" .so` 108 if [ "$PROG" != "$MODULE" ] ; then 109 continue 110 fi 111 PROG=`basename "$MODULE" .txt` 112 if [ "$PROG" != "$MODULE" ] ; then 113 continue 114 fi 115 if [ ! -e "$BIN/$PROG" ] && [ ! "$IGNORE_MISSING" ] ; then 116 echo "Not found: $PROG" 1>&2 117 exit 1 118 fi 119 120 # NOTE: Architecture needs fixing. 121 122 mipsel-linux-gnu-readelf -d "$BIN/$PROG" | grep NEEDED | sed 's/.*\[//;s/\]$//' >> "$TMPLIBS" 123 done 124 125 # Explicitly add undetected module. 126 127 echo "libl4sys-direct.so" >> "$TMPLIBS" 128 129 sort -u "$TMPLIBS" | sed 's/^/module /' 130 rm "$TMPLIBS"