Add HTTPS inspection support
[OSXPackageBuilder.git] / build.sh
index 2f00841..f94ba5e 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -35,8 +35,8 @@
 #
 # must provide target
 #
-if [ $# -eq 0 -o $# -gt 2 ]; then
-  echo "Usage: $0 current | lion | snowleopardx64 | snowleopard | snowleopardi386 | leopardupwards | leopard | leopardi386 | leopardppc | tiger | tigeri386 | tigerppc | 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,6 +44,8 @@ fi
 # load common settings
 #
 . ./common.sh $1
+
+# Debugging
 #echo "${XCODE_PATH}"
 #echo ${SYSROOT}
 
@@ -51,18 +53,33 @@ fi
 # must have Xcode
 #
 if [ -z ${XCODE_PATH} ]; then
-  echo "Error: Xcode is not found."
+  echo "Error: Commandline Tools for Xcode is not found."
   exit 1
 fi
 
 #
-# set configure options; include the appropriate user/group as discerned by common.sh and set pcre to dynamic (libpcre) or static (bundled)
-#
-if [ "$2" == "-pcre" ]; then
-       CFLAGS="${CFLAGS} -I/usr/local/include/"
-       LDFLAGS="${LDFLAGS} -L/usr/local/lib"
-       OPTS=${OPTS}
-else
+# 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
 
@@ -85,6 +102,11 @@ fi
 #
 echo ""
 echo "Notice: configuring the privoxy software."
+# Debugging
+echo "${CFLAGS}"
+echo "${CPPFLAGS}"
+echo "${LDFLAGS}"
+echo "${OPTS}"
 cd ../${SOURCE_DIR}
 autoheader
 autoconf