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