| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # -*- Mode: Sh -*- |
| 3 | # checklibs.sh --- |
| 4 | # Author : Manoj Srivastava ( [email protected] ) |
| 5 | # Created On : Fri Sep 29 15:36:22 2006 |
| 6 | # Created On Node : glaurung.internal.golden-gryphon.com |
| 7 | # Last Modified By : Manoj Srivastava |
| 8 | # Last Modified On : Fri Sep 29 22:53:27 2006 |
| 9 | # Last Machine Used: glaurung.internal.golden-gryphon.com |
| 10 | # Update Count : 43 |
| 11 | # Status : Unknown, Use with caution! |
| 12 | # HISTORY : |
| 13 | # Description : |
| 14 | # |
| 15 | # arch-tag: 8ba11489-77fa-45a0-92c4-9c5b162ee119 |
| 16 | # |
| 17 | # This program is free software; you can redistribute it and/or modify |
| 18 | # it under the terms of the GNU General Public License as published by |
| 19 | # the Free Software Foundation; either version 2 of the License, or |
| 20 | # (at your option) any later version. |
| 21 | # |
| 22 | # This program is distributed in the hope that it will be useful, |
| 23 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 | # GNU General Public License for more details. |
| 26 | # |
| 27 | # You should have received a copy of the GNU General Public License |
| 28 | # along with this program; if not, write to the Free Software |
| 29 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 30 | # |
| 31 | |
| 32 | # Make sure we abort on error |
| 33 | set -e |
| 34 | progname="$(basenamescip-shell system . . basename. \"$0\")" |
| 35 | |
| 36 | trap 'rm -f search_patterns.txt;' ALRM HUP INT PIPE TERM ABRT FPE BUS QUIT SEGV ILL EXIT |
| 37 | |
| 38 | # Find all undefined symbols in all ELF objects in this tree |
| 39 | readelfscip-shell system . . readelf. -s -D -W $(findscip-shell system . . find. . -type f -print0 | xargsscip-shell system . . xargs. -0r file | grepscip-shell system . . grep. " ELF" | \ |
| 40 | awk '{print $1}' | sed -e 's/:$//') | grepscip-shell system . . grep. UND | grepscip-shell system . . grep. -v LOCAL | |
| 41 | perlscip-shell system . . perl. -ple 's/.*\s(\S+)\s*$/\^$1\$/g' | sortscip-shell system . . sort. -u > search_patterns.txt; |
| 42 | |
| 43 | # Find all the libraries needed in this tree |
| 44 | objdumpscip-shell system . . objdump. -T --private-headers $(findscip-shell system . . find. . -type f -print0 | xargsscip-shell system . . xargs. -0r file | grepscip-shell system . . grep. " ELF" | \ |
| 45 | awk '{print $1}' | sed -e 's/:$//') | grepscip-shell system . . grep. NEEDED | sortscip-shell system . . sort. -u | awkscip-shell system . . awk. '{print $2}' | |
| 46 | while read lib; do |
| 47 | # For each library, see where it lives o the file system |
| 48 | LIB= |
| 49 | for library_dir in "/libscip-shell filesystem . . `/lib`." "/usr/libscip-shell filesystem . . `/usr/lib`." $EXTRA_LIBRARY_PATHS; do |
| 50 | if [scip-shell system . . `[`. -e "$library_dir/$lib" ]; then |
| 51 | LIB="$library_dir/$lib"; |
| 52 | break |
| 53 | fi |
| 54 | done |
| 55 | if [scip-shell system . . `[`. -z "$LIB" ]; then |
| 56 | echoscip-shell system . . echo. >&2 "Can't find $lib" |
| 57 | continue |
| 58 | fi |
| 59 | # If we fond the library, find what symbols it defines, and if these symbols |
| 60 | # are some that we need |
| 61 | if readelfscip-shell system . . readelf. -s -D -W $LIB | grepscip-shell system . . grep. -v UND | perlscip-shell system . . perl. -ple 's/.*\s(\S+)\s*$/$1/g' | \ |
| 62 | sort -u | grepscip-shell system . . grep. -q -f search_patterns.txt ; then |
| 63 | # Library provides at least some symbols we need |
| 64 | if [scip-shell system . . `[`. -n "$DEBUG" ]; then echoscip-shell system . . echo. "Found $LIB"; fi |
| 65 | else |
| 66 | # Library does not provide any symbols we need |
| 67 | echoscip-shell system . . echo. "$LIB" ; |
| 68 | fi |
| 69 | done |
| 70 | |
| 71 | # Get rid of the intermediate file |
| 72 | rmscip-shell system . . rm. -f search_patterns.txt; |
| 73 | exit 0 |
| 74 |