]> git.saurik.com Git - wxWidgets.git/blame - misc/scripts/set_install_name
avoid duplicate move events
[wxWidgets.git] / misc / scripts / set_install_name
CommitLineData
233c6e7f
VZ
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>
233c6e7f
VZ
7# Licence: wxWindows licence
8################################################################################
9
10quiet=0
11verbose=0
12libdir=
f283c683 13tool_prefix=
233c6e7f
VZ
14install_path=
15cmd=
16
17Usage()
18{
f283c683 19 name=`basename $0`
233c6e7f 20 cat 1>&2 <<EOF
f283c683 21Usage: $name [OPTIONS] [--prefix=PFX] [--libdir=DIR] [install_path]
233c6e7f
VZ
22
23Change the install name of all wxWidgets libraries in the directory DIR (or
24current directory if libdir option is not specified) to correspond to the given
25install_path (defaults to the libraries directory if not specified).
26
f283c683
VZ
27If prefix option is given, its value is prefixed to the tool names used. E.g.
28to use this script when cross-building, use "--prefix=powerpc-apple-darwin8-".
29
233c6e7f
VZ
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
35Examples:
f283c683 36 * do "$name --libdir=MyApp.app/Contents/Frameworks @executable_path/../Frameworks"
233c6e7f 37 when distributing wxWidgets shared libraries with application MyApp
f283c683 38 * run "$name" without parameters in the directory containing wxWidgets libraries
233c6e7f
VZ
39 to use them without installing
40EOF
41 exit 2
42}
43
44Message()
45{
46 if [ $quiet != 1 ]; then
47 echo "$*"
48 fi
49}
50
51VerboseMessage()
52{
53 if [ $verbose = 1 ]; then
54 Message "$*"
55 fi
56}
57
58Error()
59{
60 echo "$*" 1>&2
61}
62
63GiveUsageErrorAndExit()
64{
65 Error "$@"
66 Usage
67}
68
69ChangeInstallNames()
70{
71 # only change the libs themselves, not symlinks to them
71771e35 72 all_libs=`find "$libdir" -type f -name libwx_\*.dylib`
233c6e7f
VZ
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`
f283c683 82 oldname=`${tool_prefix}otool -D $lib | tail -1`
233c6e7f
VZ
83 Message "Updating install name of and references to $libname:"
84 for lib2 in $all_libs; do
85 VerboseMessage " updating $lib2"
f283c683 86 eval "$cmd ${tool_prefix}install_name_tool -change "$oldname" $install_path/$libname $lib2"
233c6e7f
VZ
87 done
88 VerboseMessage " updating $libname id"
f283c683 89 eval "$cmd ${tool_prefix}install_name_tool -id $install_path/$libname $lib"
233c6e7f
VZ
90 done
91}
92
93while [ $# -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
f283c683
VZ
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
233c6e7f
VZ
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
137done
138
139if [ -z $libdir ]; then
140 libdir=`pwd`
141fi
142
143if [ -z $install_path ]; then
144 install_path=$libdir
145fi
146
147ChangeInstallNames
148
149exit 0