]> git.saurik.com Git - wxWidgets.git/blame_incremental - misc/scripts/set_install_name
Richtext interface fixes and additions for Phoenix
[wxWidgets.git] / misc / scripts / set_install_name
... / ...
CommitLineData
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
11quiet=0
12verbose=0
13libdir=
14tool_prefix=
15install_path=
16cmd=
17
18Usage()
19{
20 name=`basename $0`
21 cat 1>&2 <<EOF
22Usage: $name [OPTIONS] [--prefix=PFX] [--libdir=DIR] [install_path]
23
24Change the install name of all wxWidgets libraries in the directory DIR (or
25current directory if libdir option is not specified) to correspond to the given
26install_path (defaults to the libraries directory if not specified).
27
28If prefix option is given, its value is prefixed to the tool names used. E.g.
29to 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
36Examples:
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
41EOF
42 exit 2
43}
44
45Message()
46{
47 if [ $quiet != 1 ]; then
48 echo "$*"
49 fi
50}
51
52VerboseMessage()
53{
54 if [ $verbose = 1 ]; then
55 Message "$*"
56 fi
57}
58
59Error()
60{
61 echo "$*" 1>&2
62}
63
64GiveUsageErrorAndExit()
65{
66 Error "$@"
67 Usage
68}
69
70ChangeInstallNames()
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
94while [ $# -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
138done
139
140if [ -z $libdir ]; then
141 libdir=`pwd`
142fi
143
144if [ -z $install_path ]; then
145 install_path=$libdir
146fi
147
148ChangeInstallNames
149
150exit 0