Add PhysicsFS instructions
[mingw-xscripts.git] / mingw-list-dlls
blobde9051c1b1610b765b32615f71c7d883e2684a76
1 #!/bin/sh
3 format=raw
4 verbose=
6 usage() {
7 cat >&2 <<EOF
8 Usage: $0 [--verbose] [--format={raw|shell|graph}] [--] {file.dll|file.exe} ...
9 EOF
10 exit 1
13 test $# != 0 || usage
15 while test $# != 0; do
16 case "$1" in
17 --format\=*)
18 case "$(echo "$1" | cut -d= -f2)" in
19 raw) format=raw ;;
20 shell) format=shell ;;
21 graph) format=graph ;;
22 *) usage ;;
23 esac
25 --verbose)
26 verbose=1
28 --)
29 shift
30 break
33 break
35 esac
37 shift
38 done
40 . mingw-environment.sh
42 OBJDUMP=${OBJDUMP:-$TARGET-objdump}
43 ALL_DLLS="$(find "$MINGW_PREFIX/bin" "$MINGW_PREFIX/lib" -name "*.dll")"
45 dump_dlls() {
46 $OBJDUMP -x -- "$1" | grep 'DLL Name:' | cut -d: -f2
49 list_deps() {
50 # $1 -> filename
51 # $2 -> indent level
52 # $3 -> print full filename
54 if test "$2" -ge 0; then
55 printf '%*s%s\n' $(expr "$2" \* 2) '' \
56 "$(test "$3" = 1 && echo "$1" || echo "$(basename -- "$1")")"
59 for dep in $(dump_dlls "$1"); do
60 installed="$(echo "$ALL_DLLS" | grep "$dep")"
62 if test "$installed"; then
63 list_deps "$installed" $(expr "$2" + 1) $3
64 elif test "$verbose"; then
65 echo "'$(basename -- "$1")' needs '$dep'," \
66 "which is not installed." >&2
68 done
71 shellscriptify() {
72 cat <<EOF
73 #!/bin/sh
74 # This script was generated by $(basename $0).
75 # Edit the list below to suit your needs.
77 cp \\
78 $(sed -e 's/^/ /' -e 's/$/ \\/')
80 EOF
83 # "raw" format defaults
84 initindent=-1
85 longnames=1
87 case "$format" in
88 shell)
89 initindent=-1
90 longnames=1
92 graph)
93 initindent=0
94 longnames=0
95 esac
97 while test $# != 0; do
98 list_deps "$1" $initindent $longnames
99 shift
100 done | {
101 case "$format" in
102 raw)
103 sed 's/^\s\+//' | sort | uniq
105 shell)
106 sed 's/^\s\+//' | sort | uniq | shellscriptify
108 graph)
111 esac