2005-11-20 13:11:44 -05:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Name: set_install_name
|
|
|
|
# Purpose: set install_name for wx shared libraries under Mac OS X
|
|
|
|
# Usage: run with --help option to see the instructions
|
|
|
|
# Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
|
|
|
|
# Licence: wxWindows licence
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
quiet=0
|
|
|
|
verbose=0
|
|
|
|
libdir=
|
2007-10-23 09:38:29 -04:00
|
|
|
tool_prefix=
|
2005-11-20 13:11:44 -05:00
|
|
|
install_path=
|
|
|
|
cmd=
|
|
|
|
|
|
|
|
Usage()
|
|
|
|
{
|
2007-10-23 09:38:29 -04:00
|
|
|
name=`basename $0`
|
2005-11-20 13:11:44 -05:00
|
|
|
cat 1>&2 <<EOF
|
2007-10-23 09:38:29 -04:00
|
|
|
Usage: $name [OPTIONS] [--prefix=PFX] [--libdir=DIR] [install_path]
|
2005-11-20 13:11:44 -05:00
|
|
|
|
|
|
|
Change the install name of all wxWidgets libraries in the directory DIR (or
|
|
|
|
current directory if libdir option is not specified) to correspond to the given
|
|
|
|
install_path (defaults to the libraries directory if not specified).
|
|
|
|
|
2007-10-23 09:38:29 -04:00
|
|
|
If prefix option is given, its value is prefixed to the tool names used. E.g.
|
|
|
|
to use this script when cross-building, use "--prefix=powerpc-apple-darwin8-".
|
|
|
|
|
2005-11-20 13:11:44 -05:00
|
|
|
-n, --dry-run Don't really do anything, just print the commands
|
|
|
|
-q, --quiet Don't display any non error messages
|
|
|
|
-v, --verbose Just show the commands being executed, don't run them
|
|
|
|
-h, --help Show this help screen and exit
|
|
|
|
|
|
|
|
Examples:
|
2007-10-23 09:38:29 -04:00
|
|
|
* do "$name --libdir=MyApp.app/Contents/Frameworks @executable_path/../Frameworks"
|
2005-11-20 13:11:44 -05:00
|
|
|
when distributing wxWidgets shared libraries with application MyApp
|
2007-10-23 09:38:29 -04:00
|
|
|
* run "$name" without parameters in the directory containing wxWidgets libraries
|
2005-11-20 13:11:44 -05:00
|
|
|
to use them without installing
|
|
|
|
EOF
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
Message()
|
|
|
|
{
|
|
|
|
if [ $quiet != 1 ]; then
|
|
|
|
echo "$*"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
VerboseMessage()
|
|
|
|
{
|
|
|
|
if [ $verbose = 1 ]; then
|
|
|
|
Message "$*"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
Error()
|
|
|
|
{
|
|
|
|
echo "$*" 1>&2
|
|
|
|
}
|
|
|
|
|
|
|
|
GiveUsageErrorAndExit()
|
|
|
|
{
|
|
|
|
Error "$@"
|
|
|
|
Usage
|
|
|
|
}
|
|
|
|
|
|
|
|
ChangeInstallNames()
|
|
|
|
{
|
|
|
|
# only change the libs themselves, not symlinks to them
|
2006-03-10 08:42:10 -05:00
|
|
|
all_libs=`find "$libdir" -type f -name libwx_\*.dylib`
|
2005-11-20 13:11:44 -05:00
|
|
|
if [ -z "$all_libs" ]; then
|
|
|
|
Error "No wx libraries found in \"$libdir\"."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
VerboseMessage "Processing $all_libs\n"
|
|
|
|
|
|
|
|
for lib in $all_libs; do
|
|
|
|
libname=`basename $lib`
|
2007-10-23 09:38:29 -04:00
|
|
|
oldname=`${tool_prefix}otool -D $lib | tail -1`
|
2005-11-20 13:11:44 -05:00
|
|
|
Message "Updating install name of and references to $libname:"
|
|
|
|
for lib2 in $all_libs; do
|
|
|
|
VerboseMessage " updating $lib2"
|
2007-10-23 09:38:29 -04:00
|
|
|
eval "$cmd ${tool_prefix}install_name_tool -change "$oldname" $install_path/$libname $lib2"
|
2005-11-20 13:11:44 -05:00
|
|
|
done
|
|
|
|
VerboseMessage " updating $libname id"
|
2007-10-23 09:38:29 -04:00
|
|
|
eval "$cmd ${tool_prefix}install_name_tool -id $install_path/$libname $lib"
|
2005-11-20 13:11:44 -05:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
while [ $# -ge 1 ]; do
|
|
|
|
case "$1" in
|
|
|
|
--help|-h)
|
|
|
|
Usage
|
|
|
|
;;
|
|
|
|
|
|
|
|
--dry-run|-n)
|
|
|
|
cmd="echo"
|
|
|
|
;;
|
|
|
|
|
|
|
|
--quiet|-q)
|
|
|
|
quiet=1
|
|
|
|
;;
|
|
|
|
|
|
|
|
--verbose|-v)
|
|
|
|
verbose=1
|
|
|
|
;;
|
|
|
|
|
|
|
|
--libdir=*)
|
|
|
|
if [ -n "$libdir" ]; then
|
|
|
|
GiveUsageErrorAndExit "Multiple --libdir options not allowed."
|
|
|
|
fi
|
|
|
|
libdir=`echo $1 | cut -c10-`
|
|
|
|
;;
|
|
|
|
|
2007-10-23 09:38:29 -04:00
|
|
|
--prefix=*)
|
|
|
|
if [ -n "$tool_prefix" ]; then
|
|
|
|
GiveUsageErrorAndExit "At most one --prefix option can be given."
|
|
|
|
fi
|
|
|
|
tool_prefix=`echo $1 | cut -c10-`
|
|
|
|
;;
|
|
|
|
|
2005-11-20 13:11:44 -05:00
|
|
|
-*)
|
|
|
|
GiveUsageErrorAndExit "Unknown option \"$1\"."
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
if [ -n "$install_path" ]; then
|
|
|
|
GiveUsageErrorAndExit "Too many parameters."
|
|
|
|
fi
|
|
|
|
install_path=$1
|
|
|
|
esac
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z $libdir ]; then
|
|
|
|
libdir=`pwd`
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $install_path ]; then
|
|
|
|
install_path=$libdir
|
|
|
|
fi
|
|
|
|
|
|
|
|
ChangeInstallNames
|
|
|
|
|
|
|
|
exit 0
|