Remove unnecessary copying of PCRE library files - the package template picks them...
[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 it varies depending upon whether you have Xcode itself installed or the much smaller Commandline Tools for Xcode
48 #
49 case "${release_name}" in
50   # Mac OS X 10.11-plus (x86_64 only)
51   "current")
52     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
53     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX.sdk"
54     MACOSX_VERSION="-mmacosx-version-min=10.15"
55     ARCH="-arch x86_64"
56     STARTUP="LaunchDaemon"
57     CFLAGS="-mtune=x86_64 ${CFLAGS}"
58     ;;
59   # Mac OS X 10.11-plus (x86_64 only)
60   "current-Xcode")
61     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
62     SYSROOT="-isysroot ${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
63     MACOSX_VERSION="-mmacosx-version-min=10.6"
64     ARCH="-arch x86_64"
65     STARTUP="LaunchDaemon"
66     CFLAGS="-mtune=x86_64 ${CFLAGS}"
67     ;;
68   # Mac OS X 10.7 (x86_64 only)
69   "lion")
70     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
71 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.7.sdk"
72     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.7.sdk"
73     MACOSX_VERSION="-mmacosx-version-min=10.7"
74     ARCH="-arch x86_64"
75     STARTUP="LaunchDaemon"
76     CFLAGS="-mtune=x86_64 ${CFLAGS}"
77     ;;
78   # Mac OS X 10.6 x86_64
79   "snowleopardx64")
80     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
81 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.6.sdk"
82     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.6.sdk"
83     MACOSX_VERSION="-mmacosx-version-min=10.6"
84     ARCH="-arch x86_64"
85     STARTUP="LaunchDaemon"
86     CFLAGS="-mtune=x86_64 ${CFLAGS}"
87     ;;
88   # Mac OS X 10.6 all supported architectures
89   "snowleopard")
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 x86_64 -arch i386"
95     STARTUP="LaunchDaemon"
96     ;;
97   # Mac OS X 10.6 i386
98   "snowleopardi386")
99     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
100 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.6.sdk"
101     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.6.sdk"
102     MACOSX_VERSION="-mmacosx-version-min=10.6"
103     ARCH="-arch i386"
104     STARTUP="LaunchDaemon"
105     CFLAGS="-mtune=i386 ${CFLAGS}"
106     ;;
107   # Mac OS X 10.5 and all later releases
108   "leopardupwards")
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 x86_64 -arch i386 -arch ppc"
114     STARTUP="LaunchDaemon"
115     ;;
116   # Mac OS X 10.5 all supported architectures
117   "leopard")
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 -arch ppc"
123     STARTUP="LaunchDaemon"
124     ;;
125   # Mac OS X 10.5 i386
126   "leopardi386")
127     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
128 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
129     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.5.sdk"
130     MACOSX_VERSION="-mmacosx-version-min=10.5"
131     ARCH="-arch i386"
132     STARTUP="LaunchDaemon"
133     CFLAGS="-mtune=i386 ${CFLAGS}"
134     ;;
135   # Mac OS X 10.5 PPC
136   "leopardppc")
137     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
138 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.5.sdk"
139     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.5.sdk"
140     MACOSX_VERSION="-mmacosx-version-min=10.5"
141     ARCH="-arch ppc"
142     STARTUP="LaunchDaemon"
143     CFLAGS="-mtune=G5 ${CFLAGS}"
144     ;;
145   # Mac OS X 10.4 all supported architectures
146   "tiger")
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 -arch ppc"
152     STARTUP="LaunchDaemon"
153     ;;
154   # Mac OS X 10.4 i386
155   "tigeri386")
156     XCODE_PATH="/Developer"
157 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
158     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.4u.sdk"
159     MACOSX_VERSION="-mmacosx-version-min=10.4"
160     ARCH="-arch i386"
161     STARTUP="LaunchDaemon"
162     CFLAGS="-mtune=i386 ${CFLAGS}"
163     ;;
164   # Mac OS X 10.4 PPC
165   "tigerppc")
166     XCODE_PATH="/Developer"
167 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
168     SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
169     MACOSX_VERSION="-mmacosx-version-min=10.4"
170     ARCH="-arch ppc"
171     STARTUP="LaunchDaemon"
172     CFLAGS="-mtune=G5 ${CFLAGS}"
173     ;;
174   # Mac OS X 10.3 PPC
175   "panther")
176     XCODE_PATH="/Developer"
177 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.3.9.sdk"
178     SYSROOT="-isysroot /Developer/SDKs/MacOSX10.3.9.sdk"
179     MACOSX_VERSION="-mmacosx-version-min=10.3"
180     ARCH="-arch ppc"
181     STARTUP="StartupItem"
182     CFLAGS="-mtune=G5 ${CFLAGS}"
183     ;;
184   # default
185   *)
186     XCODE_PATH=""
187     SYSROOT=""
188     MACOSX_VERSION=""
189     ARCH=""
190     STARTUP=""
191     ;;
192 esac
193
194
195 #========================================
196 #  host specific settings
197 #========================================
198
199 #
200 # darwin os major release number
201 #
202 darwin_major_rel_num="`/usr/bin/uname -r | /usr/bin/sed 's/\..*//'`"
203
204 #
205 # check the release number
206 #
207 case "${darwin_major_rel_num}" in
208   # Mac OS X 10.5 or higher
209   9|1*|2*|3*)
210     GNAME="`/usr/bin/dscl /Local/Default -list /groups | /usr/bin/grep -E '^(_)?privoxy?'`"
211     UNAME="`/usr/bin/dscl /Local/Default -list /users | /usr/bin/grep -E '^(_)?privoxy?'`"
212     SCRIPT="privoxy-create-dscl.sh"
213     OPTS="--with-user=_privoxy --with-group=_privoxy"
214     ;;
215   # Mac OS X 10.4, 10.3
216   8|7)
217     GNAME="`/usr/bin/nireport . /groups name | /usr/bin/grep -E '^privoxy?'`"
218     UNAME="`/usr/bin/nireport . /users name | /usr/bin/grep -E '^privoxy?'`"
219     SCRIPT="privoxy-create-nicl.sh"
220     OPTS="--with-user=privoxy --with-group=privoxy"
221     ;;
222   # default
223   *)
224     GNAME=""
225     UNAME=""
226     SCRIPT=""
227     OPTS=""
228     ;;
229 esac
230
231 #
232 # identify the directory containing Privoxy's source
233 #
234 cd ..
235 DIRS_FOUND=0
236 SOURCE_DIR=""
237
238 if [ -d privoxy ]; then
239         DIRS_FOUND=1
240 fi
241 if [ -d dist ]; then
242         DIRS_FOUND=$(( DIRS_FOUND + 10 ))
243 fi
244 if [ -d current ]; then
245         DIRS_FOUND=$(( DIRS_FOUND + 20 ))
246 fi
247 case "${DIRS_FOUND}" in
248         # only 'current' found
249         20)
250                 SOURCE_DIR="current"
251         ;;
252         # only 'dist' found
253         10)
254                 SOURCE_DIR="dist"
255         ;;
256         # only 'privoxy' found
257         1)
258                 SOURCE_DIR="privoxy"
259         ;;
260         # either multiple or no folder found
261         *)
262                 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. privoxy): ' SOURCE_DIR
263         ;;
264 esac
265 cd OSXPackageBuilder
266 echo "Using ../${SOURCE_DIR} as location of Privoxy source"