Yet more expansion of build target options
[OSXPackageBuilder.git] / common.sh
1 #!/bin/sh
2
3 # File        :  common.sh
4 #
5 # Purpose     :  Establish settings common to the build and privoxy-create
6 #                scripts.
7 #
8 # Copyright   :  Written by and Copyright (C) 2001-2012 the
9 #                Privoxy team. http://www.privoxy.org/
10 #
11 #                This program is free software; you can redistribute it
12 #                and/or modify it under the terms of the GNU General
13 #                Public License as published by the Free Software
14 #                Foundation; either version 2 of the License, or (at
15 #                your option) any later version.
16 #
17 #                This program is distributed in the hope that it will
18 #                be useful, but WITHOUT ANY WARRANTY; without even the
19 #                implied warranty of MERCHANTABILITY or FITNESS FOR A
20 #                PARTICULAR PURPOSE.  See the GNU General Public
21 #                License for more details.
22 #
23 #                The GNU General Public License should be included with
24 #                this file.  If not, you can view it at
25 #                http://www.gnu.org/copyleft/gpl.html
26 #                or write to the Free Software Foundation, Inc.,
27 #                51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
28 #                USA
29 #
30 # Modification : If you modify this file please consider whether your 
31 #                changes ought to be passed back to the OSXPackageBuilder
32 #                module.
33 #
34
35 #========================================
36 #  target specific settings
37 #========================================
38
39 #
40 # mac os x release name
41 #
42 release_name=$1
43
44 #
45 # check the release name
46 #
47 case "${release_name}" in
48   # Mac OS X 10.7 (x86_64 only)
49   "lion")
50     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
51     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.7.sdk"
52     MACOSX_VERSION="-mmacosx-version-min=10.7"
53     ARCH="-arch x86_64"
54     STARTUP="LaunchDaemon"
55     ;;
56   # Mac OS X 10.6 x86_64
57   "snowleopardx64")
58     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
59     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.6.sdk"
60     MACOSX_VERSION="-mmacosx-version-min=10.6"
61     ARCH="-arch x86_64"
62     STARTUP="LaunchDaemon"
63     ;;
64   # Mac OS X 10.6 all supported architectures
65   "snowleopard")
66     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
67     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.6.sdk"
68     MACOSX_VERSION="-mmacosx-version-min=10.6"
69     ARCH="-arch x86_64 -arch i386"
70     STARTUP="LaunchDaemon"
71     ;;
72   # Mac OS X 10.6 i386
73   "snowleopardi386")
74     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
75     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.6.sdk"
76     MACOSX_VERSION="-mmacosx-version-min=10.6"
77     ARCH="-arch i386"
78     STARTUP="LaunchDaemon"
79     ;;
80   # Mac OS X 10.5 and all later releases
81   "leopardupwards")
82     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
83     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
84     MACOSX_VERSION="-mmacosx-version-min=10.5"
85     ARCH="-arch x86_64 -arch i386 -arch ppc"
86     STARTUP="LaunchDaemon"
87     ;;
88   # Mac OS X 10.5 all supported architectures
89   "leopard")
90     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
91     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
92     MACOSX_VERSION="-mmacosx-version-min=10.5"
93     ARCH="-arch i386 -arch ppc"
94     STARTUP="LaunchDaemon"
95     ;;
96   # Mac OS X 10.5 i386
97   "leopardi386")
98     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
99     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
100     MACOSX_VERSION="-mmacosx-version-min=10.5"
101     ARCH="-arch i386"
102     STARTUP="LaunchDaemon"
103     ;;
104   # Mac OS X 10.5 PPC
105   "leopardppc")
106     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
107     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
108     MACOSX_VERSION="-mmacosx-version-min=10.5"
109     ARCH="-arch ppc"
110     STARTUP="LaunchDaemon"
111     ;;
112   # Mac OS X 10.4 all supported architectures
113   "tiger")
114     XCODE_PATH="/Developer"
115     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
116     MACOSX_VERSION="-mmacosx-version-min=10.4"
117     ARCH="-arch i386 -arch ppc"
118     STARTUP="LaunchDaemon"
119     ;;
120   # Mac OS X 10.4
121   "tigeri386")
122     XCODE_PATH="/Developer"
123     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
124     MACOSX_VERSION="-mmacosx-version-min=10.4"
125     ARCH="-arch i386"
126     STARTUP="LaunchDaemon"
127     ;;
128   # Mac OS X 10.4
129   "tigerppc")
130     XCODE_PATH="/Developer"
131     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
132     MACOSX_VERSION="-mmacosx-version-min=10.4"
133     ARCH="-arch ppc"
134     STARTUP="LaunchDaemon"
135     ;;
136   # Mac OS X 10.3
137   "panther")
138     XCODE_PATH="/Developer"
139     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.3.9.sdk"
140     MACOSX_VERSION="-mmacosx-version-min=10.3"
141     ARCH="-arch ppc"
142     STARTUP="StartupItem"
143     ;;
144   # default
145   *)
146     XCODE_PATH=""
147     SYSROOT=""
148     MACOSX_VERSION=""
149     ARCH=""
150     STARTUP=""
151     ;;
152 esac
153
154
155 #========================================
156 #  host specific settings
157 #========================================
158
159 #
160 # darwin os major release number
161 #
162 darwin_major_rel_num="`/usr/bin/uname -r | /usr/bin/sed 's/\..*//'`"
163
164 #
165 # check the release number
166 #
167 case "${darwin_major_rel_num}" in
168   # Mac OS X 10.5 or higher
169   9|1*)
170     GNAME="`/usr/bin/dscl /Local/Default -list /groups | /usr/bin/grep -E '^(_)?privoxy?'`"
171     UNAME="`/usr/bin/dscl /Local/Default -list /users | /usr/bin/grep -E '^(_)?privoxy?'`"
172     SCRIPT="privoxy-create-dscl.sh"
173     OPTS="--with-user=_privoxy --with-group=_privoxy"
174     ;;
175   # Mac OS X 10.4, 10.3
176   8|7)
177     GNAME="`/usr/bin/nireport . /groups name | /usr/bin/grep -E '^privoxy?'`"
178     UNAME="`/usr/bin/nireport . /users name | /usr/bin/grep -E '^privoxy?'`"
179     SCRIPT="privoxy-create-nicl.sh"
180     OPTS="--with-user=privoxy --with-group=privoxy"
181     ;;
182   # default
183   *)
184     GNAME=""
185     UNAME=""
186     SCRIPT=""
187     OPTS=""
188     ;;
189 esac
190
191 #
192 # identify the directory containing Privoxy's source
193 #
194 cd ..
195 DIRS_FOUND=0
196 SOURCE_DIR=""
197 if [ -d dist ]; then
198         DIRS_FOUND=1
199 fi
200 if [ -d current ]; then
201         DIRS_FOUND=$(( DIRS_FOUND + 10 ))
202 fi
203 case "${DIRS_FOUND}" in
204         # only 'current' found
205         10)
206                 SOURCE_DIR="current"
207         ;;
208         # only 'dist' found
209         1)
210                 SOURCE_DIR="dist"
211         ;;
212         # either both or neither found
213         11|0)
214                 read -p 'Could not select the Privoxy source directory. Please supply the directory name: ' SOURCE_DIR
215         ;;
216 esac
217 cd OSXPackageBuilder
218 echo "Using ../${SOURCE_DIR} as location of Privoxy source"