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