1 | #!/bin/bash |
---|
2 | |
---|
3 | MP="/opt/local" |
---|
4 | |
---|
5 | hasq() { |
---|
6 | [[ " ${*:2} " == *" $1 "* ]] |
---|
7 | } |
---|
8 | |
---|
9 | checkdeps-list() { |
---|
10 | local BASE=$(otool -L "${@}" 2> /dev/null | egrep '/usr/X11/lib|/opt/local/lib' | awk '{print $1}' | sed 's:.*/::' | sort -u) |
---|
11 | local BASE_US=$(otool -D "${@}" 2> /dev/null | grep -v ':' | egrep '/usr/X11/lib|/opt/local/lib' | sed 's:.*/::' | sort -u) |
---|
12 | local f |
---|
13 | local l |
---|
14 | local lv |
---|
15 | local our_deps="" |
---|
16 | |
---|
17 | for f in ${BASE} ; do |
---|
18 | hasq $f ${BASE_US} && continue |
---|
19 | |
---|
20 | if [[ -f /usr/X11/lib/$f ]] ; then |
---|
21 | lv=${f%.dylib} |
---|
22 | l=${lv%.*} |
---|
23 | |
---|
24 | case $l in |
---|
25 | #libGL*) our_deps="${our_deps} lib:$lv:mesa" ;; |
---|
26 | #libXaw) our_deps="${our_deps} lib:$l:xorg-libXaw" ;; |
---|
27 | #libXss) our_deps="${our_deps} lib:$lv:xorg-libXScrnSaver" ;; |
---|
28 | #libXmuu) our_deps="${our_deps} lib:$lv:xorg-libXmu" ;; |
---|
29 | #libXrender) our_deps="${our_deps} lib:$lv:xrender" ;; |
---|
30 | #libICE) our_deps="${our_deps} lib:$lv:xorg-libice" ;; |
---|
31 | #libSM) our_deps="${our_deps} lib:$lv:xorg-libsm" ;; |
---|
32 | #libXRes) our_deps="${our_deps} lib:$lv:xorg-libXres" ;; |
---|
33 | #libXpm) our_deps="${our_deps} lib:$lv:xpm" ;; |
---|
34 | #libXft) our_deps="${our_deps} lib:$lv:Xft2" ;; |
---|
35 | #libfreetype) our_deps="${our_deps} port:freetype" ;; |
---|
36 | #libfontconfig) our_deps="${our_deps} port:fontconfig" ;; |
---|
37 | #libpixman-1) our_deps="${our_deps} lib:$lv:libpixman" ;; |
---|
38 | #libcairo) our_deps="${our_deps} path:lib/pkgconfig/cairo.pc:cairo" ;; |
---|
39 | #libpng12) our_deps="${our_deps} port:libpng" ;; |
---|
40 | #libpng) our_deps="${our_deps} port:libpng" ;; |
---|
41 | #*) our_deps="${our_deps} lib:$lv:xorg-$l" ;; |
---|
42 | libGL*) our_deps="${our_deps} port:mesa" ;; |
---|
43 | libXss) our_deps="${our_deps} port:xorg-libXScrnSaver" ;; |
---|
44 | libXmuu) our_deps="${our_deps} port:xorg-libXmu" ;; |
---|
45 | libXrender) our_deps="${our_deps} port:xrender" ;; |
---|
46 | libICE) our_deps="${our_deps} port:xorg-libice" ;; |
---|
47 | libSM) our_deps="${our_deps} port:xorg-libsm" ;; |
---|
48 | libXRes) our_deps="${our_deps} port:xorg-libXres" ;; |
---|
49 | libXpm) our_deps="${our_deps} port:xpm" ;; |
---|
50 | libXft) our_deps="${our_deps} port:Xft2" ;; |
---|
51 | libfreetype) our_deps="${our_deps} port:freetype" ;; |
---|
52 | libfontconfig) our_deps="${our_deps} port:fontconfig" ;; |
---|
53 | libpixman-1) our_deps="${our_deps} port:libpixman" ;; |
---|
54 | libcairo) our_deps="${our_deps} path:lib/pkgconfig/cairo.pc:cairo" ;; |
---|
55 | libpng12) our_deps="${our_deps} port:libpng" ;; |
---|
56 | libpng) our_deps="${our_deps} port:libpng" ;; |
---|
57 | *) our_deps="${our_deps} port:xorg-$l" ;; |
---|
58 | esac |
---|
59 | fi |
---|
60 | done |
---|
61 | |
---|
62 | echo ${our_deps} |
---|
63 | } |
---|
64 | |
---|
65 | checkdeps-list-filtered() { |
---|
66 | local BASE=$(otool -L "${@}" 2> /dev/null | egrep '/usr/X11/lib|/opt/local/lib' | awk '{print $1}' | sed 's:.*/::' | sort -u) |
---|
67 | local BASE_US=$(otool -D "${@}" 2> /dev/null | grep -v ':' | egrep '/usr/X11/lib|/opt/local/lib' | sed 's:.*/::' | sort -u) |
---|
68 | local f |
---|
69 | local l |
---|
70 | local lv |
---|
71 | local filter_out="" |
---|
72 | local our_deps=$(checkdeps-list "${@}") |
---|
73 | |
---|
74 | for f in ${BASE} ; do |
---|
75 | hasq $f ${BASE_US} && continue |
---|
76 | |
---|
77 | if [[ -f /usr/X11/lib/$f ]] ; then |
---|
78 | filter_out="${filter_out} $(checkdeps-list /usr/X11/lib/$f)" |
---|
79 | fi |
---|
80 | done |
---|
81 | |
---|
82 | for f in ${our_deps} ; do |
---|
83 | if ! hasq ${f} ${filter_out} ; then |
---|
84 | echo -n "${f} " |
---|
85 | fi |
---|
86 | done |
---|
87 | } |
---|
88 | |
---|
89 | checkdeps() { |
---|
90 | echo -n "depends_lib" |
---|
91 | for dep in $(checkdeps-list-filtered "${@}") ; do |
---|
92 | echo ' \' |
---|
93 | echo -n " ${dep}" |
---|
94 | done |
---|
95 | } |
---|
96 | |
---|
97 | PORT=$(basename $(pwd)) |
---|
98 | |
---|
99 | if [[ -n "$1" ]] ; then |
---|
100 | PORT=$1 |
---|
101 | else |
---|
102 | echo "Assuming port: $PORT" >&2 |
---|
103 | fi |
---|
104 | |
---|
105 | DESTDIR="" |
---|
106 | |
---|
107 | if [[ -n "$(port work $PORT)" && -d "$(port work $PORT)"/destdir ]] ; then |
---|
108 | DESTDIR="$(port work $PORT)"/destdir |
---|
109 | elif [[ -d "${MP}/var/macports/software/${PORT}" ]] ; then |
---|
110 | DESTDIR="${MP}/var/macports/software/${PORT}/*" |
---|
111 | fi |
---|
112 | |
---|
113 | if [[ -z "${DESTDIR}" ]] ; then |
---|
114 | echo "Couldn't determine the destdir for the port." >&2 |
---|
115 | exit 1 |
---|
116 | fi |
---|
117 | |
---|
118 | echo "Using destdir: ${DESTDIR}" |
---|
119 | |
---|
120 | checkdeps ${DESTDIR}/${MP}/{bin,lib}/* |
---|