aboutsummaryrefslogtreecommitdiff
path: root/embed-MacOSX-dependencies.sh
blob: f8275a4bb602cae22756760c5d9bef77acb0965d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
#
# This script finds all of the dependecies from Fink and included them into
# current folder so that it becomes a libdir to be installed into /Library/Pd.
# <hans@at.or.at>

LIB_DIR=/Library/Pd/readanysf~
PD_APP_LIB=.

echo " "

for pd_darwin in `find . -name '*.pd_darwin'`; do
    LIBS=`otool -L $pd_darwin | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'`
    if [ "x$LIBS" != "x" ]; then
	echo "`echo $pd_darwin | sed 's|.*/\(.*\.pd_darwin$\)|\1|'` is using:"
	for lib in $LIBS; do
	    echo "    $lib"
	    install -vp /sw/lib/$lib $PD_APP_LIB
	    new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
	    install_name_tool -id $LIB_DIR/$new_lib $PD_APP_LIB/$new_lib
	    install_name_tool -change /sw/lib/$lib $LIB_DIR/$new_lib $pd_darwin
	done
	echo " "
    fi
done

for dylib in $PD_APP_LIB/*.dylib; do
    LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'`
    if [ "x$LIBS" != "x" ]; then
	echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
	for lib in $LIBS; do
	    echo "    $lib"
	    new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
	    if [ -e  $PD_APP_LIB/$new_lib ]; then
		echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
	    else
		install -vp /sw/lib/$lib $PD_APP_LIB
	    fi
	    install_name_tool -id $LIB_DIR/$new_lib $PD_APP_LIB/$new_lib
	    install_name_tool -change /sw/lib/$lib $LIB_DIR/$new_lib $dylib
	done
	echo " "
    fi
done

# run it one more time to catch dylibs that depend on dylibs
for dylib in $PD_APP_LIB/*.dylib; do
    LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'`
    if [ "x$LIBS" != "x" ]; then
	echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
	for lib in $LIBS; do
	    echo "    $lib"
	    new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
	    if [ -e  $PD_APP_LIB/$new_lib ]; then
		echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
	    else
		install -vp /sw/lib/$lib $PD_APP_LIB
	    fi
	    install_name_tool -id $LIB_DIR/$new_lib $PD_APP_LIB/$new_lib
	    install_name_tool -change /sw/lib/$lib $LIB_DIR/$new_lib $dylib
	done
	echo " "
    fi
done

# seems like we need it one last time! phew...
for dylib in $PD_APP_LIB/*.dylib; do
    LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'`
    if [ "x$LIBS" != "x" ]; then
	echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
	for lib in $LIBS; do
	    echo "    $lib"
	    new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
	    if [ -e  $PD_APP_LIB/$new_lib ]; then
		echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
	    else
		install -vp /sw/lib/$lib $PD_APP_LIB
	    fi
	    install_name_tool -id $LIB_DIR/$new_lib $PD_APP_LIB/$new_lib
	    install_name_tool -change /sw/lib/$lib $LIB_DIR/$new_lib $dylib
	done
	echo " "
    fi
done