#! /usr/bin/ksh

# Original Author: Ralph Goers(rgoer@Candle.Com)
# Borrowed heavily from Tim Mooney's HP version.
# This file is distributed under the terms of the GNU General Public License
#
# find-requires is part of RPM, the RPM Package Manager.  find-requires
# reads a list of full pathnames (in a package) on stdin, and outputs all
# shared libraries the package requires to run correctly.
#

PATH=/usr/bin

#Ensure we process 32-bit items
export OBJECT_MODE=32

# Search executables, archives, and symlinks to those types for shared  objects
sed -e "s/['\"]/\\\&/g" -e "s/$/\//g" | LANG=C xargs file | \
grep -e ":.*executable" -e ":.*archive" | cut -d: -f1 | sed "s/\/$//g" |

# Use the verbose version of dump to find the sharable objects
while read f
do
    LANG=C /usr/bin/dump -ov $f/ 2>/dev/null | egrep "^Flags.*SHROBJ|:$" |
    awk 'match($1,":$") { member=$1 }
         !match($1,":$") {print member} '
done | sed -e 's/:$//' -e 's/\/\[/\(/g' -e 's/\]/)/g' | xargs -i basename {} |
sort -u

