# Purpose : Build the privoxy binary, documentation and config files
# for the chosen target environment
#
-# Copyright : Written by and Copyright (C) 2001-2012 the
+# Copyright : Written by and Copyright (C) 2001-2021 the
# Privoxy team. http://www.privoxy.org/
#
# This program is free software; you can redistribute it
# USA
#
# Modification : If you modify this file please consider whether your
-# changes ought to be passed back to the macsetup module.
+# changes ought to be passed back to the OSXPackageBuilder
+# module.
#
#
# must provide target
#
-if [ $# -eq 0 -o $# -gt 1 ]; then
- echo "Usage: $0 lion | snowleopard64 | snowleopard | leopardupwards | leopard | tiger | panther"
+if [ $# -eq 0 -o $# -gt 3 ]; then
+ echo "Usage: $0 current | curent-Xcode | lion | snowleopardx64 | snowleopard | snowleopardi386 | leopardupwards | leopard | leopardi386 | leopardppc | tiger | tigeri386 | tigerppc | panther [-pcre] [-https]"
exit 1
fi
#
. ./common.sh $1
+# Debugging
+#echo "${XCODE_PATH}"
+#echo ${SYSROOT}
+
#
# must have Xcode
#
if [ -z ${XCODE_PATH} ]; then
- echo "Error: this release of Mac OS X not supported."
+ echo "Error: Commandline Tools for Xcode is not found."
exit 1
fi
#
-# use default options
-#
-OPTS=${OPTS}
+# set configure options based on the parameters passed at the command line
+
+for option in "$@"
+do
+ # 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)
+ if [ "$option" == "-pcre" ]; then
+ CFLAGS="${CFLAGS} -I/usr/local/include/"
+ LDFLAGS="${LDFLAGS} -L/usr/local/lib"
+ OPTS="${OPTS}"
+ fi
+
+ # enable HTTPS Inspection?
+ if [ "$option" == "-https" ]; then
+ CFLAGS="${CFLAGS} -I/usr/local/opt/openssl@3/include/"
+ CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/openssl@3/include/"
+ LDFLAGS="${LDFLAGS} -L/usr/local/opt/openssl@3/lib"
+ OPTS="${OPTS} --with-openssl"
+ fi
+done
+
+# if we didn't select external PCRE, set option to use the bundled one
+if [[ "${CFLAGS}" != *"-I/usr/local/include/"* ]]; then
+ OPTS="${OPTS} --disable-dynamic-pcre"
+fi
#
# check if privoxy group and user exist?
#
echo ""
echo "Notice: configuring the privoxy software."
-cd ../current
-/usr/bin/autoheader
-/usr/bin/autoconf
-/usr/bin/env CFLAGS="${CFLAGS} ${SYSROOT} ${ARCH} ${MACOSX_VERSION}" LDFLAGS="${LDFLAGS} ${SYSROOT} ${ARCH} ${MACOSX_VERSION}" ./configure ${OPTS}
+# Debugging
+echo "${CFLAGS}"
+echo "${CPPFLAGS}"
+echo "${LDFLAGS}"
+echo "${OPTS}"
+cd ../${SOURCE_DIR}
+autoheader
+autoconf
+
+/usr/bin/env CFLAGS="-O2 -mdynamic-no-pic ${CFLAGS} ${SYSROOT} ${ARCH} ${MACOSX_VERSION}" LDFLAGS="${LDFLAGS} ${SYSROOT} ${ARCH} ${MACOSX_VERSION}" ./configure ${OPTS}
#
# clean, then make privoxy
#
# modify config file
#
-/usr/bin/awk '{sub(/logfile.*logfile$/,"logfile logfile.log"); print}' ../current/config > ../current/config.tmp
-/bin/mv ../current/config.tmp ../current/config
+/usr/bin/awk '{sub(/logfile.*logfile$/,"logfile logfile.log"); print}' ../${SOURCE_DIR}/config > ../${SOURCE_DIR}/config.tmp
+/bin/mv ../${SOURCE_DIR}/config.tmp ../${SOURCE_DIR}/config