]> git.saurik.com Git - wxWidgets.git/blob - misc/scripts/set_install_name
Disable some wxWebView tests that fail on the buildbot but not locally.
[wxWidgets.git] / misc / scripts / set_install_name
1 #!/bin/sh
2 #
3 # Name: set_install_name
4 # Purpose: set install_name for wx shared libraries under Mac OS X
5 # Usage: run with --help option to see the instructions
6 # Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
7 # Version: $Id$
8 # Licence: wxWindows licence
9 ################################################################################
10
11 quiet=0
12 verbose=0
13 libdir=
14 tool_prefix=
15 install_path=
16 cmd=
17
18 Usage()
19 {
20 name=`basename $0`
21 cat 1>&2 <<EOF
22 Usage: $name [OPTIONS] [--prefix=PFX] [--libdir=DIR] [install_path]
23
24 Change the install name of all wxWidgets libraries in the directory DIR (or
25 current directory if libdir option is not specified) to correspond to the given
26 install_path (defaults to the libraries directory if not specified).
27
28 If prefix option is given, its value is prefixed to the tool names used. E.g.
29 to use this script when cross-building, use "--prefix=powerpc-apple-darwin8-".
30
31 -n, --dry-run Don't really do anything, just print the commands
32 -q, --quiet Don't display any non error messages
33 -v, --verbose Just show the commands being executed, don't run them
34 -h, --help Show this help screen and exit
35
36 Examples:
37 * do "$name --libdir=MyApp.app/Contents/Frameworks @executable_path/../Frameworks"
38 when distributing wxWidgets shared libraries with application MyApp
39 * run "$name" without parameters in the directory containing wxWidgets libraries
40 to use them without installing
41 EOF
42 exit 2
43 }
44
45 Message()
46 {
47 if [ $quiet != 1 ]; then
48 echo "$*"
49 fi
50 }
51
52 VerboseMessage()
53 {
54 if [ $verbose = 1 ]; then
55 Message "$*"
56 fi
57 }
58
59 Error()
60 {
61 echo "$*" 1>&2
62 }
63
64 GiveUsageErrorAndExit()
65 {
66 Error "$@"
67 Usage
68 }
69
70 ChangeInstallNames()
71 {
72 # only change the libs themselves, not symlinks to them
73 all_libs=`find "$libdir" -type f -name libwx_\*.dylib`
74 if [ -z "$all_libs" ]; then
75 Error "No wx libraries found in \"$libdir\"."
76 exit 1
77 fi
78
79 VerboseMessage "Processing $all_libs\n"
80
81 for lib in $all_libs; do
82 libname=`basename $lib`
83 oldname=`${tool_prefix}otool -D $lib | tail -1`
84 Message "Updating install name of and references to $libname:"
85 for lib2 in $all_libs; do
86 VerboseMessage " updating $lib2"
87 eval "$cmd ${tool_prefix}install_name_tool -change "$oldname" $install_path/$libname $lib2"
88 done
89 VerboseMessage " updating $libname id"
90 eval "$cmd ${tool_prefix}install_name_tool -id $install_path/$libname $lib"
91 done
92 }
93
94 while [ $# -ge 1 ]; do
95 case "$1" in
96 --help|-h)
97 Usage
98 ;;
99
100 --dry-run|-n)
101 cmd="echo"
102 ;;
103
104 --quiet|-q)
105 quiet=1
106 ;;
107
108 --verbose|-v)
109 verbose=1
110 ;;
111
112 --libdir=*)
113 if [ -n "$libdir" ]; then
114 GiveUsageErrorAndExit "Multiple --libdir options not allowed."
115 fi
116 libdir=`echo $1 | cut -c10-`
117 ;;
118
119 --prefix=*)
120 if [ -n "$tool_prefix" ]; then
121 GiveUsageErrorAndExit "At most one --prefix option can be given."
122 fi
123 tool_prefix=`echo $1 | cut -c10-`
124 ;;
125
126 -*)
127 GiveUsageErrorAndExit "Unknown option \"$1\"."
128 ;;
129
130 *)
131 if [ -n "$install_path" ]; then
132 GiveUsageErrorAndExit "Too many parameters."
133 fi
134 install_path=$1
135 esac
136
137 shift
138 done
139
140 if [ -z $libdir ]; then
141 libdir=`pwd`
142 fi
143
144 if [ -z $install_path ]; then
145 install_path=$libdir
146 fi
147
148 ChangeInstallNames
149
150 exit 0