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