File: osx-build-wx

package info (click to toggle)
passwordsafe 1.12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 25,980 kB
  • sloc: cpp: 67,939; ansic: 1,696; makefile: 584; perl: 459; sh: 240; xml: 210; javascript: 40
file content (230 lines) | stat: -rwxr-xr-x 7,052 bytes parent folder | download | duplicates (4)
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/sh
#
# This script is used to build wxWidgets on Mac OS X in a way that pwsafe 
# will run on as many MacOS versions as possible when built on that machine.
# That also means the wxWidgets build generated by this script would depend
# on the compilers and SDKs supported on the version of OS X it is running on.
# 
# If was initially written for building wx2.8 on Snow Leopard such that the 
# pwsafe binary would run on OS X 10.4+.  It followed the documentation here:
#   http://wiki.wxwidgets.org/Development:_wxMac
#
# See the sections "Building on Snow Leopard for Snow Leopard" and
# "Building on Snow Leopard for Snow Leopard"
#

# Build release configuration by default
DEBUG_FLAG=--disable-debug

# If unspecified, assume the user is building wxWidgets inside a subdir of its root dir
CONF_SCRIPT=../configure

# GUI toolkit to use.  Could be "carbon" or "cocoa".
TOOLKIT=undefined

# In a dry run, we just echo the commands
DRY_RUN=

# The 10.4 SDK path, if not in the default location (i.e. /Developer/SDKs/MacOSX10.4u.sdk/
SDKPATH=

# This is where gcc, g++ and ld required to build with 10.4 SDK should be
TOOLCHAIN_DIR=

usage() {
    cat <<__END_USAGE__

`basename $1`: Runs wxWidgets configure script appropriately for building pwsafe
              You then run make to actually build it

Usage (all flags are optional):
	-d
	    Create Debug configuration.  Absence of this flag creates the Release configuration

	-c <path to wxWidgets configure script>
	    Default is to assume it is in the parent directory of current dir

	-t (carbon|cocoa)
	    The OS X GUI toolkit to be used, either "carbon" or "cocoa".  wx2.8 only supports carbon

	-n
	    Dry run.  Will just echo the command(s) to be used to build wxWidgets

	-k <SDK directory path>
	    You can get the path to any installed SDK that Xcode is aware of like this
	    xcodebuild -version -sdk macosx10.9 Path

	-t <toolchain dir>
	    Directory where gcc-4.0, g++4.0, etc. should be.  Only required for building wx2.8 on OS X 10.9
__END_USAGE__
}

error() {
	echo "$*" 1>&2
	exit 1
}

while getopts "dc:t:nk:t:" opt; do
	case $opt in
		d)
			DEBUG_FLAG=--enable-debug
			;;
		c)
			if [ -x $OPTARG ]
			then
				CONF_SCRIPT=$OPTARG
			else
				error Missing or non-executable configure script: $OPTARG
			fi
			;;
		t)
			case "$OPTARG" in
				carbon) TOOLKIT=CARBON;;
				cocoa)  TOOLKIT=COCOA;;
				*)      error Unexpected toolkit: $OPTARG. Its either \"carbon\" or \"cocoa\" \(default\) 1>&2
						;;
			esac
			;;	
        k)
            if [ -d $OPTARG ]
            then
                SDKPATH=$OPTARG
            else
				error Invalid directory passed for SDK path: $OPTARG
            fi
            ;;
        t)
            if [ -d $OPTARG ]
            then
                TOOLCHAIN_DIR=$OPTARG
            else
				error Invalid directory passed for toolchain dir: $OPTARG
            fi
            ;;
		n)
			DRY_RUN="echo "
			;;
		?)
            usage $0
			exit 1
			;;
	esac
done

WX_VER=`$CONF_SCRIPT -V | grep 'wxWidgets configure' | cut -d' ' -f3`

# This might be required for 10.7 & 10.8 as well
OSX_VER=`sw_vers -productVersion`
if [ "$OSX_VER" = "10.9" -o "$OSX_VER" \> "10.9" ]
then
    if [ -z "$TOOLCHAIN_DIR" ]
    then
        # This is where gcc-4.x etc. will be found
        TOOLCHAIN_DIR=/Developer/usr/bin
    fi
