]> git.saurik.com Git - wxWidgets.git/blame - misc/scripts/set_install_name
Bumping the version number also requires that version.h be modified,
[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>
7# Version: $Id$
8# Licence: wxWindows licence
9################################################################################
10
11quiet=0
12verbose=0
13libdir=
14install_path=
15cmd=
16
17Usage()
18{
19 cat 1>&2 <<EOF
20Usage: $0 [OPTIONS] [--libdir=DIR] [install_path]
21
22Change the install name of all wxWidgets libraries in the directory DIR (or
23current directory if libdir option is not specified) to correspond to the given
24install_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
31Examples:
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
36EOF
37 exit 2
38}
39
40Message()
41{
42 if [ $quiet != 1 ]; then
43 echo "$*"
44 fi
45}
46
47VerboseMessage()
48{
49 if [ $verbose = 1 ]; then
50 Message "$*"
51 fi
52}
53
54Error()
55{
56 echo "$*" 1>&2
57}
58
59GiveUsageErrorAndExit()
60{
61 Error "$@"
62 Usage
63}
64
65ChangeInstallNames()
66{
67 # only change the libs themselves, not symlinks to them
71771e35 68 all_libs=`find "$libdir" -type f -name libwx_\*.dylib`
233c6e7f
VZ
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
89while [ $# -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
126done
127
128if [ -z $libdir ]; then
129 libdir=`pwd`
130fi
131
132if [ -z $install_path ]; then
133 install_path=$libdir
134fi
135
136ChangeInstallNames
137
138exit 0