Add HTTPS inspection support
[OSXPackageBuilder.git] / common.sh
index 44918b0..661b82e 100755 (executable)
--- a/common.sh
+++ b/common.sh
@@ -5,7 +5,7 @@
 # Purpose     :  Establish settings common to the build and privoxy-create
 #                scripts.
 #
-# 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
@@ -44,9 +44,27 @@ release_name=$1
 #
 # check the release name and assign the build variables accordingly
 #
-# NOTE: SYSROOT ought to be programmatically determined using XCODE_PATH, however since upgrading my build environment to El Capitan xcode-select returns a non-useful path, hence I am forced to set the SYSROOT explicitly for my build environment, which is now a hybrid of XCode 3.2.6 'running' on OS X 10.11. I am not going to risk upgrading XCode for fear of losing the ability to target down-level OS X versions.
+# 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
 #
 case "${release_name}" in
+  # Mac OS X 10.11-plus (x86_64 only)
+  "current")
+    XCODE_PATH="`/usr/bin/xcode-select -print-path`"
+    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX.sdk"
+    MACOSX_VERSION="-mmacosx-version-min=10.15"
+    ARCH="-arch x86_64"
+    STARTUP="LaunchDaemon"
+    CFLAGS="-mtune=x86_64 ${CFLAGS}"
+    ;;
+  # Mac OS X 10.11-plus (x86_64 only)
+  "current-Xcode")
+    XCODE_PATH="`/usr/bin/xcode-select -print-path`"
+    SYSROOT="-isysroot ${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
+    MACOSX_VERSION="-mmacosx-version-min=10.6"
+    ARCH="-arch x86_64"
+    STARTUP="LaunchDaemon"
+    CFLAGS="-mtune=x86_64 ${CFLAGS}"
+    ;;
   # Mac OS X 10.7 (x86_64 only)
   "lion")
     XCODE_PATH="`/usr/bin/xcode-select -print-path`"
@@ -55,6 +73,7 @@ case "${release_name}" in
     MACOSX_VERSION="-mmacosx-version-min=10.7"
     ARCH="-arch x86_64"
     STARTUP="LaunchDaemon"
+    CFLAGS="-mtune=x86_64 ${CFLAGS}"
     ;;
   # Mac OS X 10.6 x86_64
   "snowleopardx64")
@@ -64,6 +83,7 @@ case "${release_name}" in
     MACOSX_VERSION="-mmacosx-version-min=10.6"
     ARCH="-arch x86_64"
     STARTUP="LaunchDaemon"
+    CFLAGS="-mtune=x86_64 ${CFLAGS}"
     ;;
   # Mac OS X 10.6 all supported architectures
   "snowleopard")
@@ -82,6 +102,7 @@ case "${release_name}" in
     MACOSX_VERSION="-mmacosx-version-min=10.6"
     ARCH="-arch i386"
     STARTUP="LaunchDaemon"
+    CFLAGS="-mtune=i386 ${CFLAGS}"
     ;;
   # Mac OS X 10.5 and all later releases
   "leopardupwards")
@@ -109,6 +130,7 @@ case "${release_name}" in
     MACOSX_VERSION="-mmacosx-version-min=10.5"
     ARCH="-arch i386"
     STARTUP="LaunchDaemon"
+    CFLAGS="-mtune=i386 ${CFLAGS}"
     ;;
   # Mac OS X 10.5 PPC
   "leopardppc")
@@ -118,6 +140,7 @@ case "${release_name}" in
     MACOSX_VERSION="-mmacosx-version-min=10.5"
     ARCH="-arch ppc"
     STARTUP="LaunchDaemon"
+    CFLAGS="-mtune=G5 ${CFLAGS}"
     ;;
   # Mac OS X 10.4 all supported architectures
   "tiger")
@@ -128,7 +151,7 @@ case "${release_name}" in
     ARCH="-arch i386 -arch ppc"
     STARTUP="LaunchDaemon"
     ;;
-  # Mac OS X 10.4
+  # Mac OS X 10.4 i386
   "tigeri386")
     XCODE_PATH="/Developer"
 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
@@ -136,8 +159,9 @@ case "${release_name}" in
     MACOSX_VERSION="-mmacosx-version-min=10.4"
     ARCH="-arch i386"
     STARTUP="LaunchDaemon"
+    CFLAGS="-mtune=i386 ${CFLAGS}"
     ;;
-  # Mac OS X 10.4
+  # Mac OS X 10.4 PPC
   "tigerppc")
     XCODE_PATH="/Developer"
 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.4u.sdk"
@@ -145,8 +169,9 @@ case "${release_name}" in
     MACOSX_VERSION="-mmacosx-version-min=10.4"
     ARCH="-arch ppc"
     STARTUP="LaunchDaemon"
+    CFLAGS="-mtune=G5 ${CFLAGS}"
     ;;
-  # Mac OS X 10.3
+  # Mac OS X 10.3 PPC
   "panther")
     XCODE_PATH="/Developer"
 #    SYSROOT="-isysroot ${XCODE_PATH}/SDKs/MacOSX10.3.9.sdk"
@@ -154,6 +179,7 @@ case "${release_name}" in
     MACOSX_VERSION="-mmacosx-version-min=10.3"
     ARCH="-arch ppc"
     STARTUP="StartupItem"
+    CFLAGS="-mtune=G5 ${CFLAGS}"
     ;;
   # default
   *)
@@ -180,7 +206,7 @@ darwin_major_rel_num="`/usr/bin/uname -r | /usr/bin/sed 's/\..*//'`"
 #
 case "${darwin_major_rel_num}" in
   # Mac OS X 10.5 or higher
-  9|1*)
+  9|1*|2*|3*)
     GNAME="`/usr/bin/dscl /Local/Default -list /groups | /usr/bin/grep -E '^(_)?privoxy?'`"
     UNAME="`/usr/bin/dscl /Local/Default -list /users | /usr/bin/grep -E '^(_)?privoxy?'`"
     SCRIPT="privoxy-create-dscl.sh"
@@ -208,25 +234,33 @@ esac
 cd ..
 DIRS_FOUND=0
 SOURCE_DIR=""
-if [ -d dist ]; then
+
+if [ -d privoxy ]; then
        DIRS_FOUND=1
 fi
-if [ -d current ]; then
+if [ -d dist ]; then
        DIRS_FOUND=$(( DIRS_FOUND + 10 ))
 fi
+if [ -d current ]; then
+       DIRS_FOUND=$(( DIRS_FOUND + 20 ))
+fi
 case "${DIRS_FOUND}" in
        # only 'current' found
-       10)
+       20)
                SOURCE_DIR="current"
        ;;
        # only 'dist' found
-       1)
+       10)
                SOURCE_DIR="dist"
        ;;
-       # either both or neither found
-       11|0)
-               read -p 'Could not select the Privoxy source directory. Please supply the directory name (e.g. current or dist): ' SOURCE_DIR
+       # only 'privoxy' found
+       1)
+               SOURCE_DIR="privoxy"
+       ;;
+       # either multiple or no folder found
+       *)
+               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
        ;;
 esac
 cd OSXPackageBuilder
-echo "Using ../${SOURCE_DIR} as location of Privoxy source"
\ No newline at end of file
+echo "Using ../${SOURCE_DIR} as location of Privoxy source"