Remove unnecessary copying of PCRE library files - the package template picks them...
[OSXPackageBuilder.git] / build.sh
1 #!/bin/sh
2
3 # File        :  build.sh
4 #
5 # Purpose     :  Build the privoxy binary, documentation and config files
6 #                for the chosen target environment
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 # must provide target
37 #
38 if [ $# -eq 0 -o $# -gt 3 ]; then
39   echo "Usage: $0 current | curent-Xcode | lion | snowleopardx64 | snowleopard | snowleopardi386 | leopardupwards | leopard | leopardi386 | leopardppc | tiger | tigeri386 | tigerppc | panther  [-pcre] [-https]"
40   exit 1
41 fi
42
43 #
44 # load common settings
45 #
46 . ./common.sh $1
47
48 # Debugging
49 #echo "${XCODE_PATH}"
50 #echo ${SYSROOT}
51
52 #
53 # must have Xcode
54 #
55 if [ -z ${XCODE_PATH} ]; then
56   echo "Error: Commandline Tools for Xcode is not found."
57   exit 1
58 fi
59
60 #
61 # set configure options based on the parameters passed at the command line
62
63 for option in "$@"
64 do
65         # set pcre library source to dynamic (libpcre - more up to date but requires the external library to exist for compiling) or static (bundled with privoxy - older version)
66         if [ "$option" == "-pcre" ]; then
67                 CFLAGS="${CFLAGS} -I/usr/local/include/"
68                 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
69                 OPTS="${OPTS}"
70         fi
71
72         # enable HTTPS Inspection?
73         if [ "$option" == "-https" ]; then
74                 CFLAGS="${CFLAGS} -I/usr/local/opt/openssl@3/include/"
75                 CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/openssl@3/include/"
76                 LDFLAGS="${LDFLAGS} -L/usr/local/opt/openssl@3/lib"
77                 OPTS="${OPTS} --with-openssl"
78         fi
79 done
80
81 # if we didn't select external PCRE, set option to use the bundled one
82 if [[ "${CFLAGS}" != *"-I/usr/local/include/"* ]]; then
83         OPTS="${OPTS} --disable-dynamic-pcre"
84 fi
85
86 #
87 # check if privoxy group and user exist?
88 #
89 if [ -z ${GNAME} -o -z ${UNAME} ]; then
90   echo ""
91   echo "Error: a privoxy group and user do not exist."
92   echo "A privoxy group and user must be created before continuing."
93   echo "Review the README file for instructions on creating a privoxy group and user."
94   exit 1
95 else
96   echo ""
97   echo "Notice: an existing privoxy group and user was found."
98 fi
99
100 #
101 # configure privoxy
102 #
103 echo ""
104 echo "Notice: configuring the privoxy software."
105 # Debugging
106 echo "${CFLAGS}"
107 echo "${CPPFLAGS}"
108 echo "${LDFLAGS}"
109 echo "${OPTS}"
110 cd ../${SOURCE_DIR}
111 autoheader
112 autoconf
113
114 /usr/bin/env CFLAGS="-O2 -mdynamic-no-pic ${CFLAGS} ${SYSROOT} ${ARCH} ${MACOSX_VERSION}" LDFLAGS="${LDFLAGS} ${SYSROOT} ${ARCH} ${MACOSX_VERSION}" ./configure ${OPTS}
115
116 #
117 # clean, then make privoxy
118 #
119 echo ""
120 echo "Notice: building the privoxy software."
121 /usr/bin/make clean
122 /usr/bin/make
123
124 #
125 # modify config file
126 #
127 /usr/bin/awk '{sub(/logfile.*logfile$/,"logfile logfile.log"); print}' ../${SOURCE_DIR}/config > ../${SOURCE_DIR}/config.tmp
128 /bin/mv ../${SOURCE_DIR}/config.tmp ../${SOURCE_DIR}/config
129