summaryrefslogtreecommitdiff
path: root/mk/fix_install_names.sh
blob: f6278ce2d74a443f320feec554acb945a58c3104 (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
# Darwin / Mac OS X only
#   sh fix_install_names.sh directory binary
#
# Changes 'binary' to assume that all libHS*_dyn.dylib libraries
# are to be found in 'directory'.

prefix=$1
file=$2

type=`file "$file"`

if `test "${type/Mach-O}" == "$type"`
then
    exit
fi

if `test x${prefix%/} != x"" `
then
    prefix=${prefix%/}/
fi

for i in `otool -L $file \
         | grep 'libHS.*_dyn.dylib' \
         | sed 's/.\(.*libHS.*_dyn.dylib\).*/\1/'`
do
    install_name_tool -change $i "$prefix`basename $i`" $file
done

if `test "${file%.dylib}" != "${file}"`
then
    install_name_tool -id "$prefix`basename $file`" $file
fi