]> git.saurik.com Git - wxWidgets.git/blame - misc/scripts/set_install_name
added language info for Northern Sami (patch 1964036)
[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=
f283c683 14tool_prefix=
233c6e7f
VZ
15install_path=
16cmd=
17
18Usage()
19{
f283c683 20 name=`basename $0`
233c6e7f 21 cat 1>&2 <<EOF
f283c683 22Usage: $name [OPTIONS] [--prefix=PFX] [--libdir=DIR] [install_path]
233c6e7f
VZ
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
f283c683
VZ
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
233c6e7f
VZ
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:
f283c683 37 * do "$name --libdir=MyApp.app/Contents/Frameworks @executable_path/../Frameworks"
233c6e7f 38 when distributing wxWidgets shared libraries with application MyApp
f283c683 39 * run "$name" without parameters in the directory containing wxWidgets libraries
233c6e7f
VZ
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
71771e35 73 all_libs=`find "$libdir" -type f -name libwx_\*.dylib`
233c6e7f
VZ
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`
f283c683 83 oldname=`${tool_prefix}otool -D $lib | tail -1`
233c6e7f
VZ
84 Message "Updating install name of and references to $libname:"
85 for lib2 in $all_libs; do
86 VerboseMessage " updating $lib2"
f283c683 87 eval "$cmd ${tool_prefix}install_name_tool -change "$oldname" $install_path/$libname $lib2"
233c6e7f
VZ
88 done
89 VerboseMessage " updating $libname id"
f283c683 90 eval "$cmd ${tool_prefix}install_name_tool -id $install_path/$libname $lib"
233c6e7f
VZ
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
f283c683
VZ
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
233c6e7f
VZ
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