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