Installation package text updates for 3.0.22 release
[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-2021 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 and assign the build variables accordingly
46 #
47 # NOTE: SYSROOT ought to be programmatically determined using XCODE_PATH, however since upgrading my build environment to El Capitan xcode-select returns a non-useful path, hence I am forced to set the SYSROOT explicitly for my build environment, which is now a hybrid of XCode 3.2.6 'running' on OS X 10.11. I am not going to risk upgrading XCode for fear of losing the ability to target down-level OS X versions.
48 #
49 case "${release_name}" in
50   # Mac OS X 10.11 (x86_64 only)
51   "current")
52     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
53     SYSROOT="-isysroot ${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk"
54     MACOSX_VERSION="-mmacosx-version-min=10.6"
55     ARCH="-arch x86_64"
56     STARTUP="LaunchDaemon"
57     CFLAGS="-mtune=x86_64 ${CFLAGS}"
58     ;;
59   # Mac OS X 10.7 (x86_64 only)
60   "lion")
61     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
62 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.7.sdk"
63     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.7.sdk"
64     MACOSX_VERSION="-mmacosx-version-min=10.7"
65     ARCH="-arch x86_64"
66     STARTUP="LaunchDaemon"
67     CFLAGS="-mtune=x86_64 ${CFLAGS}"
68     ;;
69   # Mac OS X 10.6 x86_64
70   "snowleopardx64")
71     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
72 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.6.sdk"
73     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.6.sdk"
74     MACOSX_VERSION="-mmacosx-version-min=10.6"
75     ARCH="-arch x86_64"
76     STARTUP="LaunchDaemon"
77     CFLAGS="-mtune=x86_64 ${CFLAGS}"
78     ;;
79   # Mac OS X 10.6 all supported architectures
80   "snowleopard")
81     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
82 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.6.sdk"
83     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.6.sdk"
84     MACOSX_VERSION="-mmacosx-version-min=10.6"
85     ARCH="-arch x86_64 -arch i386"
86     STARTUP="LaunchDaemon"
87     ;;
88   # Mac OS X 10.6 i386
89   "snowleopardi386")
90     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
91 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.6.sdk"
92     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.6.sdk"
93     MACOSX_VERSION="-mmacosx-version-min=10.6"
94     ARCH="-arch i386"
95     STARTUP="LaunchDaemon"
96     CFLAGS="-mtune=i386 ${CFLAGS}"
97     ;;
98   # Mac OS X 10.5 and all later releases
99   "leopardupwards")
100     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
101 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
102     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.5.sdk"
103     MACOSX_VERSION="-mmacosx-version-min=10.5"
104     ARCH="-arch x86_64 -arch i386 -arch ppc"
105     STARTUP="LaunchDaemon"
106     ;;
107   # Mac OS X 10.5 all supported architectures
108   "leopard")
109     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
110 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
111     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.5.sdk"
112     MACOSX_VERSION="-mmacosx-version-min=10.5"
113     ARCH="-arch i386 -arch ppc"
114     STARTUP="LaunchDaemon"
115     ;;
116   # Mac OS X 10.5 i386
117   "leopardi386")
118     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
119 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
120     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.5.sdk"
121     MACOSX_VERSION="-mmacosx-version-min=10.5"
122     ARCH="-arch i386"
123     STARTUP="LaunchDaemon"
124     CFLAGS="-mtune=i386 ${CFLAGS}"
125     ;;
126   # Mac OS X 10.5 PPC
127   "leopardppc")
128     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
129 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
130     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.5.sdk"
131     MACOSX_VERSION="-mmacosx-version-min=10.5"
132     ARCH="-arch ppc"
133     STARTUP="LaunchDaemon"
134     CFLAGS="-mtune=G5 ${CFLAGS}"
135     ;;
136   # Mac OS X 10.4 all supported architectures
137   "tiger")
138     XCODE_PATH="/Developer"
139 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
140     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
141     MACOSX_VERSION="-mmacosx-version-min=10.4"
142     ARCH="-arch i386 -arch ppc"
143     STARTUP="LaunchDaemon"
144     ;;
145   # Mac OS X 10.4 i386
146   "tigeri386")
147     XCODE_PATH="/Developer"
148 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
149     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
150     MACOSX_VERSION="-mmacosx-version-min=10.4"
151     ARCH="-arch i386"
152     STARTUP="LaunchDaemon"
153     CFLAGS="-mtune=i386 ${CFLAGS}"
154     ;;
155   # Mac OS X 10.4 PPC
156   "tigerppc")
157     XCODE_PATH="/Developer"
158 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
159     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
160     MACOSX_VERSION="-mmacosx-version-min=10.4"
161     ARCH="-arch ppc"
162     STARTUP="LaunchDaemon"
163     CFLAGS="-mtune=G5 ${CFLAGS}"
164     ;;
165   # Mac OS X 10.3 PPC
166   "panther")
167     XCODE_PATH="/Developer"
168 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.3.9.sdk"
169     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.3.9.sdk"
170     MACOSX_VERSION="-mmacosx-version-min=10.3"
171     ARCH="-arch ppc"
172     STARTUP="StartupItem"
173     CFLAGS="-mtune=G5 ${CFLAGS}"
174     ;;
175   # default
176   *)
177     XCODE_PATH=""
178     SYSROOT=""
179     MACOSX_VERSION=""
180     ARCH=""
181     STARTUP=""
182     ;;
183 esac
184
185
186 #========================================
187 #  host specific settings
188 #========================================
189
190 #
191 # darwin os major release number
192 #
193 darwin_major_rel_num="`/usr/bin/uname -r | /usr/bin/sed 's/\..*//'`"
194
195 #
196 # check the release number
197 #
198 case "${darwin_major_rel_num}" in
199   # Mac OS X 10.5 or higher
200   9|1*)
201     GNAME="`/usr/bin/dscl /Local/Default -list /groups | /usr/bin/grep -E '^(_)?privoxy?'`"
202     UNAME="`/usr/bin/dscl /Local/Default -list /users | /usr/bin/grep -E '^(_)?privoxy?'`"
203     SCRIPT="privoxy-create-dscl.sh"
204     OPTS="--with-user=_privoxy --with-group=_privoxy"
205     ;;
206   # Mac OS X 10.4, 10.3
207   8|7)
208     GNAME="`/usr/bin/nireport . /groups name | /usr/bin/grep -E '^privoxy?'`"
209     UNAME="`/usr/bin/nireport . /users name | /usr/bin/grep -E '^privoxy?'`"
210     SCRIPT="privoxy-create-nicl.sh"
211     OPTS="--with-user=privoxy --with-group=privoxy"
212     ;;
213   # default
214   *)
215     GNAME=""
216     UNAME=""
217     SCRIPT=""
218     OPTS=""
219     ;;
220 esac
221
222 #
223 # identify the directory containing Privoxy's source
224 #
225 cd ..
226 DIRS_FOUND=0
227 SOURCE_DIR=""
228 if [ -d dist ]; then
229         DIRS_FOUND=1
230 fi
231 if [ -d current ]; then
232         DIRS_FOUND=$(( DIRS_FOUND + 10 ))
233 fi
234 case "${DIRS_FOUND}" in
235         # only 'current' found
236         10)
237                 SOURCE_DIR="current"
238         ;;
239         # only 'dist' found
240         1)
241                 SOURCE_DIR="dist"
242         ;;
243         # either both or neither found
244         11|0)
245                 read -p 'Could not select the Privoxy source directory (it should be in a directory parallel to that containing this build script). Please supply the directory name (e.g. current or dist): ' SOURCE_DIR
246         ;;
247 esac
248 cd OSXPackageBuilder
249 echo "Using ../${SOURCE_DIR} as location of Privoxy source"