File: set_install_name

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (149 lines) | stat: -rwxr-xr-x 3,642 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/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=
tool_prefix=
install_path=
cmd=

Usage()
{
    name=`basename $0`
    cat 1>&2 <<EOF
Usage: $name [OPTIONS] [--prefix=PFX] [--libdir=DIR] [install_path]

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).

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-".

    -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:
 * do "$name --libdir=MyApp.app/Contents/Frameworks @executable_path/../Frameworks"
   when distributing wxWidgets shared libraries with application MyApp
 * run "$name" without parameters in the directory containing wxWidgets libraries
   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
    all_libs=`find "$libdir" -type f -name libwx_\*.dylib`
    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`
        oldname=`${tool_prefix}otool -D $lib | tail -1`
        Message "Updating install name of and references to $libname:"
        for lib2 in $all_libs; do
            VerboseMessage "    updating $lib2"
            eval "$cmd ${tool_prefix}install_name_tool -change "$oldname" $install_path/$libname $lib2"
        done
        VerboseMessage "    updating $libname id"
        eval "$cmd ${tool_prefix}install_name_tool -id $install_path/$libname $lib"
    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-`
            ;;

        --prefix=*)
            if [ -n "$tool_prefix" ]; then
                GiveUsageErrorAndExit "At most one --prefix option can be given."
            fi
            tool_prefix=`echo $1 | cut -c10-`
            ;;

        -*)
            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