fi

doCarbonBuild() {

    if [ -z "$SDKPATH" ]
    then
        SDKPATH=/Developer/SDKs/MacOSX10.4u.sdk
    fi

    if [ ! -d "$SDKPATH" ]
    then
        error "You must specify a valid SDK directory with Carbon headers/libs for building wxWidgets version $WX_VER on OS X $OSX_VER"
    fi

    CC=gcc-4.0
    CXX=g++-4.0
    LD=g++-4.0

    if [ -n "$TOOLCHAIN_DIR" ]
    then
        CC=$TOOLCHAIN_DIR/$CC
        CXX=$TOOLCHAIN_DIR/$CXX
        LD=$TOOLCHAIN_DIR/$LD
    fi

	# There is only one way to build wx2.8.  It doesn't require a "toolkit" flag
    # see http://wiki.wxwidgets.org/Development:_wxMac#Building_under_10.6_Snow_Leopard
    MIN_OSX_VER=`/usr/libexec/PlistBuddy -c "Print :DefaultProperties:MACOSX_DEPLOYMENT_TARGET" $SDKPATH/SDKSettings.plist`

    arch_flags="-arch i386 -arch ppc"
    sdk_flags="-mmacosx-version-min=$MIN_OSX_VER -isysroot $SDKPATH"

    CFLAGS="     $arch_flags $sdk_flags"
    CXXFLAGS="   $arch_flags $sdk_flags"
    CPPFLAGS="               $sdk_flags"
    OBJCFLAGS="  $arch_flags $sdk_flags"
    OBJCXXFLAGS="$arch_flags $sdk_flags"

	$DRY_RUN $CONF_SCRIPT --prefix=`pwd`                \
                            CC=$CC                      \
                            CXX=$CXX                    \
                            LD=$LD                      \
                            CFLAGS="$CFLAGS"            \
                            CXXFLAGS="$CXXFLAGS"        \
                            CPPFLAGS="$CPPFLAGS"        \
                            LDFLAGS="$arch_flags"       \
                            OBJCFLAGS="$OBJCFLAGS"      \
                            OBJCXXFLAGS="$OBJCXXFLAGS"  \
                            $DEBUG_FLAG                 \
                            --disable-shared            \
                            --disable-compat24          \
                            --enable-unicode            \
                            --enable-universal-binary   \
                            --with-osx_carbon           \
                            --with-macosx-sdk=$SDKPATH  \
                            --with-macosx-version-min=$MIN_OSX_VER
}

if [ "$WX_VER" \< "2.9.0" ]
then
	echo Building wxWidgets 2.8.X \(or earlier\): $WX_VER on OSX $OSX_VER
	if [ "$TOOLKIT" = "COCOA" ]
	then
		error wxWidgets $WX_VER does not support Cocoa
    else
        doCarbonBuild
	fi

else
	echo Building wxWidgets 2.9.X \(or later\): $WX_VER on OSX $OSX_VER

	if [ "$TOOLKIT" = "CARBON" ]
	then
        echo Please let PasswordSafe devs know why supporting carbon builds of wx2.9+ makes sense
        doCarbonBuild
    else

        # This is about the only cocoa build customization we support because everything
        # else is taken care of via "deployment target" in pwsafe-xcode5.xcodeproj
        SDKFLAG=
        if [ -n "$SDKPATH" ]
        then
            SDKFLAG="--with-macosx-sdk=$SDKPATH"
        fi

        # This is required for C++14
        export CC=clang
        export CPP="clang -E"
        export CXX=clang++
        export CXXCPP="clang++ -E"
        export CXXFLAGS="-std=c++1y -stdlib=libc++"
        export OBJCXXFLAGS="-std=c++1y -stdlib=libc++"
        export LDFLAGS=-stdlib=libc++

        $DRY_RUN $CONF_SCRIPT --prefix=`pwd` $DEBUG_FLAG        \
                              $SDKFLAG                          \
                              --with-osx_cocoa                  \
                              --disable-shared                  \
                              --disable-compat24                \
                              --enable-unicode                  \
                              --with-macosx-version-min=10.7    \
                              --without-liblzma
	fi
fi