Remove unnecessary copying of PCRE library files - the package template picks them...
[OSXPackageBuilder.git] / build.sh
index 7fb015f..f94ba5e 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -5,7 +5,7 @@
 # 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 2 ]; then
-  echo "Usage: $0 lion | snowleopard64 | snowleopard | leopardupwards | leopard | tiger | panther  [-pcre]"
+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
 
@@ -44,21 +45,42 @@ 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
 
 #
-# set configure options
-#
-OPTS=${OPTS}
-if [ "$2" == "-pcre" ]; then
-       CFLAGS="${CFLAGS} -I/usr/local/include/"
-       LDFLAGS="${LDFLAGS} -L/usr/local/lib"
+# 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
 
 #
@@ -80,10 +102,16 @@ fi
 #
 echo ""
 echo "Notice: configuring the privoxy software."
+# Debugging
+echo "${CFLAGS}"
+echo "${CPPFLAGS}"
+echo "${LDFLAGS}"
+echo "${OPTS}"
 cd ../${SOURCE_DIR}
-/usr/bin/autoheader
-/usr/bin/autoconf
-/usr/bin/env CFLAGS="${CFLAGS} ${SYSROOT} ${ARCH} ${MACOSX_VERSION}" LDFLAGS="${LDFLAGS} ${SYSROOT} ${ARCH} ${MACOSX_VERSION}" ./configure ${OPTS}
+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