forked from ehb54/ultrascan3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libnames.sh
executable file
·64 lines (53 loc) · 1.64 KB
/
libnames.sh
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
#!/bin/sh
# libnames.sh - fix install names for all libraries (Mac only)
CDIR=`pwd`
BDIR=`dirname $0`
if [ -z "${BDIR}" -o "${BDIR}" = "." ]; then
BDIR=${CDIR}
fi
BDIR=`echo ${BDIR} | sed -e 's@/bin$@@'`
# work from the ~/us3_somo/lib directory
cd ${BDIR}/lib
LIBQWT=`ls libqwt.*.*.*.dylib`
LIBS="utils gui"
FILES="\
libus_gui.10.0.0.dylib \
libus_utils.10.0.0.dylib \
${LIBQWT} \
libqwtplot3d.0.2.7.dylib \
"
# fix each of the us3 libraries
for FILE in ${FILES} ; do
SHORTF=`echo "${FILE}" | sed -e "s/[0-9]\.[0-9]\.dylib/dylib/"`
# get list of names that need fixing
LIBL=`otool -L ${FILE} \
| egrep '_utils|_gui|qwt|qwtplot3d|mysql|crypto|openssl|framework' \
| grep -v executable \
| grep -v ${FILE} \
| grep -v ${SHORTF} \
| grep -v Library \
| awk '{print $1}'`
# fix each of the shared library names
for NAMI in ${LIBL}; do
if [ `echo ${NAMI} | grep -ci qca` -eq 0 ]; then
# give relative path to library
if [ `echo ${NAMI} | egrep -ci 'mysql|crypto|openssl'` -ne 0 ]; then
BASF=`basename ${NAMI}`
NAMO=@executable_path/../../../../lib/${BASF}
else
if [ `echo ${NAMI} | grep -ci framework` -eq 0 ]; then
# use relative path to lib
NAMO=@executable_path/../../../../lib/${NAMI}
else
# use relative path to Qt framework
NAMJ=`echo ${NAMI} | sed -e 's#@rpath/##'`
NAMO=@executable_path/../../../../Frameworks/${NAMJ}
fi
fi
fi
# report and do the fix
echo "install_name_tool -change ${NAMI} ${NAMO} ${FILE}"
install_name_tool -change ${NAMI} ${NAMO} ${FILE}
done
done
cd ${CDIR}