diff options
Diffstat (limited to 'tools/macos-setup.sh')
-rwxr-xr-x | tools/macos-setup.sh | 2118 |
1 files changed, 1201 insertions, 917 deletions
diff --git a/tools/macos-setup.sh b/tools/macos-setup.sh index 0017ffcf..13cb4547 100755 --- a/tools/macos-setup.sh +++ b/tools/macos-setup.sh @@ -10,29 +10,31 @@ # # SPDX-License-Identifier: GPL-2.0-or-later +set -e + shopt -s extglob # # Get the major version of Darwin, so we can check the major macOS # version. # -DARWIN_MAJOR_VERSION=`uname -r | sed 's/\([0-9]*\).*/\1/'` +DARWIN_MAJOR_VERSION=$(uname -r | sed 's/\([0-9]*\).*/\1/') # -# The minimum supported version of Qt is 5.9, so the minimum supported version -# of macOS is OS X 10.10 (Yosemite), aka Darwin 14.0. +# The minimum supported version of Qt is 5.11, so the minimum supported version +# of macOS is OS X 10.11 (El Capitan), aka Darwin 15.0. # -if [[ $DARWIN_MAJOR_VERSION -lt 14 ]]; then - echo "This script does not support any versions of macOS before Yosemite" 1>&2 +if [[ $DARWIN_MAJOR_VERSION -lt 15 ]]; then + echo "This script does not support any versions of macOS before El Capitan" 1>&2 exit 1 fi # # Get the processor architecture of Darwin. Currently supported: arm, i386 # -DARWIN_PROCESSOR_ARCH=`uname -p` +DARWIN_PROCESSOR_ARCH=$(uname -m) -if [ "$DARWIN_PROCESSOR_ARCH" != "arm" -a "$DARWIN_PROCESSOR_ARCH" != "i386" ]; then +if [ "$DARWIN_PROCESSOR_ARCH" != "arm64" ] && [ "$DARWIN_PROCESSOR_ARCH" != "x86_64" ]; then echo "This script does not support this processor architecture" 1>&2 exit 1 fi @@ -43,18 +45,19 @@ fi # # We use curl, but older versions of curl in older macOS releases can't -# handle some sites - including the xz site. +# handle some sites - including the xz site. We also use the --fail-with-body +# flag, which was added in curl 7.76.0. # -# If the version of curl in the system is older than 7.54.0, download +# If the version of curl in the system is older than 7.76.0, download # curl and install it. # -current_curl_version=`curl --version | sed -n 's/curl \([0-9.]*\) .*/\1/p'` -current_curl_major_version="`expr $current_curl_version : '\([0-9][0-9]*\).*'`" -current_curl_minor_version="`expr $current_curl_version : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" +current_curl_version=$( curl --version | sed -n 's/curl \([0-9.]*\) .*/\1/p' ) +current_curl_major_version="$( expr "$current_curl_version" : '\([0-9][0-9]*\).*' )" +current_curl_minor_version="$(expr "$current_curl_version" : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" if [[ $current_curl_major_version -lt 7 || ($current_curl_major_version -eq 7 && $current_curl_minor_version -lt 54) ]]; then - CURL_VERSION=${CURL_VERSION-7.60.0} + CURL_VERSION=${CURL_VERSION-7.88.1} fi # @@ -73,17 +76,6 @@ fi XZ_VERSION=5.2.5 # -# Some packages need lzip to unpack their current source. -# -LZIP_VERSION=1.21 - -# -# The version of libPCRE on Catalina is insufficient to build glib due to -# missing UTF-8 support. -# -PCRE_VERSION=8.45 - -# # CMake is required to do the build - and to build some of the # dependencies. # @@ -94,29 +86,31 @@ CMAKE_VERSION=${CMAKE_VERSION-3.21.4} # claimed to build faster than make. # Comment it out if you don't want it. # -NINJA_VERSION=${NINJA_VERSION-1.10.2} +NINJA_VERSION=${NINJA_VERSION-1.12.1} +NINJA_SHA256=89a287444b5b3e98f88a945afa50ce937b8ffd1dcc59c555ad9b1baf855298c9 # # The following libraries and tools are required even to build only TShark. # -GETTEXT_VERSION=0.21 -GLIB_VERSION=2.76.6 +GETTEXT_VERSION=0.22.5 +GLIB_VERSION=2.80.3 if [ "$GLIB_VERSION" ]; then - GLIB_MAJOR_VERSION="`expr $GLIB_VERSION : '\([0-9][0-9]*\).*'`" - GLIB_MINOR_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" - GLIB_DOTDOT_VERSION="`expr $GLIB_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`" - GLIB_MAJOR_MINOR_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION - GLIB_MAJOR_MINOR_DOTDOT_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_DOTDOT_VERSION + GLIB_MAJOR_VERSION="$( expr $GLIB_VERSION : '\([0-9][0-9]*\).*' )" + GLIB_MINOR_VERSION="$( expr $GLIB_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" +# Unused? +# GLIB_DOTDOT_VERSION="$( expr $GLIB_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*' )" +# GLIB_MAJOR_MINOR_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION +# GLIB_MAJOR_MINOR_DOTDOT_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_DOTDOT_VERSION fi PKG_CONFIG_VERSION=0.29.2 # # libgpg-error is required for libgcrypt. # -LIBGPG_ERROR_VERSION=1.39 +LIBGPG_ERROR_VERSION=1.47 # # libgcrypt is required. # -LIBGCRYPT_VERSION=1.8.7 +LIBGCRYPT_VERSION=1.10.2 # # libpcre2 is required. # @@ -135,9 +129,9 @@ PCRE2_VERSION=10.39 QT_VERSION=${QT_VERSION-6.2.4} if [ "$QT_VERSION" ]; then - QT_MAJOR_VERSION="`expr $QT_VERSION : '\([0-9][0-9]*\).*'`" - QT_MINOR_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" - QT_DOTDOT_VERSION="`expr $QT_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`" + QT_MAJOR_VERSION="$( expr "$QT_VERSION" : '\([0-9][0-9]*\).*' )" + QT_MINOR_VERSION="$( expr "$QT_VERSION" : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" + QT_DOTDOT_VERSION="$( expr "$QT_VERSION" : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*' )" QT_MAJOR_MINOR_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION QT_MAJOR_MINOR_DOTDOT_VERSION=$QT_MAJOR_VERSION.$QT_MINOR_VERSION.$QT_DOTDOT_VERSION fi @@ -148,15 +142,16 @@ fi # the optional libraries are required by other optional libraries. # LIBSMI_VERSION=0.4.8 -GNUTLS_VERSION=3.7.8 +GNUTLS_VERSION=3.8.4 +GNUTLS_SHA256=2bea4e154794f3f00180fa2a5c51fe8b005ac7a31cd58bd44cdfa7f36ebc3a9b if [ "$GNUTLS_VERSION" ]; then # # We'll be building GnuTLS, so we may need some additional libraries. # We assume GnuTLS can work with Nettle; newer versions *only* use # Nettle, not libgcrypt. # - GNUTLS_MAJOR_VERSION="`expr $GNUTLS_VERSION : '\([0-9][0-9]*\).*'`" - GNUTLS_MINOR_VERSION="`expr $GNUTLS_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" + GNUTLS_MAJOR_VERSION="$( expr $GNUTLS_VERSION : '\([0-9][0-9]*\).*' )" + GNUTLS_MINOR_VERSION="$( expr $GNUTLS_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" NETTLE_VERSION=3.9.1 # @@ -166,27 +161,28 @@ if [ "$GNUTLS_VERSION" ]; then # # And p11-kit - P11KIT_VERSION=0.25.0 + P11KIT_VERSION=0.25.3 # Which requires libtasn1 LIBTASN1_VERSION=4.19.0 fi -# Use 5.2.4, not 5.3, for now; lua_bitop.c hasn't been ported to 5.3 -# yet, and we need to check for compatibility issues (we'd want Lua -# scripts to work with 5.1, 5.2, and 5.3, as long as they only use Lua -# features present in all three versions) -LUA_VERSION=5.2.4 -SNAPPY_VERSION=1.1.10 -ZSTD_VERSION=1.5.5 +# lua_bitop.c has been ported to 5.3 and 5.4 so use the latest release. +# We may still need to check for compatibility issues (we'd want Lua +# scripts to work with 5.1 through 5.4, as long as they only use Lua +# features present in all versions) +LUA_VERSION=5.4.6 +SNAPPY_VERSION=1.2.1 +ZSTD_VERSION=1.5.6 +ZLIBNG_VERSION=2.1.6 LIBXML2_VERSION=2.11.5 LZ4_VERSION=1.9.4 SBC_VERSION=2.0 -CARES_VERSION=1.19.1 +CARES_VERSION=1.31.0 LIBSSH_VERSION=0.10.5 # mmdbresolve -MAXMINDDB_VERSION=1.4.3 -NGHTTP2_VERSION=1.56.0 -NGHTTP3_VERSION=0.15.0 +MAXMINDDB_VERSION=1.9.1 +NGHTTP2_VERSION=1.62.1 +NGHTTP3_VERSION=1.1.0 SPANDSP_VERSION=0.0.6 SPEEXDSP_VERSION=1.2.1 if [ "$SPANDSP_VERSION" ]; then @@ -198,8 +194,19 @@ fi BCG729_VERSION=1.1.1 # libilbc 3.0.0 & later link with absiel, which is released under Apache 2.0 ILBC_VERSION=2.0.2 +OPENCORE_AMR_VERSION=0.1.6 +OPENCORE_AMR_SHA256=483eb4061088e2b34b358e47540b5d495a96cd468e361050fae615b1809dc4a1 OPUS_VERSION=1.4 +# Falco libs (libsinsp and libscap) and their dependencies. Unset for now. +#FALCO_LIBS_VERSION=0.17.1 +if [ "$FALCO_LIBS_VERSION" ] ; then + JSONCPP_VERSION=1.9.5 + ONETBB_VERSION=2021.11.0 + # 2023-06-01 and later require Abseil. + RE2_VERSION=2022-06-01 +fi + # # Is /usr/bin/python3 a working version of Python? It may be, as it # might be a wrapper that runs the Python 3 that's part of Xcode. @@ -214,20 +221,27 @@ else # # No - install a Python package. # - PYTHON3_VERSION=3.9.5 + PYTHON3_VERSION=3.12.1 fi BROTLI_VERSION=1.0.9 # minizip +MINIZIPNG_VERSION=4.0.7 ZLIB_VERSION=1.3 # Uncomment to enable automatic updates using Sparkle -#SPARKLE_VERSION=2.1.0 +#SPARKLE_VERSION=2.2.2 # # Asciidoctor is required to build the documentation. # +# As the Asciidoctor Homebrew formula shows, managing all of the various +# dependencies can become quite hairy: +# https://github.com/Homebrew/homebrew-core/blob/master/Formula/a/asciidoctor.rb +# Maybe we should install a JRE and use AsciidoctorJ instead? ASCIIDOCTOR_VERSION=${ASCIIDOCTOR_VERSION-2.0.16} ASCIIDOCTORPDF_VERSION=${ASCIIDOCTORPDF_VERSION-1.6.1} +# css_parser 1.13 and later require Ruby 2.7 +CSS_PARSER_VERSION=${CSS_PARSER_VERSION-1.12.0} # # GNU autotools. They're not supplied with the macOS versions we # support, and we currently use them for minizip. @@ -237,35 +251,35 @@ AUTOMAKE_VERSION=1.16.5 LIBTOOL_VERSION=2.4.6 install_curl() { - if [ "$CURL_VERSION" -a ! -f curl-$CURL_VERSION-done ] ; then + if [ "$CURL_VERSION" ] && [ ! -f "curl-$CURL_VERSION-done" ] ; then echo "Downloading, building, and installing curl:" - [ -f curl-$CURL_VERSION.tar.bz2 ] || curl -L -O https://curl.haxx.se/download/curl-$CURL_VERSION.tar.bz2 || exit 1 + [ -f "curl-$CURL_VERSION.tar.bz2" ] || curl --fail --location --remote-name "https://curl.haxx.se/download/curl-$CURL_VERSION.tar.bz2" $no_build && echo "Skipping installation" && return - bzcat curl-$CURL_VERSION.tar.bz2 | tar xf - || exit 1 - cd curl-$CURL_VERSION - ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + bzcat "curl-$CURL_VERSION.tar.bz2" | tar xf - + cd "curl-$CURL_VERSION" + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. - touch curl-$CURL_VERSION-done + touch "curl-$CURL_VERSION-done" fi } uninstall_curl() { - if [ ! -z "$installed_curl_version" ] ; then + if [ -n "$installed_curl_version" ] ; then echo "Uninstalling curl:" - cd curl-$installed_curl_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + cd "curl-$installed_curl_version" + $DO_MAKE_UNINSTALL + make distclean cd .. - rm curl-$installed_curl_version-done + rm "curl-$installed_curl_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf curl-$installed_curl_version - rm -rf curl-$installed_curl_version.tar.bz2 + rm -rf "curl-$installed_curl_version" + rm -rf "curl-$installed_curl_version.tar.bz2" fi installed_curl_version="" @@ -273,112 +287,83 @@ uninstall_curl() { } install_xz() { - if [ "$XZ_VERSION" -a ! -f xz-$XZ_VERSION-done ] ; then + if [ "$XZ_VERSION" ] && [ ! -f xz-$XZ_VERSION-done ] ; then echo "Downloading, building, and installing xz:" - [ -f xz-$XZ_VERSION.tar.bz2 ] || curl -L -O https://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 || exit 1 + [ -f xz-$XZ_VERSION.tar.bz2 ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://tukaani.org/xz/xz-$XZ_VERSION.tar.bz2 $no_build && echo "Skipping installation" && return - bzcat xz-$XZ_VERSION.tar.bz2 | tar xf - || exit 1 + bzcat xz-$XZ_VERSION.tar.bz2 | tar xf - cd xz-$XZ_VERSION # # This builds and installs liblzma, which libxml2 uses, and - # Wireshark uses liblzma, so we need to build this with + # Wireshark uses libxml2, so we need to build this with # all the minimum-deployment-version and SDK stuff. # - CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch xz-$XZ_VERSION-done fi } uninstall_xz() { - if [ ! -z "$installed_xz_version" ] ; then + if [ -n "$installed_xz_version" ] ; then echo "Uninstalling xz:" - cd xz-$installed_xz_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + cd "xz-$installed_xz_version" + $DO_MAKE_UNINSTALL + make distclean cd .. - rm xz-$installed_xz_version-done + rm "xz-$installed_xz_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf xz-$installed_xz_version - rm -rf xz-$installed_xz_version.tar.bz2 + rm -rf "xz-$installed_xz_version" + rm -rf "xz-$installed_xz_version.tar.bz2" fi installed_xz_version="" fi } -install_lzip() { - if [ "$LZIP_VERSION" -a ! -f lzip-$LZIP_VERSION-done ] ; then - echo "Downloading, building, and installing lzip:" - [ -f lzip-$LZIP_VERSION.tar.gz ] || curl -L -O https://download.savannah.gnu.org/releases/lzip/lzip-$LZIP_VERSION.tar.gz || exit 1 - $no_build && echo "Skipping installation" && return - gzcat lzip-$LZIP_VERSION.tar.gz | tar xf - || exit 1 - cd lzip-$LZIP_VERSION - ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 - cd .. - touch lzip-$LZIP_VERSION-done - fi -} - uninstall_lzip() { - if [ ! -z "$installed_lzip_version" ] ; then + if [ -n "$installed_lzip_version" ] ; then echo "Uninstalling lzip:" - cd lzip-$installed_lzip_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + cd "lzip-$installed_lzip_version" + $DO_MAKE_UNINSTALL + make distclean cd .. - rm lzip-$installed_lzip_version-done + rm "lzip-$installed_lzip_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf lzip-$installed_lzip_version - rm -rf lzip-$installed_lzip_version.tar.gz + rm -rf "lzip-$installed_lzip_version" + rm -rf "lzip-$installed_lzip_version.tar.gz" fi installed_lzip_version="" fi } -install_pcre() { - if [ "$PCRE_VERSION" -a ! -f pcre-$PCRE_VERSION-done ] ; then - echo "Downloading, building, and installing pcre:" - [ -f pcre-$PCRE_VERSION.tar.bz2 ] || curl -L -O https://sourceforge.net/projects/pcre/files/pcre/$PCRE_VERSION/pcre-$PCRE_VERSION.tar.bz2 || exit 1 - $no_build && echo "Skipping installation" && return - bzcat pcre-$PCRE_VERSION.tar.bz2 | tar xf - || exit 1 - cd pcre-$PCRE_VERSION - ./configure --enable-unicode-properties || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 - cd .. - touch pcre-$PCRE_VERSION-done - fi -} - uninstall_pcre() { - if [ ! -z "$installed_pcre_version" ] ; then - echo "Uninstalling pcre:" - cd pcre-$installed_pcre_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + if [ -n "$installed_pcre_version" ] ; then + echo "Uninstalling leftover pcre:" + cd "pcre-$installed_pcre_version" + $DO_MAKE_UNINSTALL + make distclean cd .. - rm pcre-$installed_pcre_version-done + rm "pcre-$installed_pcre_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf pcre-$installed_pcre_version - rm -rf pcre-$installed_pcre_version.tar.bz2 + rm -rf "pcre-$installed_pcre_version" + rm -rf "pcre-$installed_pcre_version.tar.bz2" fi installed_pcre_version="" @@ -386,20 +371,19 @@ uninstall_pcre() { } install_pcre2() { - if [ "$PCRE2_VERSION" -a ! -f "pcre2-$PCRE2_VERSION-done" ] ; then + if [ "$PCRE2_VERSION" ] && [ ! -f "pcre2-$PCRE2_VERSION-done" ] ; then echo "Downloading, building, and installing pcre2:" - [ -f "pcre2-$PCRE2_VERSION.tar.bz2" ] || curl -L -O "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-10.39.tar.bz2" || exit 1 + [ -f "pcre2-$PCRE2_VERSION.tar.bz2" ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-10.39.tar.bz2" $no_build && echo "Skipping installation" && return - bzcat "pcre2-$PCRE2_VERSION.tar.bz2" | tar xf - || exit 1 + bzcat "pcre2-$PCRE2_VERSION.tar.bz2" | tar xf - cd "pcre2-$PCRE2_VERSION" mkdir build_dir cd build_dir # https://github.com/Homebrew/homebrew-core/blob/master/Formula/pcre2.rb # https://github.com/microsoft/vcpkg/blob/master/ports/pcre2/portfile.cmake - MACOSX_DEPLOYMENT_TARGET=$min_osx_target SDKROOT="$SDKPATH" \ - $DO_CMAKE -DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DPCRE2_SUPPORT_JIT=ON -DPCRE2_SUPPORT_UNICODE=ON .. || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + "${DO_CMAKE[@]}" -DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DPCRE2_SUPPORT_JIT=ON -DPCRE2_SUPPORT_UNICODE=ON .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd ../.. touch "pcre2-$PCRE2_VERSION-done" fi @@ -412,7 +396,7 @@ uninstall_pcre2() { while read -r ; do $DO_RM -v "$REPLY" ; done < <(cat "pcre2-$installed_pcre2_version/build_dir/install_manifest.txt"; echo) rm "pcre2-$installed_pcre2_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # @@ -427,20 +411,20 @@ uninstall_pcre2() { install_autoconf() { if [ "$AUTOCONF_VERSION" -a ! -f autoconf-$AUTOCONF_VERSION-done ] ; then echo "Downloading, building and installing GNU autoconf..." - [ -f autoconf-$AUTOCONF_VERSION.tar.xz ] || curl -L -O ftp://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.xz || exit 1 + [ -f autoconf-$AUTOCONF_VERSION.tar.xz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.xz $no_build && echo "Skipping installation" && return - xzcat autoconf-$AUTOCONF_VERSION.tar.xz | tar xf - || exit 1 + xzcat autoconf-$AUTOCONF_VERSION.tar.xz | tar xf - cd autoconf-$AUTOCONF_VERSION - ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch autoconf-$AUTOCONF_VERSION-done fi } uninstall_autoconf() { - if [ ! -z "$installed_autoconf_version" ] ; then + if [ -n "$installed_autoconf_version" ] ; then # # automake and libtool depend on this, so uninstall them. # @@ -449,8 +433,8 @@ uninstall_autoconf() { echo "Uninstalling GNU autoconf:" cd autoconf-$installed_autoconf_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm autoconf-$installed_autoconf_version-done @@ -469,20 +453,20 @@ uninstall_autoconf() { install_automake() { if [ "$AUTOMAKE_VERSION" -a ! -f automake-$AUTOMAKE_VERSION-done ] ; then echo "Downloading, building and installing GNU automake..." - [ -f automake-$AUTOMAKE_VERSION.tar.xz ] || curl -L -O ftp://ftp.gnu.org/gnu/automake/automake-$AUTOMAKE_VERSION.tar.xz || exit 1 + [ -f automake-$AUTOMAKE_VERSION.tar.xz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://ftp.gnu.org/gnu/automake/automake-$AUTOMAKE_VERSION.tar.xz $no_build && echo "Skipping installation" && return - xzcat automake-$AUTOMAKE_VERSION.tar.xz | tar xf - || exit 1 + xzcat automake-$AUTOMAKE_VERSION.tar.xz | tar xf - cd automake-$AUTOMAKE_VERSION - ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch automake-$AUTOMAKE_VERSION-done fi } uninstall_automake() { - if [ ! -z "$installed_automake_version" ] ; then + if [ -n "$installed_automake_version" ] ; then # # libtool depends on this(?), so uninstall it. # @@ -490,8 +474,8 @@ uninstall_automake() { echo "Uninstalling GNU automake:" cd automake-$installed_automake_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm automake-$installed_automake_version-done @@ -510,26 +494,26 @@ uninstall_automake() { install_libtool() { if [ "$LIBTOOL_VERSION" -a ! -f libtool-$LIBTOOL_VERSION-done ] ; then echo "Downloading, building and installing GNU libtool..." - [ -f libtool-$LIBTOOL_VERSION.tar.xz ] || curl -L -O ftp://ftp.gnu.org/gnu/libtool/libtool-$LIBTOOL_VERSION.tar.xz || exit 1 + [ -f libtool-$LIBTOOL_VERSION.tar.xz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://ftp.gnu.org/gnu/libtool/libtool-$LIBTOOL_VERSION.tar.xz $no_build && echo "Skipping installation" && return - xzcat libtool-$LIBTOOL_VERSION.tar.xz | tar xf - || exit 1 + xzcat libtool-$LIBTOOL_VERSION.tar.xz | tar xf - cd libtool-$LIBTOOL_VERSION - ./configure --program-prefix=g || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + ./configure "${CONFIGURE_OPTS[@]}" --program-prefix=g + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch libtool-$LIBTOOL_VERSION-done fi } uninstall_libtool() { - if [ ! -z "$installed_libtool_version" ] ; then + if [ -n "$installed_libtool_version" ] ; then echo "Uninstalling GNU libtool:" cd libtool-$installed_libtool_version - $DO_MV /usr/local/bin/glibtool /usr/local/bin/libtool - $DO_MV /usr/local/bin/glibtoolize /usr/local/bin/libtoolize - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MV "$installation_prefix/bin/glibtool" "$installation_prefix/bin/libtool" + $DO_MV "$installation_prefix/bin/glibtoolize" "$installation_prefix/bin/libtoolize" + $DO_MAKE_UNINSTALL + make distclean cd .. rm libtool-$installed_libtool_version-done @@ -546,27 +530,28 @@ uninstall_libtool() { } install_ninja() { - if [ "$NINJA_VERSION" -a ! -f ninja-$NINJA_VERSION-done ] ; then + if [ "$NINJA_VERSION" ] && [ ! -f "ninja-$NINJA_VERSION-done" ] ; then echo "Downloading and installing Ninja:" # # Download the zipball, unpack it, and move the binary to - # /usr/local/bin. + # $installation_prefix/bin. # - [ -f ninja-mac-v$NINJA_VERSION.zip ] || curl -L -o ninja-mac-v$NINJA_VERSION.zip https://github.com/ninja-build/ninja/releases/download/v$NINJA_VERSION/ninja-mac.zip || exit 1 + [ -f "ninja-mac-v$NINJA_VERSION.zip" ] || curl "${CURL_LOCAL_NAME_OPTS[@]}" "ninja-mac-v$NINJA_VERSION.zip" https://github.com/ninja-build/ninja/releases/download/v$NINJA_VERSION/ninja-mac.zip + echo "$NINJA_SHA256 ninja-mac-v$NINJA_VERSION.zip" | shasum --algorithm 256 --check $no_build && echo "Skipping installation" && return - unzip ninja-mac-v$NINJA_VERSION.zip - sudo mv ninja /usr/local/bin - touch ninja-$NINJA_VERSION-done + unzip "ninja-mac-v$NINJA_VERSION.zip" + sudo mv ninja "$installation_prefix/bin" + touch "ninja-$NINJA_VERSION-done" fi } uninstall_ninja() { - if [ ! -z "$installed_ninja_version" ]; then + if [ -n "$installed_ninja_version" ]; then echo "Uninstalling Ninja:" - sudo rm /usr/local/bin/ninja - rm ninja-$installed_ninja_version-done - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then - rm -f ninja-mac-v$installed_ninja_version.zip + $DO_RM "$installation_prefix/bin/ninja" + rm "ninja-$installed_ninja_version-done" + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then + rm -f "ninja-mac-v$installed_ninja_version.zip" fi installed_ninja_version="" @@ -576,13 +561,14 @@ uninstall_ninja() { install_asciidoctor() { if [ ! -f asciidoctor-${ASCIIDOCTOR_VERSION}-done ]; then echo "Downloading and installing Asciidoctor:" + $no_build && echo "Skipping installation" && return sudo gem install -V asciidoctor --version "=${ASCIIDOCTOR_VERSION}" touch asciidoctor-${ASCIIDOCTOR_VERSION}-done fi } uninstall_asciidoctor() { - if [ ! -z "$installed_asciidoctor_version" ]; then + if [ -n "$installed_asciidoctor_version" ]; then echo "Uninstalling Asciidoctor:" sudo gem uninstall -V asciidoctor --version "=${installed_asciidoctor_version}" rm asciidoctor-$installed_asciidoctor_version-done @@ -604,13 +590,15 @@ install_asciidoctorpdf() { ## record them for uninstallation ## ttfunk, pdf-core, prawn, prawn-table, Ascii85, ruby-rc4, hashery, afm, pdf-reader, prawn-templates, public_suffix, addressable, css_parser, prawn-svg, prawn-icon, safe_yaml, thread_safe, polyglot, treetop, asciidoctor-pdf echo "Downloading and installing Asciidoctor-pdf:" + $no_build && echo "Skipping installation" && return + sudo gem install -V css_parser --version "=${CSS_PARSER_VERSION}" sudo gem install -V asciidoctor-pdf --version "=${ASCIIDOCTORPDF_VERSION}" touch asciidoctorpdf-${ASCIIDOCTORPDF_VERSION}-done fi } uninstall_asciidoctorpdf() { - if [ ! -z "$installed_asciidoctorpdf_version" ]; then + if [ -n "$installed_asciidoctorpdf_version" ]; then echo "Uninstalling Asciidoctor:" sudo gem uninstall -V asciidoctor-pdf --version "=${installed_asciidoctorpdf_version}" ## XXX uninstall dependencies @@ -630,8 +618,9 @@ uninstall_asciidoctorpdf() { install_cmake() { if [ ! -f cmake-$CMAKE_VERSION-done ]; then echo "Downloading and installing CMake:" - CMAKE_MAJOR_VERSION="`expr $CMAKE_VERSION : '\([0-9][0-9]*\).*'`" - CMAKE_MINOR_VERSION="`expr $CMAKE_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" + $no_build && echo "Skipping installation" && return + CMAKE_MAJOR_VERSION="$( expr "$CMAKE_VERSION" : '\([0-9][0-9]*\).*' )" + CMAKE_MINOR_VERSION="$( expr "$CMAKE_VERSION" : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" CMAKE_MAJOR_MINOR_VERSION=$CMAKE_MAJOR_VERSION.$CMAKE_MINOR_VERSION # @@ -654,7 +643,7 @@ install_cmake() { # 3.19.3 and later have a macos-universal DMG for 10.13 and later, # and a macos10.10-universal DMG for 10.10 and later. # - if [ "$CMAKE_MINOR_VERSION" -lt 5 ]; then + if [ "$CMAKE_MINOR_VERSION" -lt 10 ]; then echo "CMake $CMAKE_VERSION" is too old 1>&2 elif [ "$CMAKE_MINOR_VERSION" -lt 19 -o \ "$CMAKE_VERSION" = 3.19.0 -o \ @@ -666,17 +655,17 @@ install_cmake() { else type="macos10.0-universal" fi - [ -f cmake-$CMAKE_VERSION-$type.dmg ] || curl -L -O https://cmake.org/files/v$CMAKE_MAJOR_MINOR_VERSION/cmake-$CMAKE_VERSION-$type.dmg || exit 1 + [ -f cmake-$CMAKE_VERSION-$type.dmg ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://cmake.org/files/v$CMAKE_MAJOR_MINOR_VERSION/cmake-$CMAKE_VERSION-$type.dmg $no_build && echo "Skipping installation" && return - sudo hdiutil attach cmake-$CMAKE_VERSION-$type.dmg || exit 1 - sudo ditto /Volumes/cmake-$CMAKE_VERSION-$type/CMake.app /Applications/CMake.app || exit 1 + sudo hdiutil attach cmake-$CMAKE_VERSION-$type.dmg + sudo ditto /Volumes/cmake-$CMAKE_VERSION-$type/CMake.app /Applications/CMake.app # - # Plant the appropriate symbolic links in /usr/local/bin. + # Plant the appropriate symbolic links in $installation_prefix/bin. # It's a drag-install, so there's no installer to make them, # and the CMake code to put them in place is lame, as # - # 1) it defaults to /usr/bin, not /usr/local/bin; + # 1) it defaults to /usr/bin, not $installation_prefix/bin; # 2) it doesn't request the necessary root privileges; # 3) it can't be run from the command line; # @@ -684,7 +673,7 @@ install_cmake() { # for i in ccmake cmake cmake-gui cmakexbuild cpack ctest do - sudo ln -s /Applications/CMake.app/Contents/bin/$i /usr/local/bin/$i + sudo ln -s /Applications/CMake.app/Contents/bin/$i "$installation_prefix/bin/$i" done sudo hdiutil detach /Volumes/cmake-$CMAKE_VERSION-$type ;; @@ -697,9 +686,9 @@ install_cmake() { } uninstall_cmake() { - if [ ! -z "$installed_cmake_version" ]; then + if [ -n "$installed_cmake_version" ]; then echo "Uninstalling CMake:" - installed_cmake_major_version="`expr $installed_cmake_version : '\([0-9][0-9]*\).*'`" + installed_cmake_major_version="$( expr "$installed_cmake_version" : '\([0-9][0-9]*\).*' )" case "$installed_cmake_major_version" in 0|1|2) @@ -710,7 +699,7 @@ uninstall_cmake() { sudo rm -rf /Applications/CMake.app for i in ccmake cmake cmake-gui cmakexbuild cpack ctest do - sudo rm -f /usr/local/bin/$i + sudo rm -f "$installation_prefix/bin/$i" done rm cmake-$installed_cmake_version-done ;; @@ -739,6 +728,7 @@ install_meson() { # We have it. : else + $no_build && echo "Skipping installation" && return sudo pip3 install meson touch meson-done fi @@ -758,7 +748,7 @@ install_pytest() { # # Install pytest with pip3 if we don't have it already. # - if python3 -m pytest --version >/dev/null 2>&1 + if python3 -m pytest --version &> /dev/null || pytest --version &> /dev/null then # We have it. : @@ -781,122 +771,21 @@ uninstall_pytest() { install_gettext() { if [ ! -f gettext-$GETTEXT_VERSION-done ] ; then echo "Downloading, building, and installing GNU gettext:" - [ -f gettext-$GETTEXT_VERSION.tar.gz ] || curl -L -O https://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz || exit 1 + [ -f gettext-$GETTEXT_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://ftp.gnu.org/pub/gnu/gettext/gettext-$GETTEXT_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat gettext-$GETTEXT_VERSION.tar.gz | tar xf - || exit 1 + gzcat gettext-$GETTEXT_VERSION.tar.gz | tar xf - cd gettext-$GETTEXT_VERSION - - # - # This is annoying. - # - # GNU gettext's configuration script checks for the presence of an - # implementation of iconv(). Not only does it check whether iconv() - # is available, *but* it checks for certain behavior *not* specified - # by POSIX that the GNU implementation provides, namely that an - # attempt to convert the UTF-8 for the EURO SYMBOL chaaracter to - # ISO 8859-1 results in an error. - # - # macOS, prior to Sierra, provided the GNU iconv library (as it's - # a POSIX API). - # - # Sierra appears to have picked up an implementation from FreeBSD - # (that implementation originated with the CITRUS project: - # - # http://citrus.bsdclub.org - # - # with additional work done to integrate it into NetBSD, and then - # adopted by FreeBSD with further work done). - # - # That implementation does *NOT* return an error in that case; instead, - # it transliterates the EURO SYMBOL to "EUR". - # - # Both behaviors conform to POSIX. - # - # This causes GNU gettext's configure script to conclude that it - # should not say iconv() is available. That, unfortunately, causes - # the build to fail with a linking error when trying to build - # libtextstyle (a library for which we have no use, that is offered - # as a separate library by the GNU project: - # - # https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.html - # - # and that is presumably bundled in GNU gettext because some gettext - # tool depends on it). The failure appears to be due to: - # - # libtextstyle's exported symbols file is generated from a - # template and a script that passes through only symbols - # that appear in a header file that declares the symbol - # as extern; - # - # one such header file declares iconv_ostream_create, but only - # if HAVE_ICONV is defined. - # - # the source file that defines iconv_ostream_create does so - # only if HAVE_ICONV is defined; - # - # the aforementioned script pays *NO ATTENTION* to #ifdefs, - # so it will include iconv_ostream_create in the list of - # symbols to export regardless of whether a working iconv() - # was found; - # - # the linker failing because it was told to export a symbol - # that doesn't exist. - # - # This is a collection of multiple messes: - # - # 1) not all versions of iconv() defaulting to "return an error - # if the target character set doesn't have a character that - # corresponds to the source character" and not offering a way - # to force that behavior; - # - # 2) either some parts of GNU gettext - and libraries bundled - # with it, for some mysterious reason - depending on the GNU - # behavior rather than assuming only what POSIX specifies, and - # the configure script checking for the GNU behavior and not - # setting HAVE_ICONV if it's not found; - # - # 3) the process for building the exported symbols file not - # removing symbols that won't exist in the build due to - # a "working" iconv() not being found; - # - # 4) the file that would define iconv_ostream_create() not - # defining as an always-failing stub if HAVE_ICONV isn't - # defined; - # - # 5) macOS's linker failing if a symbol is specified in an - # exported symbols file but not found, while other linkers - # just ignore it? (I add this because I'm a bit surprised - # that this has not been fixed, as I suspect it would fail - # on FreeBSD and possibly NetBSD as well, as I think their - # iconv()s also default to transliterating rather than failing - # if an input character has no corresponding character in - # the output encoding.) - # - # The Homebrew folks are aware of this and have reported it to - # Apple as a "feedback", for what that's worth: - # - # https://github.com/Homebrew/homebrew-core/commit/af3b4da5a096db3d9ee885e99ed29b33dec1f1c4 - # - # We adopt their fix, which is to run the configure script with - # "am_cv_func_iconv_works=y" as one of the arguments if it's - # running on Sonoma; in at least one test, doing so on Ventura - # caused the build to fail. - # - if [[ $DARWIN_MAJOR_VERSION -ge 23 ]]; then - workaround_arg="am_cv_func_iconv_works=y" - else - workaround_arg= - fi - CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure $workaround_arg || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch gettext-$GETTEXT_VERSION-done fi } uninstall_gettext() { - if [ ! -z "$installed_gettext_version" ] ; then + if [ -n "$installed_gettext_version" ] ; then # # GLib depends on this, so uninstall it. # @@ -904,8 +793,8 @@ uninstall_gettext() { echo "Uninstalling GNU gettext:" cd gettext-$installed_gettext_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm gettext-$installed_gettext_version-done @@ -924,24 +813,24 @@ uninstall_gettext() { install_pkg_config() { if [ ! -f pkg-config-$PKG_CONFIG_VERSION-done ] ; then echo "Downloading, building, and installing pkg-config:" - [ -f pkg-config-$PKG_CONFIG_VERSION.tar.gz ] || curl -L -O https://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz || exit 1 + [ -f pkg-config-$PKG_CONFIG_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://pkgconfig.freedesktop.org/releases/pkg-config-$PKG_CONFIG_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat pkg-config-$PKG_CONFIG_VERSION.tar.gz | tar xf - || exit 1 + gzcat pkg-config-$PKG_CONFIG_VERSION.tar.gz | tar xf - cd pkg-config-$PKG_CONFIG_VERSION - ./configure --with-internal-glib || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS -Wno-int-conversion" ./configure "${CONFIGURE_OPTS[@]}" --with-internal-glib + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch pkg-config-$PKG_CONFIG_VERSION-done fi } uninstall_pkg_config() { - if [ ! -z "$installed_pkg_config_version" ] ; then + if [ -n "$installed_pkg_config_version" ] ; then echo "Uninstalling pkg-config:" cd pkg-config-$installed_pkg_config_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm pkg-config-$installed_pkg_config_version-done @@ -960,13 +849,13 @@ uninstall_pkg_config() { install_glib() { if [ ! -f glib-$GLIB_VERSION-done ] ; then echo "Downloading, building, and installing GLib:" - glib_dir=`expr $GLIB_VERSION : '\([0-9][0-9]*\.[0-9][0-9]*\).*'` + glib_dir=$( expr "$GLIB_VERSION" : '\([0-9][0-9]*\.[0-9][0-9]*\).*' ) # # Starting with GLib 2.28.8, xz-compressed tarballs are available. # - [ -f glib-$GLIB_VERSION.tar.xz ] || curl -L -O https://download.gnome.org/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.xz || exit 1 + [ -f glib-$GLIB_VERSION.tar.xz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" "https://download.gnome.org/sources/glib/$glib_dir/glib-$GLIB_VERSION.tar.xz" $no_build && echo "Skipping installation" && return - xzcat glib-$GLIB_VERSION.tar.xz | tar xf - || exit 1 + xzcat glib-$GLIB_VERSION.tar.xz | tar xf - cd glib-$GLIB_VERSION # # First, determine where the system include files are. @@ -979,7 +868,7 @@ install_glib() { # # We need this for several things we do later. # - includedir=`SDKROOT="$SDKPATH" xcrun --show-sdk-path 2>/dev/null`/usr/include + includedir=$( SDKROOT="$SDKPATH" xcrun --show-sdk-path 2>/dev/null )/usr/include # # GLib's configuration procedure, whether autotools-based or # Meson-based, really likes to use pkg-config to find libraries, @@ -993,7 +882,7 @@ install_glib() { # # So, if we have a system-provided libffi, but pkg-config # doesn't find libffi, we construct a .pc file for that libffi, - # and install it in /usr/local/lib/pkgconfig. + # and install it in $installation_prefix/lib/pkgconfig. # # First, check whether pkg-config finds libffi but thinks its # header files are in a non-existent directory. That probaby @@ -1008,17 +897,17 @@ install_glib() { if pkg-config libffi ; then # We have a .pc file for libffi; what does it say the # include directory is? - incldir=`pkg-config --variable=includedir libffi` - if [ ! -z "$incldir" -a ! -d "$incldir" ] ; then + incldir=$( pkg-config --variable=includedir libffi ) + if [ -n "$incldir" -a ! -d "$incldir" ] ; then # Bogus - remove it, assuming - $DO_RM /usr/local/lib/pkgconfig/libffi.pc + $DO_RM "$installation_prefix/lib/pkgconfig/libffi.pc" fi fi if pkg-config libffi ; then # It found libffi; no need to install a .pc file, and we # don't want to overwrite what's there already. : - elif [ ! -e $includedir/ffi/ffi.h ] ; then + elif [ ! -e "$includedir"/ffi/ffi.h ] ; then # We don't appear to have libffi as part of the system, so # let the configuration process figure out what to do. # @@ -1054,7 +943,7 @@ install_glib() { # to the standard output, but running the last process in # the pipeline as root won't allow the shell that's # *running* it to open the .pc file if we don't have write - # permission on /usr/local/lib/pkgconfig, so we need a + # permission on $installation_prefix/lib/pkgconfig, so we need a # program that creates a file and then reads from the # standard input and writes to that file. UN*Xes have a # program that does that; it's called "tee". :-) @@ -1062,7 +951,7 @@ install_glib() { # However, it *also* writes the file to the standard output, # so we redirect that to /dev/null when we run it. # - cat <<"EOF" | sed "s;@INCLUDEDIR@;$includedir;" | $DO_TEE_TO_PC_FILE /usr/local/lib/pkgconfig/libffi.pc >/dev/null + cat <<"EOF" | sed "s;@INCLUDEDIR@;$includedir;" | $DO_TEE_TO_PC_FILE "$installation_prefix/lib/pkgconfig/libffi.pc" >/dev/null prefix=/usr libdir=${prefix}/lib includedir=@INCLUDEDIR@ @@ -1087,11 +976,11 @@ EOF *) case $GLIB_MINOR_VERSION in - [0-9]|1[0-9]|2[0-9]|3[0-7]) + [0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]) echo "GLib $GLIB_VERSION" is too old 1>&2 ;; - 3[8-9]|4[0-9]|5[0-8]) + 5[0-8]) if [ ! -f ./configure ]; then LIBTOOLIZE=glibtoolize ./autogen.sh fi @@ -1111,15 +1000,17 @@ EOF # # https://bugzilla.gnome.org/show_bug.cgi?id=691608#c25 # - if grep -qs '#define.*MACOSX' $includedir/ffi/fficonfig.h + if grep -qs '#define.*MACOSX' "$includedir/ffi/fficonfig.h" then # It's defined, nothing to do - CFLAGS="$CFLAGS -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 + CFLAGS="$CFLAGS -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" else - CFLAGS="$CFLAGS -DMACOSX -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -DMACOSX -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 + CFLAGS="$CFLAGS -DMACOSX -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -DMACOSX -Wno-format-nonliteral $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" fi - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL ;; 59|[6-9][0-9]|[1-9][0-9][0-9]) @@ -1132,9 +1023,10 @@ EOF # # https://gitlab.gnome.org/GNOME/glib/-/issues/2902 # - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" $MESON -Dtests=false _build || exit 1 - ninja $MAKE_BUILD_OPTS -C _build || exit 1 - $DO_NINJA_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + $MESON -Dprefix="$installation_prefix" -Dtests=false _build + ninja -C _build + $DO_NINJA_INSTALL ;; *) echo "Glib's put out 1000 2.x releases?" 1>&2 @@ -1148,28 +1040,28 @@ EOF } uninstall_glib() { - if [ ! -z "$installed_glib_version" ] ; then + if [ -n "$installed_glib_version" ] ; then echo "Uninstalling GLib:" - cd glib-$installed_glib_version - installed_glib_major_version="`expr $installed_glib_version : '\([0-9][0-9]*\).*'`" - installed_glib_minor_version="`expr $installed_glib_version : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" - installed_glib_dotdot_version="`expr $installed_glib_version : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`" - installed_glib_major_minor_version=$installed_glib_major_version.$installed_glib_minor_version - installed_glib_major_minor_dotdot_version=$installed_glib_major_version.$installed_glib_minor_version.$installed_glib_dotdot_version + cd "glib-$installed_glib_version" + installed_glib_major_version="$( expr "$installed_glib_version" : '\([0-9][0-9]*\).*' )" + installed_glib_minor_version="$( expr "$installed_glib_version" : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" + # installed_glib_dotdot_version="$( expr $installed_glib_version : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*' )" + # installed_glib_major_minor_version=$installed_glib_major_version.$installed_glib_minor_version + # installed_glib_major_minor_dotdot_version=$installed_glib_major_version.$installed_glib_minor_version.$installed_glib_dotdot_version # # GLib 2.59.1 and later use Meson+Ninja as the build system. # case $installed_glib_major_version in 1) - $DO_MAKE_UNINSTALL || exit 1 + $DO_MAKE_UNINSTALL # # This appears to delete dependencies out from under other # Makefiles in the tree, causing it to fail. At least until # that gets fixed, if it ever gets fixed, we just ignore the # exit status of "make distclean" # - # make distclean || exit 1 + # make distclean make distclean || echo "Ignoring make distclean failure" 1>&2 ;; @@ -1177,14 +1069,14 @@ uninstall_glib() { case $installed_glib_minor_version in [0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-8]) - $DO_MAKE_UNINSTALL || exit 1 + $DO_MAKE_UNINSTALL # # This appears to delete dependencies out from under other # Makefiles in the tree, causing it to fail. At least until # that gets fixed, if it ever gets fixed, we just ignore the # exit status of "make distclean" # - # make distclean || exit 1 + # make distclean make distclean || echo "Ignoring make distclean failure" 1>&2 ;; @@ -1194,7 +1086,7 @@ uninstall_glib() { # supports it, and I'm too lazy to add a dot-dot # version check. # - $DO_NINJA_UNINSTALL || exit 1 + $DO_NINJA_UNINSTALL # # For Meson+Ninja, we do the build in an _build # subdirectory, so the equivalent of "make distclean" @@ -1250,11 +1142,11 @@ install_qt() { 5) case $QT_MINOR_VERSION in - 0|1|2|3|4|5|6|7|8) + 0|1|2|3|4|5|6|7|8|9|10) echo "Qt $QT_VERSION" is too old 1>&2 ;; - 9|10|11|12|13|14) + 11|12|13|14) QT_VOLUME=qt-opensource-mac-x64-$QT_VERSION ;; *) @@ -1262,9 +1154,9 @@ install_qt() { ;; esac - [ -f $QT_VOLUME.dmg ] || curl -L -O https://download.qt.io/archive/qt/$QT_MAJOR_MINOR_VERSION/$QT_MAJOR_MINOR_DOTDOT_VERSION/$QT_VOLUME.dmg || exit 1 + [ -f $QT_VOLUME.dmg ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://download.qt.io/archive/qt/$QT_MAJOR_MINOR_VERSION/$QT_MAJOR_MINOR_DOTDOT_VERSION/$QT_VOLUME.dmg $no_build && echo "Skipping installation" && return - sudo hdiutil attach $QT_VOLUME.dmg || exit 1 + sudo hdiutil attach $QT_VOLUME.dmg # # Run the installer executable directly, so that we wait for @@ -1282,7 +1174,7 @@ install_qt() { } uninstall_qt() { - if [ ! -z "$installed_qt_version" ] ; then + if [ -n "$installed_qt_version" ] ; then echo "Uninstalling Qt:" rm -rf $HOME/Qt$installed_qt_version rm qt-$installed_qt_version-done @@ -1297,9 +1189,9 @@ uninstall_qt() { # 5.3 - 5.8: qt-opensource-mac-x64-clang-{version}.dmg # 5.9 - 5.14: qt-opensource-mac-x64-{version}.dmg # - installed_qt_major_version="`expr $installed_qt_version : '\([0-9][0-9]*\).*'`" - installed_qt_minor_version="`expr $installed_qt_version : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" - installed_qt_dotdot_version="`expr $installed_qt_version : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`" + installed_qt_major_version="$( expr "$installed_qt_version" : '\([0-9][0-9]*\).*' )" + installed_qt_minor_version="$( expr "$installed_qt_version" : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" + # installed_qt_dotdot_version="$( expr "$installed_qt_version" : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*' )" case $installed_qt_major_version in 1|2|3|4) @@ -1309,14 +1201,10 @@ uninstall_qt() { 5*) case $installed_qt_minor_version in - 0|1|2|3|4|5) + 0|1|2|3|4|5|6|7|8) echo "Qt $installed_qt_version" is too old 1>&2 ;; - 6|7|8) - installed_qt_volume=qt-opensource-mac-x64-clang-$installed_qt_version.dmg - ;; - 9|10|11|12|13|14) installed_qt_volume=qt-opensource-mac-x64-$installed_qt_version.dmg ;; @@ -1332,24 +1220,24 @@ uninstall_qt() { install_libsmi() { if [ "$LIBSMI_VERSION" -a ! -f libsmi-$LIBSMI_VERSION-done ] ; then echo "Downloading, building, and installing libsmi:" - [ -f libsmi-$LIBSMI_VERSION.tar.gz ] || curl -L -O https://www.ibr.cs.tu-bs.de/projects/libsmi/download/libsmi-$LIBSMI_VERSION.tar.gz || exit 1 + [ -f libsmi-$LIBSMI_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://www.ibr.cs.tu-bs.de/projects/libsmi/download/libsmi-$LIBSMI_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat libsmi-$LIBSMI_VERSION.tar.gz | tar xf - || exit 1 + gzcat libsmi-$LIBSMI_VERSION.tar.gz | tar xf - cd libsmi-$LIBSMI_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch libsmi-$LIBSMI_VERSION-done fi } uninstall_libsmi() { - if [ ! -z "$installed_libsmi_version" ] ; then + if [ -n "$installed_libsmi_version" ] ; then echo "Uninstalling libsmi:" cd libsmi-$installed_libsmi_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm libsmi-$installed_libsmi_version-done @@ -1368,20 +1256,20 @@ uninstall_libsmi() { install_libgpg_error() { if [ "$LIBGPG_ERROR_VERSION" -a ! -f libgpg-error-$LIBGPG_ERROR_VERSION-done ] ; then echo "Downloading, building, and installing libgpg-error:" - [ -f libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 ] || curl -L -O https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 || exit 1 + [ -f libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 $no_build && echo "Skipping installation" && return - bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - || exit 1 + bzcat libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2 | tar xf - cd libgpg-error-$LIBGPG_ERROR_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch libgpg-error-$LIBGPG_ERROR_VERSION-done fi } uninstall_libgpg_error() { - if [ ! -z "$installed_libgpg_error_version" ] ; then + if [ -n "$installed_libgpg_error_version" ] ; then # # libgcrypt depends on this, so uninstall it. # @@ -1389,8 +1277,8 @@ uninstall_libgpg_error() { echo "Uninstalling libgpg-error:" cd libgpg-error-$installed_libgpg_error_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm libgpg-error-$installed_libgpg_error_version-done @@ -1418,9 +1306,9 @@ install_libgcrypt() { fi echo "Downloading, building, and installing libgcrypt:" - [ -f libgcrypt-$LIBGCRYPT_VERSION.tar.gz ] || curl -L -O https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz || exit 1 + [ -f libgcrypt-$LIBGCRYPT_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-$LIBGCRYPT_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat libgcrypt-$LIBGCRYPT_VERSION.tar.gz | tar xf - || exit 1 + gzcat libgcrypt-$LIBGCRYPT_VERSION.tar.gz | tar xf - cd libgcrypt-$LIBGCRYPT_VERSION # # The assembler language code is not compatible with the macOS @@ -1431,20 +1319,26 @@ install_libgcrypt() { # # https://lists.freebsd.org/pipermail/freebsd-ports-bugs/2010-October/198809.html # - CFLAGS="$CFLAGS -std=gnu89 $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --disable-asm || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + # We specify "unix" as the random number generator so that we + # don't try to use getentropy, because random/rndgetentropy.c + # *REQUIRES* Linux getrandom(), which we don't have. (This should + # not matter, as we only use this for decryption, as far as I know.) + # + CFLAGS="$CFLAGS -std=gnu89 $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" --disable-asm --enable-random=unix + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch libgcrypt-$LIBGCRYPT_VERSION-done fi } uninstall_libgcrypt() { - if [ ! -z "$installed_libgcrypt_version" ] ; then + if [ -n "$installed_libgcrypt_version" ] ; then echo "Uninstalling libgcrypt:" cd libgcrypt-$installed_libgcrypt_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm libgcrypt-$installed_libgcrypt_version-done @@ -1461,63 +1355,64 @@ uninstall_libgcrypt() { } install_gmp() { - if [ "$GMP_VERSION" -a ! -f gmp-$GMP_VERSION-done ] ; then + if [ "$GMP_VERSION" ] && [ ! -f "gmp-$GMP_VERSION-done" ] ; then echo "Downloading, building, and installing GMP:" - [ -f gmp-$GMP_VERSION.tar.lz ] || curl -L -O https://gmplib.org/download/gmp/gmp-$GMP_VERSION.tar.lz || exit 1 + [ -f "gmp-$GMP_VERSION.tar.xz" ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://gmplib.org/download/gmp/gmp-$GMP_VERSION.tar.xz $no_build && echo "Skipping installation" && return - lzip -c -d gmp-$GMP_VERSION.tar.lz | tar xf - || exit 1 - cd gmp-$GMP_VERSION + xzcat "gmp-$GMP_VERSION.tar.xz" | tar xf - + cd "gmp-$GMP_VERSION" # # Create a fat binary: https://gmplib.org/manual/Notes-for-Package-Builds.html # # According to # # https://www.mail-archive.com/gmp-bugs@gmplib.org/msg01492.html - # + # # and other pages, the Shiny New Linker in Xcode 15 causes this # build to fail with "ld: branch8 out of range 384833 in # ___gmpn_add_nc_x86_64"; linking with -ld64 is a workaround. # # For now, link with -ld64 on Xcode 15 and later. # - XCODE_VERSION=`xcodebuild -version | sed -n 's;Xcode \(.*\);\1;p'` - XCODE_MAJOR_VERSION="`expr $XCODE_VERSION : '\([0-9][0-9]*\).*'`" - XCODE_MINOR_VERSION="`expr $XCODE_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" - XCODE_DOTDOT_VERSION="`expr $XCODE_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`" + XCODE_VERSION=$( xcodebuild -version | sed -n 's;Xcode \(.*\);\1;p' ) + XCODE_MAJOR_VERSION="$( expr "$XCODE_VERSION" : '\([0-9][0-9]*\).*' )" + # XCODE_MINOR_VERSION="$( expr $XCODE_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" + # XCODE_DOTDOT_VERSION="$( expr $XCODE_VERSION : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*' )" if [ "$XCODE_MAJOR_VERSION" -ge 15 ] then LD64_FLAG="-ld64" else LD64_FLAG="" fi - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS $LD64_FLAG" ./configure --enable-fat || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS $LD64_FLAG" \ + ./configure "${CONFIGURE_OPTS[@]}" --enable-fat + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. - touch gmp-$GMP_VERSION-done + touch "gmp-$GMP_VERSION-done" fi } uninstall_gmp() { - if [ ! -z "$installed_gmp_version" ] ; then + if [ -n "$installed_gmp_version" ] ; then # # Nettle depends on this, so uninstall it. # uninstall_nettle "$@" echo "Uninstalling GMP:" - cd gmp-$installed_gmp_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + cd "gmp-$installed_gmp_version" + $DO_MAKE_UNINSTALL + make distclean cd .. - rm gmp-$installed_gmp_version-done + rm "gmp-$installed_gmp_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf gmp-$installed_gmp_version - rm -rf gmp-$installed_gmp_version.tar.lz + rm -rf "gmp-$installed_gmp_version" + rm -rf "gmp-$installed_gmp_version.tar.xz" fi installed_gmp_version="" @@ -1525,40 +1420,41 @@ uninstall_gmp() { } install_libtasn1() { - if [ "$LIBTASN1_VERSION" -a ! -f libtasn1-$LIBTASN1_VERSION-done ] ; then + if [ "$LIBTASN1_VERSION" ] && [ ! -f "libtasn1-$LIBTASN1_VERSION-done" ] ; then echo "Downloading, building, and installing libtasn1:" - [ -f libtasn1-$LIBTASN1_VERSION.tar.gz ] || curl -L -O https://ftpmirror.gnu.org/libtasn1/libtasn1-$LIBTASN1_VERSION.tar.gz || exit 1 + [ -f "libtasn1-$LIBTASN1_VERSION.tar.gz" ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" "https://ftp.gnu.org/gnu/libtasn1/libtasn1-$LIBTASN1_VERSION.tar.gz" $no_build && echo "Skipping installation" && return - gzcat libtasn1-$LIBTASN1_VERSION.tar.gz | tar xf - || exit 1 - cd libtasn1-$LIBTASN1_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + gzcat "libtasn1-$LIBTASN1_VERSION.tar.gz" | tar xf - + cd "libtasn1-$LIBTASN1_VERSION" + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. - touch libtasn1-$LIBTASN1_VERSION-done + touch "libtasn1-$LIBTASN1_VERSION-done" fi } uninstall_libtasn1() { - if [ ! -z "$installed_libtasn1_version" ] ; then + if [ -n "$installed_libtasn1_version" ] ; then # # p11-kit depends on this, so uninstall it. # uninstall_p11_kit "$@" echo "Uninstalling libtasn1:" - cd libtasn1-$installed_libtasn1_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + cd "libtasn1-$installed_libtasn1_version" + $DO_MAKE_UNINSTALL + make distclean cd .. - rm libtasn1-$installed_libtasn1_version-done + rm "libtasn1-$installed_libtasn1_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf libtasn1-$installed_libtasn1_version - rm -rf libtasn1-$installed_libtasn1_version.tar.gz + rm -rf "libtasn1-$installed_libtasn1_version" + rm -rf "libtasn1-$installed_libtasn1_version.tar.gz" fi installed_libtasn1_version="" @@ -1566,12 +1462,12 @@ uninstall_libtasn1() { } install_p11_kit() { - if [ "$P11KIT_VERSION" -a ! -f p11-kit-$P11KIT_VERSION-done ] ; then + if [ "$P11KIT_VERSION" ] && [ ! -f "p11-kit-$P11KIT_VERSION-done" ] ; then echo "Downloading, building, and installing p11-kit:" - [ -f p11-kit-$P11KIT_VERSION.tar.xz ] || curl -L -O https://github.com/p11-glue/p11-kit/releases/download/$P11KIT_VERSION/p11-kit-$P11KIT_VERSION.tar.xz || exit 1 + [ -f "p11-kit-$P11KIT_VERSION.tar.xz" ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" "https://github.com/p11-glue/p11-kit/releases/download/$P11KIT_VERSION/p11-kit-$P11KIT_VERSION.tar.xz" $no_build && echo "Skipping installation" && return - xzcat p11-kit-$P11KIT_VERSION.tar.xz | tar xf - || exit 1 - cd p11-kit-$P11KIT_VERSION + xzcat "p11-kit-$P11KIT_VERSION.tar.xz" | tar xf - + cd "p11-kit-$P11KIT_VERSION" # # Prior to Catalina, the libffi that's supplied with macOS # doesn't support ffi_closure_alloc() or ffi_prep_closure_loc(), @@ -1587,34 +1483,35 @@ install_p11_kit() { # but it's not clear that this matters to us, so we just # configure p11-kit not to use libffi. # - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS -L/usr/local/lib" LIBS=-lintl ./configure --without-libffi --without-trust-paths || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LIBS=-lintl \ + ./configure "${CONFIGURE_OPTS[@]}" --without-libffi --without-trust-paths + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. - touch p11-kit-$P11KIT_VERSION-done + touch "p11-kit-$P11KIT_VERSION-done" fi } uninstall_p11_kit() { - if [ ! -z "$installed_p11_kit_version" ] ; then + if [ -n "$installed_p11_kit_version" ] ; then # # Nettle depends on this, so uninstall it. # uninstall_nettle "$@" echo "Uninstalling p11-kit:" - cd p11-kit-$installed_p11_kit_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + cd "p11-kit-$installed_p11_kit_version" + $DO_MAKE_UNINSTALL + make distclean cd .. - rm p11-kit-$installed_p11_kit_version-done + rm "p11-kit-$installed_p11_kit_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf p11-kit-$installed_p11_kit_version - rm -rf p11-kit-$installed_p11_kit_version.tar.xz + rm -rf "p11-kit-$installed_p11_kit_version" + rm -rf "p11-kit-$installed_p11_kit_version.tar.xz" fi installed_p11_kit_version="" @@ -1622,40 +1519,41 @@ uninstall_p11_kit() { } install_nettle() { - if [ "$NETTLE_VERSION" -a ! -f nettle-$NETTLE_VERSION-done ] ; then + if [ "$NETTLE_VERSION" ] && [ ! -f "nettle-$NETTLE_VERSION-done" ] ; then echo "Downloading, building, and installing Nettle:" - [ -f nettle-$NETTLE_VERSION.tar.gz ] || curl -L -O https://ftp.gnu.org/gnu/nettle/nettle-$NETTLE_VERSION.tar.gz || exit 1 + [ -f "nettle-$NETTLE_VERSION.tar.gz" ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" "https://ftp.gnu.org/gnu/nettle/nettle-$NETTLE_VERSION.tar.gz" $no_build && echo "Skipping installation" && return - gzcat nettle-$NETTLE_VERSION.tar.gz | tar xf - || exit 1 - cd nettle-$NETTLE_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS -I/usr/local/include" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS -L/usr/local/lib" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + gzcat "nettle-$NETTLE_VERSION.tar.gz" | tar xf - + cd "nettle-$NETTLE_VERSION" + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. - touch nettle-$NETTLE_VERSION-done + touch "nettle-$NETTLE_VERSION-done" fi } uninstall_nettle() { - if [ ! -z "$installed_nettle_version" ] ; then + if [ -n "$installed_nettle_version" ] ; then # # GnuTLS depends on this, so uninstall it. # uninstall_gnutls "$@" echo "Uninstalling Nettle:" - cd nettle-$installed_nettle_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + cd "nettle-$installed_nettle_version" + $DO_MAKE_UNINSTALL + make distclean cd .. - rm nettle-$installed_nettle_version-done + rm "nettle-$installed_nettle_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf nettle-$installed_nettle_version - rm -rf nettle-$installed_nettle_version.tar.gz + rm -rf "nettle-$installed_nettle_version" + rm -rf "nettle-$installed_nettle_version.tar.gz" fi installed_nettle_version="" @@ -1663,55 +1561,46 @@ uninstall_nettle() { } install_gnutls() { - if [ "$GNUTLS_VERSION" -a ! -f gnutls-$GNUTLS_VERSION-done ] ; then + if [ "$GNUTLS_VERSION" ] && [ ! -f "gnutls-$GNUTLS_VERSION-done" ] ; then # # GnuTLS requires Nettle. # - if [ -z $NETTLE_VERSION ] + if [ -z "$NETTLE_VERSION" ] then echo "GnuTLS requires Nettle, but you didn't install Nettle" 1>&2 exit 1 fi echo "Downloading, building, and installing GnuTLS:" - if [[ $GNUTLS_MAJOR_VERSION -ge 3 ]] - then - # - # Starting with GnuTLS 3.x, the tarballs are compressed with - # xz rather than bzip2. - # - [ -f gnutls-$GNUTLS_VERSION.tar.xz ] || curl -L -O https://www.gnupg.org/ftp/gcrypt/gnutls/v$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION/gnutls-$GNUTLS_VERSION.tar.xz || exit 1 - $no_build && echo "Skipping installation" && return - xzcat gnutls-$GNUTLS_VERSION.tar.xz | tar xf - || exit 1 - else - [ -f gnutls-$GNUTLS_VERSION.tar.bz2 ] || curl -L -O https://www.gnupg.org/ftp/gcrypt/gnutls/v$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION/gnutls-$GNUTLS_VERSION.tar.bz2 || exit 1 - $no_build && echo "Skipping installation" && return - bzcat gnutls-$GNUTLS_VERSION.tar.bz2 | tar xf - || exit 1 - fi + [ -f gnutls-$GNUTLS_VERSION.tar.xz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" "https://www.gnupg.org/ftp/gcrypt/gnutls/v$GNUTLS_MAJOR_VERSION.$GNUTLS_MINOR_VERSION/gnutls-$GNUTLS_VERSION.tar.xz" + echo "$GNUTLS_SHA256 gnutls-$GNUTLS_VERSION.tar.xz" | shasum --algorithm 256 --check + $no_build && echo "Skipping installation" && return + tar -xf gnutls-$GNUTLS_VERSION.tar.xz cd gnutls-$GNUTLS_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS -I /usr/local/include" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS -I/usr/local/include/" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS -L/usr/local/lib" ./configure --with-included-unistring --disable-guile || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" --with-included-unistring --disable-guile + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch gnutls-$GNUTLS_VERSION-done fi } uninstall_gnutls() { - if [ ! -z "$installed_gnutls_version" ] ; then + if [ -n "$installed_gnutls_version" ] ; then echo "Uninstalling GnuTLS:" - cd gnutls-$installed_gnutls_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + cd "gnutls-$installed_gnutls_version" + $DO_MAKE_UNINSTALL + make distclean cd .. - rm gnutls-$installed_gnutls_version-done + rm "gnutls-$installed_gnutls_version-done" s - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf gnutls-$installed_gnutls_version - rm -rf gnutls-$installed_gnutls_version.tar.bz2 + rm -rf "gnutls-$installed_gnutls_version" + rm -rf "gnutls-$installed_gnutls_version.tar.bz2" fi installed_gnutls_version="" @@ -1721,31 +1610,31 @@ uninstall_gnutls() { install_lua() { if [ "$LUA_VERSION" -a ! -f lua-$LUA_VERSION-done ] ; then echo "Downloading, building, and installing Lua:" - [ -f lua-$LUA_VERSION.tar.gz ] || curl -L -O https://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz || exit 1 + [ -f lua-$LUA_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat lua-$LUA_VERSION.tar.gz | tar xf - || exit 1 + gzcat lua-$LUA_VERSION.tar.gz | tar xf - cd lua-$LUA_VERSION - make MYCFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" MYLDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" $MAKE_BUILD_OPTS macosx || exit 1 - $DO_MAKE_INSTALL || exit 1 + make INSTALL_TOP="$installation_prefix" MYCFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" MYLDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" macosx + $DO_MAKE INSTALL_TOP="$installation_prefix" install cd .. touch lua-$LUA_VERSION-done fi } uninstall_lua() { - if [ ! -z "$installed_lua_version" ] ; then + if [ -n "$installed_lua_version" ] ; then echo "Uninstalling Lua:" # # Lua has no "make uninstall", so just remove stuff manually. # There's no configure script, so there's no need for # "make distclean", either; just do "make clean". # - (cd /usr/local/bin; $DO_RM -f lua luac) - (cd /usr/local/include; $DO_RM -f lua.h luaconf.h lualib.h lauxlib.h lua.hpp) - (cd /usr/local/lib; $DO_RM -f liblua.a) - (cd /usr/local/man/man1; $DO_RM -f lua.1 luac.1) + (cd "$installation_prefix/bin"; $DO_RM -f lua luac) + (cd "$installation_prefix/include"; $DO_RM -f lua.h luaconf.h lualib.h lauxlib.h lua.hpp) + (cd "$installation_prefix/lib"; $DO_RM -f liblua.a) + (cd "$installation_prefix/man/man1"; $DO_RM -f lua.1 luac.1) cd lua-$installed_lua_version - make clean || exit 1 + make clean cd .. rm lua-$installed_lua_version-done @@ -1764,13 +1653,13 @@ uninstall_lua() { install_snappy() { if [ "$SNAPPY_VERSION" -a ! -f snappy-$SNAPPY_VERSION-done ] ; then echo "Downloading, building, and installing snappy:" - [ -f snappy-$SNAPPY_VERSION.tar.gz ] || curl -L -o snappy-$SNAPPY_VERSION.tar.gz https://github.com/google/snappy/archive/$SNAPPY_VERSION.tar.gz || exit 1 + [ -f snappy-$SNAPPY_VERSION.tar.gz ] || curl "${CURL_LOCAL_NAME_OPTS[@]}" snappy-$SNAPPY_VERSION.tar.gz https://github.com/google/snappy/archive/$SNAPPY_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat snappy-$SNAPPY_VERSION.tar.gz | tar xf - || exit 1 + gzcat snappy-$SNAPPY_VERSION.tar.gz | tar xf - cd snappy-$SNAPPY_VERSION if [ "$SNAPPY_VERSION" = "1.1.10" ] ; then # This patch corresponds to https://github.com/google/snappy/commit/27f34a580be4a3becf5f8c0cba13433f53c21337 - patch -p0 <${topdir}/macosx-support-lib-patches/snappy-signed.patch || exit 1 + patch -p0 < "${topdir}/tools/macos-setup-patches/snappy-signed.patch" fi mkdir build_dir cd build_dir @@ -1781,44 +1670,44 @@ install_snappy() { # will carry that dependency with it, so linking with it should # Just Work. # - MACOSX_DEPLOYMENT_TARGET=$min_osx_target SDKROOT="$SDKPATH" $DO_CMAKE -DBUILD_SHARED_LIBS=YES -DSNAPPY_BUILD_BENCHMARKS=NO -DSNAPPY_BUILD_TESTS=NO ../ || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + "${DO_CMAKE[@]}" -DBUILD_SHARED_LIBS=YES -DSNAPPY_BUILD_BENCHMARKS=NO -DSNAPPY_BUILD_TESTS=NO .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd ../.. touch snappy-$SNAPPY_VERSION-done fi } uninstall_snappy() { - if [ ! -z "$installed_snappy_version" ] ; then + if [ -n "$installed_snappy_version" ] ; then echo "Uninstalling snappy:" cd snappy-$installed_snappy_version # # snappy uses cmake and doesn't support "make uninstall"; # just remove what we know it installs. # - # $DO_MAKE_UNINSTALL || exit 1 + # $DO_MAKE_UNINSTALL if [ -s build_dir/install_manifest.txt ] ; then while read -r ; do $DO_RM -v "$REPLY" ; done < <(cat build_dir/install_manifest.txt; echo) else - $DO_RM -f /usr/local/lib/libsnappy.1.1.8.dylib \ - /usr/local/lib/libsnappy.1.dylib \ - /usr/local/lib/libsnappy.dylib \ - /usr/local/include/snappy-c.h \ - /usr/local/include/snappy-sinksource.h \ - /usr/local/include/snappy-stubs-public.h \ - /usr/local/include/snappy.h \ - /usr/local/lib/cmake/Snappy/SnappyConfig.cmake \ - /usr/local/lib/cmake/Snappy/SnappyConfigVersion.cmake \ - /usr/local/lib/cmake/Snappy/SnappyTargets-noconfig.cmake \ - /usr/local/lib/cmake/Snappy/SnappyTargets.cmake || exit 1 + $DO_RM -f "$installation_prefix/lib/libsnappy.1.1.8.dylib" \ + "$installation_prefix/lib/libsnappy.1.dylib" \ + "$installation_prefix/lib/libsnappy.dylib" \ + "$installation_prefix/include/snappy-c.h" \ + "$installation_prefix/include/snappy-sinksource.h" \ + "$installation_prefix/include/snappy-stubs-public.h" \ + "$installation_prefix/include/snappy.h" \ + "$installation_prefix/lib/cmake/Snappy/SnappyConfig.cmake" \ + "$installation_prefix/lib/cmake/Snappy/SnappyConfigVersion.cmake" \ + "$installation_prefix/lib/cmake/Snappy/SnappyTargets-noconfig.cmake" \ + "$installation_prefix/lib/cmake/Snappy/SnappyTargets.cmake" fi # # snappy uses cmake and doesn't support "make distclean"; #.just remove the entire build directory. # - # make distclean || exit 1 - rm -rf build_dir || exit 1 + # make distclean + rm -rf build_dir cd .. rm snappy-$installed_snappy_version-done @@ -1835,75 +1724,119 @@ uninstall_snappy() { } install_zstd() { - if [ "$ZSTD_VERSION" -a ! -f zstd-$ZSTD_VERSION-done ] ; then + if [ "$ZSTD_VERSION" ] && [ ! -f zstd-$ZSTD_VERSION-done ] ; then echo "Downloading, building, and installing zstd:" - [ -f zstd-$ZSTD_VERSION.tar.gz ] || curl -L -O https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz || exit 1 + [ -f zstd-$ZSTD_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat zstd-$ZSTD_VERSION.tar.gz | tar xf - || exit 1 + gzcat zstd-$ZSTD_VERSION.tar.gz | tar xf - cd zstd-$ZSTD_VERSION - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + # We shouldn't have to specify DESTDIR. + # https://github.com/facebook/zstd/issues/3146 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + make PREFIX="$installation_prefix" DESTDIR="$installation_prefix" "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE PREFIX="$installation_prefix" install cd .. touch zstd-$ZSTD_VERSION-done fi } uninstall_zstd() { - if [ ! -z "$installed_zstd_version" ] ; then + if [ -n "$installed_zstd_version" ] ; then echo "Uninstalling zstd:" - cd zstd-$installed_zstd_version - $DO_MAKE_UNINSTALL || exit 1 + cd "zstd-$installed_zstd_version" + $DO_MAKE_UNINSTALL # # zstd has no configure script, so there's no need for # "make distclean", and the Makefile supplied with it # has no "make distclean" rule; just do "make clean". # - make clean || exit 1 + make clean cd .. - rm zstd-$installed_zstd_version-done + rm "zstd-$installed_zstd_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # - rm -rf zstd-$installed_zstd_version - rm -rf zstd-$installed_zstd_version.tar.gz + rm -rf "zstd-$installed_zstd_version" + rm -rf "zstd-$installed_zstd_version.tar.gz" fi installed_zstd_version="" fi } +#$ZLIBNG_VERSION +install_zlibng() { + if [ "$ZLIBNG_VERSION" ] && [ ! -f zlib-ng-$ZLIBNG_VERSION-done ] ; then + echo "Downloading, building, and installing zlib-ng:" + [ -f $ZLIBNG_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://github.com/zlib-ng/zlib-ng/archive/refs/tags/$ZLIBNG_VERSION.tar.gz + $no_build && echo "Skipping installation" && return + gzcat $ZLIBNG_VERSION.tar.gz | tar xf - + cd zlib-ng-$ZLIBNG_VERSION + mkdir build + cd build + "${DO_CMAKE[@]}" .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL + cd ../.. + touch zlib-ng-$ZLIBNG_VERSION-done + fi +} + +uninstall_zlibng() { + if [ -n "$installed_zstd_version" ] ; then + echo "Uninstalling zlibng:" + cd "zlib-ng-$installed_zlibng_version" + $DO_MAKE_UNINSTALL + # + # XXX not sure what to do here... + # + make clean + cd .. + rm "zlib-ng-$installed_zlibng_version-done" + + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then + # + # Get rid of the previously downloaded and unpacked version. + # + rm -rf "zlib-ng-$installed_zlibng_version" + rm -rf "zlib-ng-$installed_zlibng_version.tar.gz" + fi + installed_zlibng_version="" + fi +} install_libxml2() { if [ "$LIBXML2_VERSION" -a ! -f libxml2-$LIBXML2_VERSION-done ] ; then echo "Downloading, building, and installing libxml2:" - LIBXML2_MAJOR_VERSION="`expr $LIBXML2_VERSION : '\([0-9][0-9]*\).*'`" - LIBXML2_MINOR_VERSION="`expr $LIBXML2_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" + LIBXML2_MAJOR_VERSION="$( expr "$LIBXML2_VERSION" : '\([0-9][0-9]*\).*' )" + LIBXML2_MINOR_VERSION="$( expr "$LIBXML2_VERSION" : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" LIBXML2_MAJOR_MINOR_VERSION=$LIBXML2_MAJOR_VERSION.$LIBXML2_MINOR_VERSION - [ -f libxml2-$LIBXML2_VERSION.tar.gz ] || curl -L -O https://download.gnome.org/sources/libxml2/$LIBXML2_MAJOR_MINOR_VERSION/libxml2-$LIBXML2_VERSION.tar.xz || exit 1 + [ -f libxml2-$LIBXML2_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://download.gnome.org/sources/libxml2/$LIBXML2_MAJOR_MINOR_VERSION/libxml2-$LIBXML2_VERSION.tar.xz $no_build && echo "Skipping installation" && return - xzcat libxml2-$LIBXML2_VERSION.tar.xz | tar xf - || exit 1 - cd libxml2-$LIBXML2_VERSION + xzcat libxml2-$LIBXML2_VERSION.tar.xz | tar xf - + cd "libxml2-$LIBXML2_VERSION" # # At least on macOS 12.0.1 with Xcode 13.1, when we build # libxml2, the linker complains that we don't have the right # to link with the Python framework, so don't build with # Python. # - CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --without-python || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" --without-python + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch libxml2-$LIBXML2_VERSION-done fi } uninstall_libxml2() { - if [ ! -z "$installed_libxml2_version" ] ; then + if [ -n "$installed_libxml2_version" ] ; then echo "Uninstalling libxml2:" cd libxml2-$installed_libxml2_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm libxml2-$installed_libxml2_version-done @@ -1920,7 +1853,7 @@ uninstall_libxml2() { } install_lz4() { - if [ "$LZ4_VERSION" -a ! -f lz4-$LZ4_VERSION-done ] ; then + if [ "$LZ4_VERSION" ] && [ ! -f lz4-$LZ4_VERSION-done ] ; then echo "Downloading, building, and installing lz4:" # # lz4 switched from sequentially numbered releases, named rN, @@ -1945,12 +1878,12 @@ install_lz4() { # if [[ "$LZ4_VERSION" == r* ]] then - [ -f lz4-$LZ4_VERSION.tar.gz ] || curl -L -o lz4-$LZ4_VERSION.tar.gz https://github.com/lz4/lz4/archive/$LZ4_VERSION.tar.gz || exit 1 + [ -f lz4-$LZ4_VERSION.tar.gz ] || curl "${CURL_LOCAL_NAME_OPTS[@]}" lz4-$LZ4_VERSION.tar.gz https://github.com/lz4/lz4/archive/$LZ4_VERSION.tar.gz else - [ -f lz4-$LZ4_VERSION.tar.gz ] || curl -L -o lz4-$LZ4_VERSION.tar.gz https://github.com/lz4/lz4/archive/v$LZ4_VERSION.tar.gz || exit 1 + [ -f lz4-$LZ4_VERSION.tar.gz ] || curl "${CURL_LOCAL_NAME_OPTS[@]}" lz4-$LZ4_VERSION.tar.gz https://github.com/lz4/lz4/archive/v$LZ4_VERSION.tar.gz fi $no_build && echo "Skipping installation" && return - gzcat lz4-$LZ4_VERSION.tar.gz | tar xf - || exit 1 + gzcat lz4-$LZ4_VERSION.tar.gz | tar xf - cd lz4-$LZ4_VERSION # # No configure script here, but it appears that if MOREFLAGS is @@ -1958,29 +1891,30 @@ install_lz4() { # and CXXFLAGS into FLAGS, which is used when building source # files and libraries. # - MOREFLAGS="-D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + MOREFLAGS="-D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" \ + make PREFIX="$installation_prefix" "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE PREFIX="$installation_prefix" install cd .. touch lz4-$LZ4_VERSION-done fi } uninstall_lz4() { - if [ ! -z "$installed_lz4_version" ] ; then + if [ -n "$installed_lz4_version" ] ; then echo "Uninstalling lz4:" - cd lz4-$installed_lz4_version - $DO_MAKE_UNINSTALL || exit 1 + cd "lz4-$installed_lz4_version" + $DO_MAKE_UNINSTALL # # lz4's Makefile doesn't support "make distclean"; just do # "make clean". Perhaps not using autotools means that # there's no need for "make distclean". # - # make distclean || exit 1 - make clean || exit 1 + # make distclean + make clean cd .. - rm lz4-$installed_lz4_version-done + rm "lz4-$installed_lz4_version-done" - if [ "$#" -eq 1 -a "$1" = "-r" ] ; then + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then # # Get rid of the previously downloaded and unpacked version. # @@ -1990,8 +1924,8 @@ uninstall_lz4() { # tree. Therefore, we have to remove the build tree # as root. # - sudo rm -rf lz4-$installed_lz4_version - rm -rf lz4-$installed_lz4_version.tar.gz + sudo rm -rf "lz4-$installed_lz4_version" + rm -rf "lz4-$installed_lz4_version.tar.gz" fi installed_lz4_version="" @@ -2001,28 +1935,30 @@ uninstall_lz4() { install_sbc() { if [ "$SBC_VERSION" -a ! -f sbc-$SBC_VERSION-done ] ; then echo "Downloading, building, and installing sbc:" - [ -f sbc-$SBC_VERSION.tar.gz ] || curl -L -O https://www.kernel.org/pub/linux/bluetooth/sbc-$SBC_VERSION.tar.gz || exit 1 + [ -f sbc-$SBC_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://www.kernel.org/pub/linux/bluetooth/sbc-$SBC_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat sbc-$SBC_VERSION.tar.gz | tar xf - || exit 1 + gzcat sbc-$SBC_VERSION.tar.gz | tar xf - cd sbc-$SBC_VERSION - if [ "$DARWIN_PROCESSOR_ARCH" = "arm" ] ; then - CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS -U__ARM_NEON__" CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --disable-tools --disable-tester --disable-shared || exit 1 + if [ "$DARWIN_PROCESSOR_ARCH" = "arm64" ] ; then + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS -U__ARM_NEON__" CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" --disable-tools --disable-tester --disable-shared else - CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --disable-tools --disable-tester --disable-shared || exit 1 + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" --disable-tools --disable-tester --disable-shared fi - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch sbc-$SBC_VERSION-done fi } uninstall_sbc() { - if [ ! -z "$installed_sbc_version" ] ; then + if [ -n "$installed_sbc_version" ] ; then echo "Uninstalling sbc:" cd sbc-$installed_sbc_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm sbc-$installed_sbc_version-done @@ -2041,24 +1977,25 @@ uninstall_sbc() { install_maxminddb() { if [ "$MAXMINDDB_VERSION" -a ! -f maxminddb-$MAXMINDDB_VERSION-done ] ; then echo "Downloading, building, and installing MaxMindDB API:" - [ -f libmaxminddb-$MAXMINDDB_VERSION.tar.gz ] || curl -L -O https://github.com/maxmind/libmaxminddb/releases/download/$MAXMINDDB_VERSION/libmaxminddb-$MAXMINDDB_VERSION.tar.gz || exit 1 + [ -f libmaxminddb-$MAXMINDDB_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://github.com/maxmind/libmaxminddb/releases/download/$MAXMINDDB_VERSION/libmaxminddb-$MAXMINDDB_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat libmaxminddb-$MAXMINDDB_VERSION.tar.gz | tar xf - || exit 1 + gzcat libmaxminddb-$MAXMINDDB_VERSION.tar.gz | tar xf - cd libmaxminddb-$MAXMINDDB_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch maxminddb-$MAXMINDDB_VERSION-done fi } uninstall_maxminddb() { - if [ ! -z "$installed_maxminddb_version" ] ; then + if [ -n "$installed_maxminddb_version" ] ; then echo "Uninstalling MaxMindDB API:" cd libmaxminddb-$installed_maxminddb_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm maxminddb-$installed_maxminddb_version-done @@ -2077,24 +2014,26 @@ uninstall_maxminddb() { install_c_ares() { if [ "$CARES_VERSION" -a ! -f c-ares-$CARES_VERSION-done ] ; then echo "Downloading, building, and installing C-Ares API:" - [ -f c-ares-$CARES_VERSION.tar.gz ] || curl -L -O https://c-ares.org/download/c-ares-$CARES_VERSION.tar.gz || exit 1 + # https://github.com/c-ares/c-ares/releases/download/v1.31.0/c-ares-1.31.0.tar.gz + [ -f c-ares-$CARES_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://github.com/c-ares/c-ares/releases/download/v$CARES_VERSION/c-ares-$CARES_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat c-ares-$CARES_VERSION.tar.gz | tar xf - || exit 1 + gzcat c-ares-$CARES_VERSION.tar.gz | tar xf - cd c-ares-$CARES_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch c-ares-$CARES_VERSION-done fi } uninstall_c_ares() { - if [ ! -z "$installed_cares_version" ] ; then + if [ -n "$installed_cares_version" ] ; then echo "Uninstalling C-Ares API:" cd c-ares-$installed_cares_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm c-ares-$installed_cares_version-done @@ -2113,42 +2052,42 @@ uninstall_c_ares() { install_libssh() { if [ "$LIBSSH_VERSION" -a ! -f libssh-$LIBSSH_VERSION-done ] ; then echo "Downloading, building, and installing libssh:" - LIBSSH_MAJOR_VERSION="`expr $LIBSSH_VERSION : '\([0-9][0-9]*\).*'`" - LIBSSH_MINOR_VERSION="`expr $LIBSSH_VERSION : '[0-9][0-9]*\.\([0-9][0-9]*\).*'`" + LIBSSH_MAJOR_VERSION="$( expr "$LIBSSH_VERSION" : '\([0-9][0-9]*\).*' )" + LIBSSH_MINOR_VERSION="$( expr "$LIBSSH_VERSION" : '[0-9][0-9]*\.\([0-9][0-9]*\).*' )" LIBSSH_MAJOR_MINOR_VERSION=$LIBSSH_MAJOR_VERSION.$LIBSSH_MINOR_VERSION - [ -f libssh-$LIBSSH_VERSION.tar.xz ] || curl -L -O https://www.libssh.org/files/$LIBSSH_MAJOR_MINOR_VERSION/libssh-$LIBSSH_VERSION.tar.xz + [ -f libssh-$LIBSSH_VERSION.tar.xz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://www.libssh.org/files/$LIBSSH_MAJOR_MINOR_VERSION/libssh-$LIBSSH_VERSION.tar.xz $no_build && echo "Skipping installation" && return - xzcat libssh-$LIBSSH_VERSION.tar.xz | tar xf - || exit 1 - cd libssh-$LIBSSH_VERSION + xzcat libssh-$LIBSSH_VERSION.tar.xz | tar xf - + cd "libssh-$LIBSSH_VERSION" mkdir build cd build - MACOSX_DEPLOYMENT_TARGET=$min_osx_target SDKROOT="$SDKPATH" $DO_CMAKE -DWITH_GCRYPT=1 ../ || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + "${DO_CMAKE[@]}" -DWITH_GCRYPT=1 .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd ../.. touch libssh-$LIBSSH_VERSION-done fi } uninstall_libssh() { - if [ ! -z "$installed_libssh_version" ] ; then + if [ -n "$installed_libssh_version" ] ; then echo "Uninstalling libssh:" cd libssh-$installed_libssh_version # # libssh uses cmake and doesn't support "make uninstall"; # just remove what we know it installs. # - # $DO_MAKE_UNINSTALL || exit 1 - $DO_RM -rf /usr/local/lib/libssh* \ - /usr/local/include/libssh \ - /usr/local/lib/pkgconfig/libssh* \ - /usr/local/lib/cmake/libssh || exit 1 + # $DO_MAKE_UNINSTALL + $DO_RM -rf "$installation_prefix"/lib/libssh* \ + "$installation_prefix"/include/libssh \ + "$installation_prefix"/lib/pkgconfig/libssh* \ + "$installation_prefix"/lib/cmake/libssh # # libssh uses cmake and doesn't support "make distclean"; # just remove the entire build directory. # - # make distclean || exit 1 - rm -rf build || exit 1 + # make distclean + rm -rf build cd .. rm libssh-$installed_libssh_version-done @@ -2167,24 +2106,25 @@ uninstall_libssh() { install_nghttp2() { if [ "$NGHTTP2_VERSION" -a ! -f nghttp2-$NGHTTP2_VERSION-done ] ; then echo "Downloading, building, and installing nghttp2:" - [ -f nghttp2-$NGHTTP2_VERSION.tar.xz ] || curl -L -O https://github.com/nghttp2/nghttp2/releases/download/v$NGHTTP2_VERSION/nghttp2-$NGHTTP2_VERSION.tar.xz || exit 1 + [ -f nghttp2-$NGHTTP2_VERSION.tar.xz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://github.com/nghttp2/nghttp2/releases/download/v$NGHTTP2_VERSION/nghttp2-$NGHTTP2_VERSION.tar.xz $no_build && echo "Skipping installation" && return - xzcat nghttp2-$NGHTTP2_VERSION.tar.xz | tar xf - || exit 1 + xzcat nghttp2-$NGHTTP2_VERSION.tar.xz | tar xf - cd nghttp2-$NGHTTP2_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-lib-only || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" --enable-lib-only + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch nghttp2-$NGHTTP2_VERSION-done fi } uninstall_nghttp2() { - if [ ! -z "$installed_nghttp2_version" ] ; then + if [ -n "$installed_nghttp2_version" ] ; then echo "Uninstalling nghttp2:" cd nghttp2-$installed_nghttp2_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm nghttp2-$installed_nghttp2_version-done @@ -2203,24 +2143,25 @@ uninstall_nghttp2() { install_nghttp3() { if [ "$NGHTTP3_VERSION" -a ! -f nghttp3-$NGHTTP3_VERSION-done ] ; then echo "Downloading, building, and installing nghttp3:" - [ -f nghttp3-$NGHTTP3_VERSION.tar.xz ] || curl -L -O https://github.com/ngtcp2/nghttp3/releases/download/v$NGHTTP3_VERSION/nghttp3-$NGHTTP3_VERSION.tar.xz || exit 1 + [ -f nghttp3-$NGHTTP3_VERSION.tar.xz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://github.com/ngtcp2/nghttp3/releases/download/v$NGHTTP3_VERSION/nghttp3-$NGHTTP3_VERSION.tar.xz $no_build && echo "Skipping installation" && return - xzcat nghttp3-$NGHTTP3_VERSION.tar.xz | tar xf - || exit 1 + xzcat nghttp3-$NGHTTP3_VERSION.tar.xz | tar xf - cd nghttp3-$NGHTTP3_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure --enable-lib-only || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" --enable-lib-only + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch nghttp3-$NGHTTP3_VERSION-done fi } uninstall_nghttp3() { - if [ ! -z "$installed_nghttp3_version" ] ; then + if [ -n "$installed_nghttp3_version" ] ; then echo "Uninstalling nghttp3:" cd nghttp3-$installed_nghttp3_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm nghttp3-$installed_nghttp3_version-done @@ -2240,26 +2181,27 @@ install_libtiff() { if [ "$LIBTIFF_VERSION" -a ! -f tiff-$LIBTIFF_VERSION-done ] ; then echo "Downloading, building, and installing libtiff:" [ -f tiff-$LIBTIFF_VERSION.tar.gz ] || - curl --fail -L -O https://download.osgeo.org/libtiff/tiff-$LIBTIFF_VERSION.tar.gz || - curl --fail -L -O https://download.osgeo.org/libtiff/old/tiff-$LIBTIFF_VERSION.tar.gz || + curl "${CURL_REMOTE_NAME_OPTS[@]}" https://download.osgeo.org/libtiff/tiff-$LIBTIFF_VERSION.tar.gz || + curl "${CURL_REMOTE_NAME_OPTS[@]}" https://download.osgeo.org/libtiff/old/tiff-$LIBTIFF_VERSION.tar.gz || exit 1 $no_build && echo "Skipping installation" && return - gzcat tiff-$LIBTIFF_VERSION.tar.gz | tar xf - || exit 1 + gzcat tiff-$LIBTIFF_VERSION.tar.gz | tar xf - cd tiff-$LIBTIFF_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch tiff-$LIBTIFF_VERSION-done fi } uninstall_libtiff() { - if [ ! -z "$installed_libtiff_version" ] ; then + if [ -n "$installed_libtiff_version" ] ; then echo "Uninstalling libtiff:" cd tiff-$installed_libtiff_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm tiff-$installed_libtiff_version-done @@ -2278,30 +2220,31 @@ uninstall_libtiff() { install_spandsp() { if [ "$SPANDSP_VERSION" -a ! -f spandsp-$SPANDSP_VERSION-done ] ; then echo "Downloading, building, and installing SpanDSP:" - [ -f spandsp-$SPANDSP_VERSION.tar.gz ] || curl -L -O https://www.soft-switch.org/downloads/spandsp/spandsp-$SPANDSP_VERSION.tar.gz || exit 1 + [ -f spandsp-$SPANDSP_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://www.soft-switch.org/downloads/spandsp/spandsp-$SPANDSP_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat spandsp-$SPANDSP_VERSION.tar.gz | tar xf - || exit 1 + gzcat spandsp-$SPANDSP_VERSION.tar.gz | tar xf - cd spandsp-$SPANDSP_VERSION # # Don't use -Wunused-but-set-variable, as it's not supported # by all the gcc versions in the versions of Xcode that we # support. # - patch -p0 <${topdir}/macosx-support-lib-patches/spandsp-configure-patch || exit 1 - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + patch -p0 < "${topdir}/tools/macos-setup-patches/spandsp-configure-patch" + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch spandsp-$SPANDSP_VERSION-done fi } uninstall_spandsp() { - if [ ! -z "$installed_spandsp_version" ] ; then + if [ -n "$installed_spandsp_version" ] ; then echo "Uninstalling SpanDSP:" cd spandsp-$installed_spandsp_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm spandsp-$installed_spandsp_version-done @@ -2320,24 +2263,25 @@ uninstall_spandsp() { install_speexdsp() { if [ "$SPEEXDSP_VERSION" -a ! -f speexdsp-$SPEEXDSP_VERSION-done ] ; then echo "Downloading, building, and installing SpeexDSP:" - [ -f speexdsp-$SPEEXDSP_VERSION.tar.gz ] || curl -L -O https://ftp.osuosl.org/pub/xiph/releases/speex/speexdsp-$SPEEXDSP_VERSION.tar.gz || exit 1 + [ -f speexdsp-$SPEEXDSP_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://ftp.osuosl.org/pub/xiph/releases/speex/speexdsp-$SPEEXDSP_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat speexdsp-$SPEEXDSP_VERSION.tar.gz | tar xf - || exit 1 + gzcat speexdsp-$SPEEXDSP_VERSION.tar.gz | tar xf - cd speexdsp-$SPEEXDSP_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch speexdsp-$SPEEXDSP_VERSION-done fi } uninstall_speexdsp() { - if [ ! -z "$installed_speexdsp_version" ] ; then + if [ -n "$installed_speexdsp_version" ] ; then echo "Uninstalling SpeexDSP:" cd speexdsp-$installed_speexdsp_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm speexdsp-$installed_speexdsp_version-done @@ -2356,39 +2300,39 @@ uninstall_speexdsp() { install_bcg729() { if [ "$BCG729_VERSION" -a ! -f bcg729-$BCG729_VERSION-done ] ; then echo "Downloading, building, and installing bcg729:" - [ -f bcg729-$BCG729_VERSION.tar.gz ] || curl -L -O https://gitlab.linphone.org/BC/public/bcg729/-/archive/$BCG729_VERSION/bcg729-$BCG729_VERSION.tar.gz || exit 1 + [ -f bcg729-$BCG729_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://gitlab.linphone.org/BC/public/bcg729/-/archive/$BCG729_VERSION/bcg729-$BCG729_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat bcg729-$BCG729_VERSION.tar.gz | tar xf - || exit 1 + gzcat bcg729-$BCG729_VERSION.tar.gz | tar xf - cd bcg729-$BCG729_VERSION mkdir build_dir cd build_dir - MACOSX_DEPLOYMENT_TARGET=$min_osx_target SDKROOT="$SDKPATH" $DO_CMAKE ../ || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + "${DO_CMAKE[@]}" .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd ../.. touch bcg729-$BCG729_VERSION-done fi } uninstall_bcg729() { - if [ ! -z "$installed_bcg729_version" ] ; then + if [ -n "$installed_bcg729_version" ] ; then echo "Uninstalling bcg729:" cd bcg729-$installed_bcg729_version # # bcg729 uses cmake on macOS and doesn't support "make uninstall"; # just remove what we know it installs. # - # $DO_MAKE_UNINSTALL || exit 1 - $DO_RM -rf /usr/local/share/Bcg729 \ - /usr/local/lib/libbcg729* \ - /usr/local/include/bcg729 \ - /usr/local/lib/pkgconfig/libbcg729* || exit 1 + # $DO_MAKE_UNINSTALL + $DO_RM -rf "$installation_prefix"/share/Bcg729 \ + "$installation_prefix"/lib/libbcg729* \ + "$installation_prefix"/include/bcg729 \ + "$installation_prefix"/lib/pkgconfig/libbcg729* # # bcg729 uses cmake on macOS and doesn't support "make distclean"; # just remove the enire build directory. # - # make distclean || exit 1 - rm -rf build_dir || exit 1 + # make distclean + rm -rf build_dir cd .. rm bcg729-$installed_bcg729_version-done @@ -2407,13 +2351,14 @@ uninstall_bcg729() { install_ilbc() { if [ -n "$ILBC_VERSION" ] && [ ! -f ilbc-$ILBC_VERSION-done ] ; then echo "Downloading, building, and installing iLBC:" - [ -f libilbc-$ILBC_VERSION.tar.bz ] || curl --location --remote-name https://github.com/TimothyGu/libilbc/releases/download/v$ILBC_VERSION/libilbc-$ILBC_VERSION.tar.bz2 || exit 1 + [ -f libilbc-$ILBC_VERSION.tar.bz ] || curl --location --remote-name https://github.com/TimothyGu/libilbc/releases/download/v$ILBC_VERSION/libilbc-$ILBC_VERSION.tar.bz2 $no_build && echo "Skipping installation" && return - bzcat libilbc-$ILBC_VERSION.tar.bz2 | tar xf - || exit 1 - cd libilbc-$ILBC_VERSION || exit 1 - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + bzcat libilbc-$ILBC_VERSION.tar.bz2 | tar xf - + cd libilbc-$ILBC_VERSION + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch ilbc-$ILBC_VERSION-done fi @@ -2422,9 +2367,9 @@ install_ilbc() { uninstall_ilbc() { if [ -n "$installed_ilbc_version" ] ; then echo "Uninstalling iLBC:" - cd "libilbc-$installed_ilbc_version" || exit 1 - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + cd "libilbc-$installed_ilbc_version" + $DO_MAKE_UNINSTALL + make distclean cd .. rm "ilbc-$installed_ilbc_version-done" @@ -2440,27 +2385,66 @@ uninstall_ilbc() { fi } +install_opencore_amr() { + if [ "$OPENCORE_AMR_VERSION" ] && [ ! -f opencore-amr-$OPENCORE_AMR_VERSION-done ] ; then + echo "Downloading, building, and installing opencore-amr:" + [ -f opencore-amr-$OPENCORE_AMR_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-$OPENCORE_AMR_VERSION.tar.gz + echo "$OPENCORE_AMR_SHA256 opencore-amr-$OPENCORE_AMR_VERSION.tar.gz" | shasum --algorithm 256 --check + $no_build && echo "Skipping installation" && return + tar -xf opencore-amr-$OPENCORE_AMR_VERSION.tar.gz + cd opencore-amr-$OPENCORE_AMR_VERSION + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL + cd .. + touch opencore-amr-$OPENCORE_AMR_VERSION-done + fi +} + +uninstall_opencore_amr() { + if [ -n "$installed_opencore_amr_version" ] ; then + echo "Uninstalling opencore-amr:" + cd "opencore-amr-$installed_opencore_amr_version" + $DO_MAKE_UNINSTALL + make distclean + cd .. + rm "opencore-amr-$installed_opencore_amr_version-done" + + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then + # + # Get rid of the previously downloaded and unpacked version. + # + rm -rf "opencore-amr-$installed_opencore_amr_version" + rm -rf "opencore-amr-$installed_opencore_amr_version.tar.gz" + fi + + installed_opencore_amr_version="" + fi +} + install_opus() { if [ "$OPUS_VERSION" -a ! -f opus-$OPUS_VERSION-done ] ; then echo "Downloading, building, and installing opus:" - [ -f opus-$OPUS_VERSION.tar.gz ] || curl -L -O https://downloads.xiph.org/releases/opus/opus-$OPUS_VERSION.tar.gz || exit 1 + [ -f opus-$OPUS_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://downloads.xiph.org/releases/opus/opus-$OPUS_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat opus-$OPUS_VERSION.tar.gz | tar xf - || exit 1 + gzcat opus-$OPUS_VERSION.tar.gz | tar xf - cd opus-$OPUS_VERSION - CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd .. touch opus-$OPUS_VERSION-done fi } uninstall_opus() { - if [ ! -z "$installed_opus_version" ] ; then + if [ -n "$installed_opus_version" ] ; then echo "Uninstalling opus:" cd opus-$installed_opus_version - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd .. rm opus-$installed_opus_version-done @@ -2476,26 +2460,164 @@ uninstall_opus() { fi } -install_python3() { - # The macos11 installer can be deployed to older versions, down to - # 10.9 (Mavericks), but is still considered experimental so continue - # to use the 64-bit installer (10.9) on earlier releases for now. - local macver=x10.9 - if [[ $DARWIN_MAJOR_VERSION -gt 19 ]]; then - # The macos11 installer is required for Arm-based Macs, which require - # macOS 11 Big Sur. Note that the package name is "11.0" (no x) for - # 3.9.1 but simply "11" for 3.9.2 (and later) - if [[ $PYTHON3_VERSION = 3.9.1 ]]; then - macver=11.0 - else - macver=11 +install_jsoncpp() { + if [ "$JSONCPP_VERSION" ] && [ ! -f "jsoncpp-$JSONCPP_VERSION-done" ] ; then + echo "Downloading, building, and installing JsonCpp:" + [ -f "jsoncpp-$JSONCPP_VERSION.tar.gz" ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" --remote-header-name "https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/$JSONCPP_VERSION.tar.gz" + $no_build && echo "Skipping installation" && return + tar -xf "jsoncpp-$JSONCPP_VERSION.tar.gz" + cd "jsoncpp-$JSONCPP_VERSION" + mkdir build_dir + cd build_dir + "${DO_CMAKE[@]}" -DBUILD_OBJECT_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL + cd ../.. + touch "jsoncpp-$JSONCPP_VERSION-done" + fi +} + +uninstall_jsoncpp() { + if [ "$installed_jsoncpp_version" ] && [ -s "jsoncpp-$installed_jsoncpp_version/build_dir/install_manifest.txt" ] ; then + echo "Uninstalling JsonCpp:" + while read -r ; do $DO_RM -v "$REPLY" ; done < <(cat "jsoncpp-$installed_jsoncpp_version/build_dir/install_manifest.txt"; echo) + rm "jsoncpp-$JSONCPP_VERSION-done" + + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then + # + # Get rid of the previously downloaded and unpacked version. + # + rm -rf "jsoncpp-$installed_jsoncpp_version" + rm -rf "jsoncpp-$installed_jsoncpp_version.tar.gz" + fi + + installed_jsoncpp_version="" + fi +} + +install_onetbb() { + if [ "$ONETBB_VERSION" ] && [ ! -f "onetbb-$ONETBB_VERSION-done" ] ; then + echo "Downloading, building, and installing oneTBB:" + [ -f "oneTBB-$ONETBB_VERSION.tar.gz" ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" --remote-header-name "https://github.com/oneapi-src/oneTBB/archive/refs/tags/v$ONETBB_VERSION.tar.gz" + $no_build && echo "Skipping installation" && return + tar -xf "oneTBB-$ONETBB_VERSION.tar.gz" + cd "oneTBB-$ONETBB_VERSION" + mkdir build_dir + cd build_dir + "${DO_CMAKE[@]}" -DBUILD_SHARED_LIBS=ON -DTBB_TEST=OFF .. + make "${MAKE_BUILD_OPTS[@]}" tbb + $DO_MAKE_INSTALL + cd ../.. + touch "onetbb-$ONETBB_VERSION-done" + fi +} + +uninstall_onetbb() { + if [ "$installed_onetbb_version" ] && [ -s "oneTBB-$installed_onetbb_version/build_dir/install_manifest.txt" ] ; then + echo "Uninstalling oneTBB:" + while read -r ; do $DO_RM -v "$REPLY" ; done < <(cat "oneTBB-$installed_onetbb_version/build_dir/install_manifest.txt"; echo) + rm "onetbb-$installed_onetbb_version-done" + + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then + # + # Get rid of the previously downloaded and unpacked version. + # + rm -rf "oneTBB-$installed_onetbb_version" + rm -rf "oneTBB-$installed_onetbb_version.tar.gz" + fi + + installed_onetbb_version="" + fi +} + +install_re2() { + if [ "$RE2_VERSION" ] && [ ! -f "re2-$RE2_VERSION-done" ] ; then + echo "Downloading, building, and installing RE2:" + [ -f "re2-$RE2_VERSION.tar.gz" ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" --remote-header-name "https://github.com/google/re2/archive/refs/tags/$RE2_VERSION.tar.gz" + $no_build && echo "Skipping installation" && return + tar -xf "re2-$RE2_VERSION.tar.gz" + cd "re2-$RE2_VERSION" + mkdir build_dir + cd build_dir + "${DO_CMAKE[@]}" -DBUILD_SHARED_LIBS=ON -DRE2_BUILD_TESTING=OFF .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL + cd ../.. + touch "re2-$RE2_VERSION-done" + fi +} + +uninstall_re2() { + if [ -n "$installed_re2_version" ] && [ -s "re2-$installed_re2_version/build_dir/install_manifest.txt" ] ; then + echo "Uninstalling RE2:" + while read -r ; do $DO_RM -v "$REPLY" ; done < <(cat "re2-$installed_re2_version/build_dir/install_manifest.txt"; echo) + rm "re2-$installed_re2_version-done" + + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then + # + # Get rid of the previously downloaded and unpacked version. + # + rm -rf "re2-$installed_re2_version" + rm -rf "re2-$installed_re2_version.tar.gz" + fi + + installed_re2_version="" + fi +} + +install_falco_libs() { + if [ "$FALCO_LIBS_VERSION" ] && [ ! -f "falco-libs-$FALCO_LIBS_VERSION-done" ] ; then + echo "Downloading, building, and installing libsinsp and libscap:" + [ -f "falco-libs-$FALCO_LIBS_VERSION.tar.gz" ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" --remote-header-name "https://github.com/falcosecurity/libs/archive/refs/tags/$FALCO_LIBS_VERSION.tar.gz" + $no_build && echo "Skipping installation" && return + mv "libs-$FALCO_LIBS_VERSION.tar.gz" "falco-libs-$FALCO_LIBS_VERSION.tar.gz" + tar -xf "falco-libs-$FALCO_LIBS_VERSION.tar.gz" + mv "libs-$FALCO_LIBS_VERSION" "falco-libs-$FALCO_LIBS_VERSION" + cd "falco-libs-$FALCO_LIBS_VERSION" + patch -p1 < "${topdir}/tools/macos-setup-patches/falco-uthash_h-install.patch" + patch -p1 < "${topdir}/tools/macos-setup-patches/falco-include-dirs.patch" + mkdir build_dir + cd build_dir + "${DO_CMAKE[@]}" -DBUILD_SHARED_LIBS=ON -DMINIMAL_BUILD=ON -DCREATE_TEST_TARGETS=OFF \ + -DUSE_BUNDLED_DEPS=ON -DUSE_BUNDLED_CARES=OFF -DUSE_BUNDLED_ZLIB=OFF \ + -DUSE_BUNDLED_JSONCPP=OFF -DUSE_BUNDLED_TBB=OFF -DUSE_BUNDLED_RE2=OFF \ + .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL + cd ../.. + touch "falco-libs-$FALCO_LIBS_VERSION-done" + fi +} + +uninstall_falco_libs() { + if [ -n "$installed_falco_libs_version" ] && [ -s "falco-libs-$installed_falco_libs_version/build_dir/install_manifest.txt" ] ; then + echo "Uninstalling Falco libs:" + $DO_RM "$installation_prefix"/include/falcosecurity/uthash.h + while read -r ; do $DO_RM -v "$REPLY" ; done < <(cat "falco-libs-$installed_falco_libs_version/build_dir/install_manifest.txt"; echo) + rm "falco-libs-$installed_falco_libs_version-done" + + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then + # + # Get rid of the previously downloaded and unpacked version. + # + rm -rf "falco-libs-$installed_falco_libs_version" + rm -rf "falco-libs-$installed_falco_libs_version.tar.gz" fi + + installed_falco_libs_version="" fi +} + +install_python3() { + # The macos11 universal2 installer can be deployed to older versions, + # down to 10.9 (Mavericks). The 10.9 installer was deprecated in 3.9.8 + # and stopped being released after 3.9.13 + local macver=11 if [ "$PYTHON3_VERSION" -a ! -f python3-$PYTHON3_VERSION-done ] ; then echo "Downloading and installing python3:" - [ -f python-$PYTHON3_VERSION-macos$macver.pkg ] || curl -L -O https://www.python.org/ftp/python/$PYTHON3_VERSION/python-$PYTHON3_VERSION-macos$macver.pkg || exit 1 + [ -f python-$PYTHON3_VERSION-macos$macver.pkg ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://www.python.org/ftp/python/$PYTHON3_VERSION/python-$PYTHON3_VERSION-macos$macver.pkg $no_build && echo "Skipping installation" && return - sudo installer -target / -pkg python-$PYTHON3_VERSION-macos$macver.pkg || exit 1 + sudo installer -target / -pkg python-$PYTHON3_VERSION-macos$macver.pkg touch python3-$PYTHON3_VERSION-done # @@ -2506,7 +2628,7 @@ install_python3() { # # Strip off any dot-dot component in $PYTHON3_VERSION. # - python_version=`echo $PYTHON3_VERSION | sed 's/\([1-9][0-9]*\.[1-9][0-9]*\).*/\1/'` + python_version=$( echo "$PYTHON3_VERSION" | sed 's/\([1-9][0-9]*\.[1-9][0-9]*\).*/\1/' ) # # Now treat Meson as being in the directory in question. # @@ -2524,12 +2646,12 @@ install_python3() { uninstall_python3() { # Major version (e.g. "3.7") local PYTHON_VERSION=${installed_python3_version%.*} - if [ ! -z "$installed_python3_version" ] ; then + if [ -n "$installed_python3_version" ] ; then echo "Uninstalling python3:" frameworkdir="/Library/Frameworks/Python.framework/Versions/$PYTHON_VERSION" sudo rm -rf "$frameworkdir" sudo rm -rf "/Applications/Python $PYTHON_VERSION" - sudo find /usr/local/bin -maxdepth 1 -lname "*$frameworkdir/bin/*" -delete + sudo find "$installation_prefix"/bin -maxdepth 1 -lname "*$frameworkdir/bin/*" -delete # Remove three symlinks and empty directories. Removing directories # might fail if for some reason multiple versions are installed. sudo rm /Library/Frameworks/Python.framework/Headers @@ -2560,39 +2682,39 @@ uninstall_python3() { install_brotli() { if [ "$BROTLI_VERSION" -a ! -f brotli-$BROTLI_VERSION-done ] ; then echo "Downloading, building, and installing brotli:" - [ -f brotli-$BROTLI_VERSION.tar.gz ] || curl -L -o brotli-$BROTLI_VERSION.tar.gz https://github.com/google/brotli/archive/v$BROTLI_VERSION.tar.gz || exit 1 + [ -f brotli-$BROTLI_VERSION.tar.gz ] || curl "${CURL_LOCAL_NAME_OPTS[@]}" brotli-$BROTLI_VERSION.tar.gz https://github.com/google/brotli/archive/v$BROTLI_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat brotli-$BROTLI_VERSION.tar.gz | tar xf - || exit 1 + gzcat brotli-$BROTLI_VERSION.tar.gz | tar xf - cd brotli-$BROTLI_VERSION mkdir build_dir cd build_dir - MACOSX_DEPLOYMENT_TARGET=$min_osx_target SDKROOT="$SDKPATH" $DO_CMAKE ../ || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + "${DO_CMAKE[@]}" .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd ../.. touch brotli-$BROTLI_VERSION-done fi } uninstall_brotli() { - if [ ! -z "$installed_brotli_version" ] ; then + if [ -n "$installed_brotli_version" ] ; then echo "Uninstalling brotli:" cd brotli-$installed_brotli_version # # brotli uses cmake on macOS and doesn't support "make uninstall"; # just remove what we know it installs. # - # $DO_MAKE_UNINSTALL || exit 1 - $DO_RM -rf /usr/local/bin/brotli \ - /usr/local/lib/libbrotli* \ - /usr/local/include/brotli \ - /usr/local/lib/pkgconfig/libbrotli* || exit 1 + # $DO_MAKE_UNINSTALL + $DO_RM -rf "$installation_prefix"/bin/brotli \ + "$installation_prefix"/lib/libbrotli* \ + "$installation_prefix"/include/brotli \ + "$installation_prefix"/lib/pkgconfig/libbrotli* # # brotli uses cmake on macOS and doesn't support "make distclean"; # just remove the enire build directory. # - # make distclean || exit 1 - rm -rf build_dir || exit 1 + # make distclean + rm -rf build_dir cd .. rm brotli-$installed_brotli_version-done @@ -2611,25 +2733,26 @@ uninstall_brotli() { install_minizip() { if [ "$ZLIB_VERSION" ] && [ ! -f minizip-$ZLIB_VERSION-done ] ; then echo "Downloading, building, and installing zlib for minizip:" - [ -f zlib-$ZLIB_VERSION.tar.gz ] || curl -L -o zlib-$ZLIB_VERSION.tar.gz https://zlib.net/zlib-$ZLIB_VERSION.tar.gz || exit 1 + [ -f zlib-$ZLIB_VERSION.tar.gz ] || curl "${CURL_LOCAL_NAME_OPTS[@]}" zlib-$ZLIB_VERSION.tar.gz https://zlib.net/fossils/zlib-$ZLIB_VERSION.tar.gz $no_build && echo "Skipping installation" && return - gzcat zlib-$ZLIB_VERSION.tar.gz | tar xf - || exit 1 + gzcat zlib-$ZLIB_VERSION.tar.gz | tar xf - # # minizip ships both with a minimal Makefile that doesn't # support "make install", "make uninstall", or "make distclean", # and with a Makefile.am file that, if we do an autoreconf, # gives us a configure script, and a Makefile.in that, if we run - # the configure script, gives us a Makefile that supports ll of + # the configure script, gives us a Makefile that supports all of # those targets, and that installs a pkg-config .pc file for # minizip. # # So that's what we do. # - cd zlib-$ZLIB_VERSION/contrib/minizip || exit 1 + cd zlib-$ZLIB_VERSION/contrib/minizip LIBTOOLIZE=glibtoolize autoreconf --force --install - CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" ./configure || exit 1 - make $MAKE_BUILD_OPTS || exit 1 - $DO_MAKE_INSTALL || exit 1 + CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=0 $VERSION_MIN_FLAGS $SDKFLAGS" LDFLAGS="$LDFLAGS $VERSION_MIN_FLAGS $SDKFLAGS" \ + ./configure "${CONFIGURE_OPTS[@]}" + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL cd ../../.. touch minizip-$ZLIB_VERSION-done fi @@ -2639,8 +2762,8 @@ uninstall_minizip() { if [ -n "$installed_minizip_version" ] ; then echo "Uninstalling minizip:" cd zlib-$installed_minizip_version/contrib/minizip - $DO_MAKE_UNINSTALL || exit 1 - make distclean || exit 1 + $DO_MAKE_UNINSTALL + make distclean cd ../../.. rm minizip-$installed_minizip_version-done @@ -2657,16 +2780,54 @@ uninstall_minizip() { fi } +install_minizip_ng() { + if [ "$MINIZIPNG_VERSION" ] && [ ! -f minizip-ng-$MINIZIPNG_VERSION-done ] ; then + echo "Downloading, building, and installing minizip-ng:" + [ -f $MINIZIPNG_VERSION.tar.gz ] || curl "${CURL_REMOTE_NAME_OPTS[@]}" https://github.com/zlib-ng/minizip-ng/archive/refs/tags/$MINIZIPNG_VERSION.tar.gz + $no_build && echo "Skipping installation" && return + gzcat $MINIZIPNG_VERSION.tar.gz | tar xf - + cd minizip-ng-$MINIZIPNG_VERSION + mkdir build + cd build + "${DO_CMAKE[@]}" .. + make "${MAKE_BUILD_OPTS[@]}" + $DO_MAKE_INSTALL + cd ../.. + touch minizip-ng-$MINIZIPNG_VERSION-done + fi +} + +uninstall_minizip_ng() { + if [ -n "$installed_minizip_ng_version" ] ; then + echo "Uninstalling minizip:" + cd minizip-ng-$installed_minizip_ng_version/contrib/minizip + $DO_MAKE_UNINSTALL + make distclean + cd ../../.. + + rm minizip-ng-$installed_minizip_ng_version-done + + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then + # + # Get rid of the previously downloaded and unpacked version. + # + rm -rf minizip-ng-$installed_minizip_ng_version + rm -rf minizip-ng-$installed_minizip_ng_version.tar.gz + fi + + installed_minizip_ng_version="" + fi +} install_sparkle() { if [ "$SPARKLE_VERSION" ] && [ ! -f sparkle-$SPARKLE_VERSION-done ] ; then echo "Downloading and installing Sparkle:" # - # Download the tarball and unpack it in /usr/local/Sparkle-x.y.z + # Download the tarball and unpack it in $installation_prefix/Sparkle-x.y.z # - [ -f Sparkle-$SPARKLE_VERSION.tar.xz ] || curl -L -o Sparkle-$SPARKLE_VERSION.tar.xz https://github.com/sparkle-project/Sparkle/releases/download/$SPARKLE_VERSION/Sparkle-$SPARKLE_VERSION.tar.xz || exit 1 + [ -f Sparkle-$SPARKLE_VERSION.tar.xz ] || curl "${CURL_LOCAL_NAME_OPTS[@]}" Sparkle-$SPARKLE_VERSION.tar.xz https://github.com/sparkle-project/Sparkle/releases/download/$SPARKLE_VERSION/Sparkle-$SPARKLE_VERSION.tar.xz $no_build && echo "Skipping installation" && return - test -d "/usr/local/Sparkle-$SPARKLE_VERSION" || sudo mkdir "/usr/local/Sparkle-$SPARKLE_VERSION" - sudo tar -C "/usr/local/Sparkle-$SPARKLE_VERSION" -xpof Sparkle-$SPARKLE_VERSION.tar.xz + test -d "$installation_prefix/Sparkle-$SPARKLE_VERSION" || sudo mkdir "$installation_prefix/Sparkle-$SPARKLE_VERSION" + sudo tar -C "$installation_prefix/Sparkle-$SPARKLE_VERSION" -xpof Sparkle-$SPARKLE_VERSION.tar.xz touch sparkle-$SPARKLE_VERSION-done fi } @@ -2674,7 +2835,10 @@ install_sparkle() { uninstall_sparkle() { if [ -n "$installed_sparkle_version" ]; then echo "Uninstalling Sparkle:" - sudo rm -rf "/usr/local/Sparkle-$installed_sparkle_version" + sudo rm -rf "$installation_prefix/Sparkle-$installed_sparkle_version" + + rm sparkle-$installed_sparkle_version-done + if [ "$#" -eq 1 ] && [ "$1" = "-r" ] ; then rm -f "Sparkle-$installed_sparkle_version.tar.xz" fi @@ -2688,7 +2852,7 @@ install_all() { # Check whether the versions we have installed are the versions # requested; if not, uninstall the installed versions. # - if [ ! -z "$installed_brotli_version" -a \ + if [ -n "$installed_brotli_version" -a \ "$installed_brotli_version" != "$BROTLI_VERSION" ] ; then echo "Installed brotli version is $installed_brotli_version" if [ -z "$BROTLI_VERSION" ] ; then @@ -2699,7 +2863,7 @@ install_all() { uninstall_brotli -r fi - if [ ! -z "$installed_python3_version" -a \ + if [ -n "$installed_python3_version" -a \ "$installed_python3_version" != "$PYTHON3_VERSION" ] ; then echo "Installed python3 version is $installed_python3_version" if [ -z "$PYTHON3_VERSION" ] ; then @@ -2710,7 +2874,7 @@ install_all() { uninstall_python3 -r fi - if [ ! -z "$installed_bcg729_version" -a \ + if [ -n "$installed_bcg729_version" -a \ "$installed_bcg729_version" != "$BCG729_VERSION" ] ; then echo "Installed bcg729 version is $installed_bcg729_version" if [ -z "$BCG729_VERSION" ] ; then @@ -2732,6 +2896,17 @@ install_all() { uninstall_ilbc -r fi + if [ -n "$installed_opencore_amr_version" ] \ + && [ "$installed_opencore_amr_version" != "$OPENCORE_AMR_VERSION" ] ; then + echo "Installed opencore-amr version is $installed_opencore_amr_version" + if [ -z "$OPENCORE_AMR_VERSION" ] ; then + echo "opencore-amr is not requested" + else + echo "Requested opencore-amr version is $OPENCORE_AMR_VERSION" + fi + uninstall_opencore_amr -r + fi + if [ -n "$installed_opus_version" ] \ && [ "$installed_opus_version" != "$OPUS_VERSION" ] ; then echo "Installed opus version is $installed_opus_version" @@ -2743,7 +2918,7 @@ install_all() { uninstall_opus -r fi - if [ ! -z "$installed_spandsp_version" -a \ + if [ -n "$installed_spandsp_version" -a \ "$installed_spandsp_version" != "$SPANDSP_VERSION" ] ; then echo "Installed SpanDSP version is $installed_spandsp_version" if [ -z "$SPANDSP_VERSION" ] ; then @@ -2754,7 +2929,7 @@ install_all() { uninstall_spandsp -r fi - if [ ! -z "$installed_speexdsp_version" -a \ + if [ -n "$installed_speexdsp_version" -a \ "$installed_speexdsp_version" != "$SPEEXDSP_VERSION" ] ; then echo "Installed SpeexDSP version is $installed_speexdsp_version" if [ -z "$SPEEXDSP_VERSION" ] ; then @@ -2765,7 +2940,7 @@ install_all() { uninstall_speexdsp -r fi - if [ ! -z "$installed_libtiff_version" -a \ + if [ -n "$installed_libtiff_version" -a \ "$installed_libtiff_version" != "$LIBTIFF_VERSION" ] ; then echo "Installed libtiff version is $installed_libtiff_version" if [ -z "$LIBTIFF_VERSION" ] ; then @@ -2776,7 +2951,7 @@ install_all() { uninstall_libtiff -r fi - if [ ! -z "$installed_nghttp2_version" -a \ + if [ -n "$installed_nghttp2_version" -a \ "$installed_nghttp2_version" != "$NGHTTP2_VERSION" ] ; then echo "Installed nghttp2 version is $installed_nghttp2_version" if [ -z "$NGHTTP2_VERSION" ] ; then @@ -2787,7 +2962,7 @@ install_all() { uninstall_nghttp2 -r fi - if [ ! -z "$installed_nghttp3_version" -a \ + if [ -n "$installed_nghttp3_version" -a \ "$installed_nghttp3_version" != "$NGHTTP3_VERSION" ] ; then echo "Installed nghttp3 version is $installed_nghttp3_version" if [ -z "$NGHTTP3_VERSION" ] ; then @@ -2798,7 +2973,7 @@ install_all() { uninstall_nghttp3 -r fi - if [ ! -z "$installed_libssh_version" -a \ + if [ -n "$installed_libssh_version" -a \ "$installed_libssh_version" != "$LIBSSH_VERSION" ] ; then echo "Installed libssh version is $installed_libssh_version" if [ -z "$LIBSSH_VERSION" ] ; then @@ -2809,7 +2984,7 @@ install_all() { uninstall_libssh -r fi - if [ ! -z "$installed_cares_version" -a \ + if [ -n "$installed_cares_version" -a \ "$installed_cares_version" != "$CARES_VERSION" ] ; then echo "Installed C-Ares version is $installed_cares_version" if [ -z "$CARES_VERSION" ] ; then @@ -2820,7 +2995,7 @@ install_all() { uninstall_c_ares -r fi - if [ ! -z "$installed_maxminddb_version" -a \ + if [ -n "$installed_maxminddb_version" -a \ "$installed_maxminddb_version" != "$MAXMINDDB_VERSION" ] ; then echo "Installed MaxMindDB API version is $installed_maxminddb_version" if [ -z "$MAXMINDDB_VERSION" ] ; then @@ -2831,7 +3006,7 @@ install_all() { uninstall_maxminddb -r fi - if [ ! -z "$installed_sbc_version" -a \ + if [ -n "$installed_sbc_version" -a \ "$installed_sbc_version" != "$SBC_VERSION" ] ; then echo "Installed SBC version is $installed_sbc_version" if [ -z "$SBC_VERSION" ] ; then @@ -2842,7 +3017,7 @@ install_all() { uninstall_sbc -r fi - if [ ! -z "$installed_lz4_version" -a \ + if [ -n "$installed_lz4_version" -a \ "$installed_lz4_version" != "$LZ4_VERSION" ] ; then echo "Installed LZ4 version is $installed_lz4_version" if [ -z "$LZ4_VERSION" ] ; then @@ -2853,7 +3028,7 @@ install_all() { uninstall_lz4 -r fi - if [ ! -z "$installed_libxml2_version" -a \ + if [ -n "$installed_libxml2_version" -a \ "$installed_libxml2_version" != "$LIBXML2_VERSION" ] ; then echo "Installed libxml2 version is $installed_libxml2_version" if [ -z "$LIBXML2_VERSION" ] ; then @@ -2864,7 +3039,7 @@ install_all() { uninstall_libxml2 -r fi - if [ ! -z "$installed_snappy_version" -a \ + if [ -n "$installed_snappy_version" -a \ "$installed_snappy_version" != "$SNAPPY_VERSION" ] ; then echo "Installed SNAPPY version is $installed_snappy_version" if [ -z "$SNAPPY_VERSION" ] ; then @@ -2875,7 +3050,27 @@ install_all() { uninstall_snappy -r fi - if [ ! -z "$installed_lua_version" -a \ + if [ -n "$installed_zstd_version" ] && [ "$installed_zstd_version" != "$ZSTD_VERSION" ] ; then + echo "Installed zstd version is $installed_zstd_version" + if [ -z "$ZSTD_VERSION" ] ; then + echo "zstd is not requested" + else + echo "Requested zstd version is $ZSTD_VERSION" + fi + uninstall_zstd -r + fi + + if [ -n "$installed_zlibng_version" ] && [ "$installed_zlibng_version" != "$ZLIBNG_VERSION" ] ; then + echo "Installed zlibng version is $installed_zlibng_version" + if [ -z "$ZLIBNG_VERSION" ] ; then + echo "zlibng is not requested" + else + echo "Requested zlibng version is $ZLIBNG_VERSION" + fi + uninstall_zlibng -r + fi + + if [ -n "$installed_lua_version" -a \ "$installed_lua_version" != "$LUA_VERSION" ] ; then echo "Installed Lua version is $installed_lua_version" if [ -z "$LUA_VERSION" ] ; then @@ -2886,8 +3081,7 @@ install_all() { uninstall_lua -r fi - if [ ! -z "$installed_gnutls_version" -a \ - "$installed_gnutls_version" != "$GNUTLS_VERSION" ] ; then + if [ -n "$installed_gnutls_version" ] && [ "$installed_gnutls_version" != "$GNUTLS_VERSION" ] ; then echo "Installed GnuTLS version is $installed_gnutls_version" if [ -z "$GNUTLS_VERSION" ] ; then echo "GnuTLS is not requested" @@ -2897,7 +3091,7 @@ install_all() { uninstall_gnutls -r fi - if [ ! -z "$installed_nettle_version" -a \ + if [ -n "$installed_nettle_version" -a \ "$installed_nettle_version" != "$NETTLE_VERSION" ] ; then echo "Installed Nettle version is $installed_nettle_version" if [ -z "$NETTLE_VERSION" ] ; then @@ -2908,7 +3102,7 @@ install_all() { uninstall_nettle -r fi - if [ ! -z "$installed_gmp_version" -a \ + if [ -n "$installed_gmp_version" -a \ "$installed_gmp_version" != "$GMP_VERSION" ] ; then echo "Installed GMP version is $installed_gmp_version" if [ -z "$GMP_VERSION" ] ; then @@ -2919,7 +3113,7 @@ install_all() { uninstall_gmp -r fi - if [ ! -z "$installed_p11_kit_version" -a \ + if [ -n "$installed_p11_kit_version" -a \ "$installed_p11_kit_version" != "$P11KIT_VERSION" ] ; then echo "Installed p11-kit version is $installed_p11_kit_version" if [ -z "$P11KIT_VERSION" ] ; then @@ -2930,7 +3124,7 @@ install_all() { uninstall_p11_kit -r fi - if [ ! -z "$installed_libtasn1_version" -a \ + if [ -n "$installed_libtasn1_version" -a \ "$installed_libtasn1_version" != "$LIBTASN1_VERSION" ] ; then echo "Installed libtasn1 version is $installed_libtasn1_version" if [ -z "$LIBTASN1_VERSION" ] ; then @@ -2941,7 +3135,7 @@ install_all() { uninstall_libtasn1 -r fi - if [ ! -z "$installed_libgcrypt_version" -a \ + if [ -n "$installed_libgcrypt_version" -a \ "$installed_libgcrypt_version" != "$LIBGCRYPT_VERSION" ] ; then echo "Installed libgcrypt version is $installed_libgcrypt_version" if [ -z "$LIBGCRYPT_VERSION" ] ; then @@ -2952,7 +3146,7 @@ install_all() { uninstall_libgcrypt -r fi - if [ ! -z "$installed_libgpg_error_version" -a \ + if [ -n "$installed_libgpg_error_version" -a \ "$installed_libgpg_error_version" != "$LIBGPG_ERROR_VERSION" ] ; then echo "Installed libgpg-error version is $installed_libgpg_error_version" if [ -z "$LIBGPG_ERROR_VERSION" ] ; then @@ -2963,7 +3157,7 @@ install_all() { uninstall_libgpg_error -r fi - if [ ! -z "$installed_libsmi_version" -a \ + if [ -n "$installed_libsmi_version" -a \ "$installed_libsmi_version" != "$LIBSMI_VERSION" ] ; then echo "Installed libsmi version is $installed_libsmi_version" if [ -z "$LIBSMI_VERSION" ] ; then @@ -2974,7 +3168,7 @@ install_all() { uninstall_libsmi -r fi - if [ ! -z "$installed_qt_version" -a \ + if [ -n "$installed_qt_version" -a \ "$installed_qt_version" != "$QT_VERSION" ] ; then echo "Installed Qt version is $installed_qt_version" if [ -z "$QT_VERSION" ] ; then @@ -2985,7 +3179,7 @@ install_all() { uninstall_qt -r fi - if [ ! -z "$installed_glib_version" -a \ + if [ -n "$installed_glib_version" -a \ "$installed_glib_version" != "$GLIB_VERSION" ] ; then echo "Installed GLib version is $installed_glib_version" if [ -z "$GLIB_VERSION" ] ; then @@ -2996,7 +3190,7 @@ install_all() { uninstall_glib -r fi - if [ ! -z "$installed_pkg_config_version" -a \ + if [ -n "$installed_pkg_config_version" -a \ "$installed_pkg_config_version" != "$PKG_CONFIG_VERSION" ] ; then echo "Installed pkg-config version is $installed_pkg_config_version" if [ -z "$PKG_CONFIG_VERSION" ] ; then @@ -3007,7 +3201,7 @@ install_all() { uninstall_pkg_config -r fi - if [ ! -z "$installed_gettext_version" -a \ + if [ -n "$installed_gettext_version" -a \ "$installed_gettext_version" != "$GETTEXT_VERSION" ] ; then echo "Installed GNU gettext version is $installed_gettext_version" if [ -z "$GETTEXT_VERSION" ] ; then @@ -3018,7 +3212,7 @@ install_all() { uninstall_gettext -r fi - if [ ! -z "$installed_ninja_version" -a \ + if [ -n "$installed_ninja_version" -a \ "$installed_ninja_version" != "$NINJA_VERSION" ] ; then echo "Installed Ninja version is $installed_ninja_version" if [ -z "$NINJA_VERSION" ] ; then @@ -3029,7 +3223,7 @@ install_all() { uninstall_ninja -r fi - if [ ! -z "$installed_asciidoctorpdf_version" -a \ + if [ -n "$installed_asciidoctorpdf_version" -a \ "$installed_asciidoctorpdf_version" != "$ASCIIDOCTORPDF_VERSION" ] ; then echo "Installed Asciidoctor-pdf version is $installed_asciidoctorpdf_version" if [ -z "$ASCIIDOCTORPDF_VERSION" ] ; then @@ -3044,7 +3238,7 @@ install_all() { uninstall_asciidoctorpdf -r fi - if [ ! -z "$installed_asciidoctor_version" -a \ + if [ -n "$installed_asciidoctor_version" -a \ "$installed_asciidoctor_version" != "$ASCIIDOCTOR_VERSION" ] ; then echo "Installed Asciidoctor version is $installed_asciidoctor_version" if [ -z "$ASCIIDOCTOR_VERSION" ] ; then @@ -3059,7 +3253,7 @@ install_all() { uninstall_asciidoctor -r fi - if [ ! -z "$installed_cmake_version" -a \ + if [ -n "$installed_cmake_version" -a \ "$installed_cmake_version" != "$CMAKE_VERSION" ] ; then echo "Installed CMake version is $installed_cmake_version" if [ -z "$CMAKE_VERSION" ] ; then @@ -3070,7 +3264,7 @@ install_all() { uninstall_cmake -r fi - if [ ! -z "$installed_libtool_version" -a \ + if [ -n "$installed_libtool_version" -a \ "$installed_libtool_version" != "$LIBTOOL_VERSION" ] ; then echo "Installed GNU libtool version is $installed_libtool_version" if [ -z "$LIBTOOL_VERSION" ] ; then @@ -3081,7 +3275,7 @@ install_all() { uninstall_libtool -r fi - if [ ! -z "$installed_automake_version" -a \ + if [ -n "$installed_automake_version" -a \ "$installed_automake_version" != "$AUTOMAKE_VERSION" ] ; then echo "Installed GNU automake version is $installed_automake_version" if [ -z "$AUTOMAKE_VERSION" ] ; then @@ -3092,7 +3286,7 @@ install_all() { uninstall_automake -r fi - if [ ! -z "$installed_autoconf_version" -a \ + if [ -n "$installed_autoconf_version" -a \ "$installed_autoconf_version" != "$AUTOCONF_VERSION" ] ; then echo "Installed GNU autoconf version is $installed_autoconf_version" if [ -z "$AUTOCONF_VERSION" ] ; then @@ -3103,14 +3297,9 @@ install_all() { uninstall_autoconf -r fi - if [ ! -z "$installed_pcre_version" -a \ - "$installed_pcre_version" != "$PCRE_VERSION" ] ; then - echo "Installed pcre version is $installed_pcre_version" - if [ -z "$PCRE_VERSION" ] ; then - echo "pcre is not requested" - else - echo "Requested pcre version is $PCRE_VERSION" - fi + if [ -n "$installed_pcre_version" ] ; then + echo "Installed pcre1 version is $installed_pcre_version" + echo "(We no longer build with pcre1)" uninstall_pcre -r fi @@ -3125,18 +3314,12 @@ install_all() { uninstall_pcre2 -r fi - if [ ! -z "$installed_lzip_version" -a \ - "$installed_lzip_version" != "$LZIP_VERSION" ] ; then - echo "Installed lzip version is $installed_lzip_version" - if [ -z "$LZIP_VERSION" ] ; then - echo "lzip is not requested" - else - echo "Requested lzip version is $LZIP_VERSION" - fi + if [ -n "$installed_lzip_version" ] ; then + echo "Removing legacy install of lzip" uninstall_lzip -r fi - if [ ! -z "$installed_xz_version" -a \ + if [ -n "$installed_xz_version" -a \ "$installed_xz_version" != "$XZ_VERSION" ] ; then echo "Installed xz version is $installed_xz_version" if [ -z "$XZ_VERSION" ] ; then @@ -3147,7 +3330,7 @@ install_all() { uninstall_xz -r fi - if [ ! -z "$installed_curl_version" -a \ + if [ -n "$installed_curl_version" -a \ "$installed_curl_version" != "$CURL_VERSION" ] ; then echo "Installed curl version is $installed_curl_version" if [ -z "$CURL_VERSION" ] ; then @@ -3158,7 +3341,7 @@ install_all() { uninstall_curl -r fi - if [ ! -z "$installed_minizip_version" -a \ + if [ -n "$installed_minizip_version" -a \ "$installed_minizip_version" != "$ZLIB_VERSION" ] ; then echo "Installed minizip (zlib) version is $installed_minizip_version" if [ -z "$ZLIB_VERSION" ] ; then @@ -3169,7 +3352,17 @@ install_all() { uninstall_minizip -r fi - if [ ! -z "$installed_sparkle_version" -a \ + if [ -n "$installed_minizip_ng_version" ] && [ "$installed_minizip_ng_version" != "$MINIZIPNG_VERSION" ] ; then + echo "Installed minizip-ng version is $installed_minizip_ng_version" + if [ -z "$MINIZIPNG_VERSION" ] ; then + echo "minizip-ng is not requested" + else + echo "Requested minizip-ng version is $MINIZIPNG_VERSION" + fi + uninstall_minizip_ng -r + fi + + if [ -n "$installed_sparkle_version" -a \ "$installed_sparkle_version" != "$SPARKLE_VERSION" ] ; then echo "Installed Sparkle version is $installed_sparkle_version" if [ -z "$SPARKLE_VERSION" ] ; then @@ -3180,20 +3373,56 @@ install_all() { uninstall_sparkle -r fi + if [ "$installed_falco_libs_version" ] && [ "$installed_falco_libs_version" != "$FALCO_LIBS_VERSION" ] ; then + echo "Installed Falco libs (libsinsp and libscap) version is $installed_falco_libs_version" + if [ -z "$FALCO_LIBS_VERSION" ] ; then + echo "Falco libs is not requested" + else + echo "Requested Falco libs version is $FALCO_LIBS_VERSION" + fi + uninstall_falco_libs -r + fi + + if [ "$installed_jsoncpp_version" ] && [ "$installed_jsoncpp_version" != "$JSONCPP_VERSION" ] ; then + echo "Installed JsonCpp version is $installed_jsoncpp_version" + if [ -z "$JSONCPP_VERSION" ] ; then + echo "JsonCpp is not requested" + else + echo "Requested JsonCpp version is $JSONCPP_VERSION" + fi + uninstall_jsoncpp -r + fi + + if [ "$installed_onetbb_version" ] && [ "$installed_onetbb_version" != "$ONETBB_VERSION" ] ; then + echo "Installed oneTBB version is $installed_onetbb_version" + if [ -z "$ONETBB_VERSION" ] ; then + echo "oneTBB is not requested" + else + echo "Requested oneTBB version is $ONETBB_VERSION" + fi + uninstall_onetbb -r + fi + + if [ "$installed_re2_version" ] && [ "$installed_re2_version" != "$RE2_VERSION" ] ; then + echo "Installed RE2 version is $installed_re2_version" + if [ -z "$RE2_VERSION" ] ; then + echo "RE2 is not requested" + else + echo "Requested RE2 version is $RE2_VERSION" + fi + uninstall_re2 -r + fi + # # Start with curl: we may need it to download and install xz. # install_curl # - # Now intall xz: it is the sole download format of glib later than 2.31.2. + # Now install xz: it is the sole download format of glib later than 2.31.2. # install_xz - install_lzip - - install_pcre - install_autoconf install_automake @@ -3284,6 +3513,8 @@ install_all() { install_zstd + install_zlibng + install_libxml2 install_lz4 @@ -3310,13 +3541,25 @@ install_all() { install_ilbc + install_opencore_amr + install_opus install_brotli install_minizip + install_minizip_ng + install_sparkle + + install_re2 + + install_onetbb + + install_jsoncpp + + install_falco_libs } uninstall_all() { @@ -3333,14 +3576,26 @@ uninstall_all() { # We also do a "make distclean", so that we don't have leftovers from # old configurations. # + uninstall_falco_libs + + uninstall_jsoncpp + + uninstall_onetbb + + uninstall_re2 + uninstall_sparkle uninstall_minizip + uninstall_minizip_ng + uninstall_brotli uninstall_opus + uninstall_opencore_amr + uninstall_ilbc uninstall_bcg729 @@ -3365,6 +3620,8 @@ uninstall_all() { uninstall_zstd + uninstall_zlibng + uninstall_libxml2 uninstall_lz4 @@ -3424,6 +3681,7 @@ uninstall_all() { uninstall_pcre + # Legacy, remove uninstall_lzip uninstall_xz @@ -3432,66 +3690,12 @@ uninstall_all() { fi } -# -# Do we have permission to write in /usr/local? -# -# If so, assume we have permission to write in its subdirectories. -# (If that's not the case, this test needs to check the subdirectories -# as well.) -# -# If not, do "make install", "make uninstall", "ninja install", -# "ninja uninstall", the removes for dependencies that don't support -# "make uninstall" or "ninja uninstall", the renames of [g]libtool*, -# and the writing of a libffi .pc file with sudo. -# -if [ -w /usr/local ] -then - DO_MAKE_INSTALL="make install" - DO_MAKE_UNINSTALL="make uninstall" - DO_NINJA_INSTALL="ninja -C _build install" - DO_NINJA_UNINSTALL="ninja -C _build uninstall" - DO_TEE_TO_PC_FILE="tee" - DO_RM="rm" - DO_MV="mv" -else - DO_MAKE_INSTALL="sudo make install" - DO_MAKE_UNINSTALL="sudo make uninstall" - DO_NINJA_INSTALL="sudo ninja -C _build install" - DO_NINJA_UNINSTALL="sudo ninja -C _build uninstall" - DO_TEE_TO_PC_FILE="sudo tee" - DO_RM="sudo rm" - DO_MV="sudo mv" -fi - -# -# When building with CMake, don't build libraries with an install path -# that begins with @rpath because that will cause binaries linked with it -# to use that path as the library to look for, and that will cause the -# run-time linker, at least on macOS 14 and later, not to find the library -# in /usr/local/lib unless you explicitly set DYLD_LIBRARY_PATH to include -# /usr/local/lib. That means that you get "didn't find libpcre" errors if -# you try to run binaries from a build unless you set DYLD_LIBRARYPATH to -# include /usr/local/lib. -# -# However, setting CMAKE_MACOSX_RPATH to OFF causes the installed -# library just to have the file name of the library as its install -# name. It needs to be the full installed path of the library in -# order to make running binaries from the build directory work, so -# we set CMAKE_INSTALL_NAME_DIR to /usr/local/lib. -# -# packaging/macosx/osx-app.sh will convert *all* libraries in -# the app bundle to have an @rpath install name, so this won't -# break anything there; it just fixes the ability to run from the -# build directory. -# -DO_CMAKE="cmake -DCMAKE_MACOSX_RPATH=OFF -DCMAKE_INSTALL_NAME_DIR=/usr/local/lib" - # This script is meant to be run in the source root. The following -# code will attempt to get you there, but is not perfect (particulary +# code will attempt to get you there, but is not perfect (particularly # if someone copies the script). -topdir=`pwd`/`dirname $0`/.. -cd $topdir +topdir="$( pwd )/$( dirname "$0" )/.." +cd "$topdir" # Preference of the support libraries directory: # ${MACOSX_SUPPORT_LIBS} @@ -3517,7 +3721,7 @@ for i in /Developer/SDKs \ do if [ -d "$i" ] then - min_osx_target=`sw_vers -productVersion | sed 's/\([0-9]*\)\.\([0-9]*\)\.[0-9]*/\1.\2/'` + min_osx_target=$( sw_vers -productVersion | sed 's/\([0-9]*\)\.\([0-9]*\)\.[0-9]*/\1.\2/' ) break fi done @@ -3534,78 +3738,159 @@ done no_build=false -while getopts ht:un name +installation_prefix=/usr/local + +while getopts hnp:t:u name do case $name in - u) - do_uninstall=yes + h|\?) + echo "Usage: macos-setup.sh [ -n ] [ -p <installation prefix> ] [ -t <target> ] [ -u ]" 1>&1 + exit 0 ;; n) no_build=true ;; + p) + installation_prefix="$OPTARG" + ;; t) min_osx_target="$OPTARG" ;; - h|?) - echo "Usage: macos-setup.sh [ -t <target> ] [ -u ] [ -n ]" 1>&1 - exit 0 + u) + do_uninstall=yes ;; esac done # +# Create our custom installation prefix if needed. +# +if [ "$installation_prefix" != "/usr/local" ] ; then + export PATH="$installation_prefix/bin:$PATH" + if [ ! -d "$installation_prefix" ] ; then + echo "Creating $installation_prefix" + $DO_MKDIR "$installation_prefix" + fi +fi + +# +# Do we have permission to write in $installation_prefix? +# +# If so, assume we have permission to write in its subdirectories. +# (If that's not the case, this test needs to check the subdirectories +# as well.) +# +# If not, do "make install", "make uninstall", "ninja install", +# "ninja uninstall", the removes for dependencies that don't support +# "make uninstall" or "ninja uninstall", the renames of [g]libtool*, +# and the writing of a libffi .pc file with sudo. +# +if [ -w "$installation_prefix" ] +then + DO_MAKE="make" + DO_MAKE_INSTALL="make install" + DO_MAKE_UNINSTALL="make uninstall" + DO_NINJA_INSTALL="ninja -C _build install" + DO_NINJA_UNINSTALL="ninja -C _build uninstall" + DO_TEE_TO_PC_FILE="tee" + DO_RM="rm" + DO_MV="mv" +else + DO_MAKE="sudo make" + DO_MAKE_INSTALL="sudo make install" + DO_MAKE_UNINSTALL="sudo make uninstall" + DO_NINJA_INSTALL="sudo ninja -C _build install" + DO_NINJA_UNINSTALL="sudo ninja -C _build uninstall" + DO_TEE_TO_PC_FILE="sudo tee" + DO_RM="sudo rm" + DO_MV="sudo mv" +fi + +# +# When building with CMake, don't build libraries with an install path +# that begins with @rpath because that will cause binaries linked with it +# to use that path as the library to look for, and that will cause the +# run-time linker, at least on macOS 14 and later, not to find the library +# in $installation_prefix/lib unless you explicitly set DYLD_LIBRARY_PATH to include +# $installation_prefix/lib. That means that you get "didn't find libpcre" errors if +# you try to run binaries from a build unless you set DYLD_LIBRARYPATH to +# include $installation_prefix/lib. +# +# However, setting CMAKE_MACOSX_RPATH to OFF causes the installed +# library just to have the file name of the library as its install +# name. It needs to be the full installed path of the library in +# order to make running binaries from the build directory work, so +# we set CMAKE_INSTALL_NAME_DIR to $installation_prefix/lib. +# +# packaging/macosx/osx-app.sh will convert *all* libraries in +# the app bundle to have an @rpath install name, so this won't +# break anything there; it just fixes the ability to run from the +# build directory. +# +DO_CMAKE=( cmake + -DCMAKE_OSX_DEPLOYMENT_TARGET="$min_osx_target" + -DSDKROOT="$SDKPATH" + -DCMAKE_MACOSX_RPATH=OFF + -DCMAKE_INSTALL_PREFIX="$installation_prefix" + -DCMAKE_INSTALL_NAME_DIR="$installation_prefix/lib" + ) + +# # Get the version numbers of installed packages, if any. # if [ -d "${MACOSX_SUPPORT_LIBS}" ] then cd "${MACOSX_SUPPORT_LIBS}" - installed_xz_version=`ls xz-*-done 2>/dev/null | sed 's/xz-\(.*\)-done/\1/'` - installed_lzip_version=`ls lzip-*-done 2>/dev/null | sed 's/lzip-\(.*\)-done/\1/'` - installed_pcre_version=`ls pcre-*-done 2>/dev/null | sed 's/pcre-\(.*\)-done/\1/'` - installed_pcre2_version=$(ls pcre2-*-done 2>/dev/null | sed 's/pcre2-\(.*\)-done/\1/') - installed_autoconf_version=`ls autoconf-*-done 2>/dev/null | sed 's/autoconf-\(.*\)-done/\1/'` - installed_automake_version=`ls automake-*-done 2>/dev/null | sed 's/automake-\(.*\)-done/\1/'` - installed_libtool_version=`ls libtool-*-done 2>/dev/null | sed 's/libtool-\(.*\)-done/\1/'` - installed_cmake_version=`ls cmake-*-done 2>/dev/null | sed 's/cmake-\(.*\)-done/\1/'` - installed_ninja_version=`ls ninja-*-done 2>/dev/null | sed 's/ninja-\(.*\)-done/\1/'` - installed_asciidoctor_version=`ls asciidoctor-*-done 2>/dev/null | sed 's/asciidoctor-\(.*\)-done/\1/'` - installed_asciidoctorpdf_version=`ls asciidoctorpdf-*-done 2>/dev/null | sed 's/asciidoctorpdf-\(.*\)-done/\1/'` - installed_gettext_version=`ls gettext-*-done 2>/dev/null | sed 's/gettext-\(.*\)-done/\1/'` - installed_pkg_config_version=`ls pkg-config-*-done 2>/dev/null | sed 's/pkg-config-\(.*\)-done/\1/'` - installed_glib_version=`ls glib-*-done 2>/dev/null | sed 's/glib-\(.*\)-done/\1/'` - installed_qt_version=`ls qt-*-done 2>/dev/null | sed 's/qt-\(.*\)-done/\1/'` - installed_libsmi_version=`ls libsmi-*-done 2>/dev/null | sed 's/libsmi-\(.*\)-done/\1/'` - installed_libgpg_error_version=`ls libgpg-error-*-done 2>/dev/null | sed 's/libgpg-error-\(.*\)-done/\1/'` - installed_libgcrypt_version=`ls libgcrypt-*-done 2>/dev/null | sed 's/libgcrypt-\(.*\)-done/\1/'` - installed_gmp_version=`ls gmp-*-done 2>/dev/null | sed 's/gmp-\(.*\)-done/\1/'` - installed_libtasn1_version=`ls libtasn1-*-done 2>/dev/null | sed 's/libtasn1-\(.*\)-done/\1/'` - installed_p11_kit_version=`ls p11-kit-*-done 2>/dev/null | sed 's/p11-kit-\(.*\)-done/\1/'` - installed_nettle_version=`ls nettle-*-done 2>/dev/null | sed 's/nettle-\(.*\)-done/\1/'` - installed_gnutls_version=`ls gnutls-*-done 2>/dev/null | sed 's/gnutls-\(.*\)-done/\1/'` - installed_lua_version=`ls lua-*-done 2>/dev/null | sed 's/lua-\(.*\)-done/\1/'` - installed_snappy_version=`ls snappy-*-done 2>/dev/null | sed 's/snappy-\(.*\)-done/\1/'` - installed_zstd_version=`ls zstd-*-done 2>/dev/null | sed 's/zstd-\(.*\)-done/\1/'` - installed_libxml2_version=`ls libxml2-*-done 2>/dev/null | sed 's/libxml2-\(.*\)-done/\1/'` - installed_lz4_version=`ls lz4-*-done 2>/dev/null | sed 's/lz4-\(.*\)-done/\1/'` - installed_sbc_version=`ls sbc-*-done 2>/dev/null | sed 's/sbc-\(.*\)-done/\1/'` - installed_maxminddb_version=`ls maxminddb-*-done 2>/dev/null | sed 's/maxminddb-\(.*\)-done/\1/'` - installed_cares_version=`ls c-ares-*-done 2>/dev/null | sed 's/c-ares-\(.*\)-done/\1/'` - installed_libssh_version=`ls libssh-*-done 2>/dev/null | sed 's/libssh-\(.*\)-done/\1/'` - installed_nghttp2_version=`ls nghttp2-*-done 2>/dev/null | sed 's/nghttp2-\(.*\)-done/\1/'` - installed_nghttp3_version=`ls nghttp3-*-done 2>/dev/null | sed 's/nghttp3-\(.*\)-done/\1/'` - installed_libtiff_version=`ls tiff-*-done 2>/dev/null | sed 's/tiff-\(.*\)-done/\1/'` - installed_spandsp_version=`ls spandsp-*-done 2>/dev/null | sed 's/spandsp-\(.*\)-done/\1/'` - installed_speexdsp_version=`ls speexdsp-*-done 2>/dev/null | sed 's/speexdsp-\(.*\)-done/\1/'` - installed_bcg729_version=`ls bcg729-*-done 2>/dev/null | sed 's/bcg729-\(.*\)-done/\1/'` - installed_ilbc_version=`ls ilbc-*-done 2>/dev/null | sed 's/ilbc-\(.*\)-done/\1/'` - installed_opus_version=`ls opus-*-done 2>/dev/null | sed 's/opus-\(.*\)-done/\1/'` - installed_python3_version=`ls python3-*-done 2>/dev/null | sed 's/python3-\(.*\)-done/\1/'` - installed_brotli_version=`ls brotli-*-done 2>/dev/null | sed 's/brotli-\(.*\)-done/\1/'` - installed_minizip_version=`ls minizip-*-done 2>/dev/null | sed 's/minizip-\(.*\)-done/\1/'` - installed_sparkle_version=`ls sparkle-*-done 2>/dev/null | sed 's/sparkle-\(.*\)-done/\1/'` - - cd $topdir + installed_xz_version=$( ls xz-*-done 2>/dev/null | sed 's/xz-\(.*\)-done/\1/' ) + installed_lzip_version=$( ls lzip-*-done 2>/dev/null | sed 's/lzip-\(.*\)-done/\1/' ) + installed_pcre_version=$( ls pcre-*-done 2>/dev/null | sed 's/pcre-\(.*\)-done/\1/' ) + installed_pcre2_version=$( ls pcre2-*-done 2>/dev/null | sed 's/pcre2-\(.*\)-done/\1/' ) + installed_autoconf_version=$( ls autoconf-*-done 2>/dev/null | sed 's/autoconf-\(.*\)-done/\1/' ) + installed_automake_version=$( ls automake-*-done 2>/dev/null | sed 's/automake-\(.*\)-done/\1/' ) + installed_libtool_version=$( ls libtool-*-done 2>/dev/null | sed 's/libtool-\(.*\)-done/\1/' ) + installed_cmake_version=$( ls cmake-*-done 2>/dev/null | sed 's/cmake-\(.*\)-done/\1/' ) + installed_ninja_version=$( ls ninja-*-done 2>/dev/null | sed 's/ninja-\(.*\)-done/\1/' ) + installed_asciidoctor_version=$( ls asciidoctor-*-done 2>/dev/null | sed 's/asciidoctor-\(.*\)-done/\1/' ) + installed_asciidoctorpdf_version=$( ls asciidoctorpdf-*-done 2>/dev/null | sed 's/asciidoctorpdf-\(.*\)-done/\1/' ) + installed_gettext_version=$( ls gettext-*-done 2>/dev/null | sed 's/gettext-\(.*\)-done/\1/' ) + installed_pkg_config_version=$( ls pkg-config-*-done 2>/dev/null | sed 's/pkg-config-\(.*\)-done/\1/' ) + installed_glib_version=$( ls glib-*-done 2>/dev/null | sed 's/glib-\(.*\)-done/\1/' ) + installed_qt_version=$( ls qt-*-done 2>/dev/null | sed 's/qt-\(.*\)-done/\1/' ) + installed_libsmi_version=$( ls libsmi-*-done 2>/dev/null | sed 's/libsmi-\(.*\)-done/\1/' ) + installed_libgpg_error_version=$( ls libgpg-error-*-done 2>/dev/null | sed 's/libgpg-error-\(.*\)-done/\1/' ) + installed_libgcrypt_version=$( ls libgcrypt-*-done 2>/dev/null | sed 's/libgcrypt-\(.*\)-done/\1/' ) + installed_gmp_version=$( ls gmp-*-done 2>/dev/null | sed 's/gmp-\(.*\)-done/\1/' ) + installed_libtasn1_version=$( ls libtasn1-*-done 2>/dev/null | sed 's/libtasn1-\(.*\)-done/\1/' ) + installed_p11_kit_version=$( ls p11-kit-*-done 2>/dev/null | sed 's/p11-kit-\(.*\)-done/\1/' ) + installed_nettle_version=$( ls nettle-*-done 2>/dev/null | sed 's/nettle-\(.*\)-done/\1/' ) + installed_gnutls_version=$( ls gnutls-*-done 2>/dev/null | sed 's/gnutls-\(.*\)-done/\1/' ) + installed_lua_version=$( ls lua-*-done 2>/dev/null | sed 's/lua-\(.*\)-done/\1/' ) + installed_snappy_version=$( ls snappy-*-done 2>/dev/null | sed 's/snappy-\(.*\)-done/\1/' ) + installed_zstd_version=$( ls zstd-*-done 2>/dev/null | sed 's/zstd-\(.*\)-done/\1/' ) + installed_zlibng_version=$( ls zlibng-*-done 2>/dev/null | sed 's/zlibng-\(.*\)-done/\1/' ) + installed_libxml2_version=$( ls libxml2-*-done 2>/dev/null | sed 's/libxml2-\(.*\)-done/\1/' ) + installed_lz4_version=$( ls lz4-*-done 2>/dev/null | sed 's/lz4-\(.*\)-done/\1/' ) + installed_sbc_version=$( ls sbc-*-done 2>/dev/null | sed 's/sbc-\(.*\)-done/\1/' ) + installed_maxminddb_version=$( ls maxminddb-*-done 2>/dev/null | sed 's/maxminddb-\(.*\)-done/\1/' ) + installed_cares_version=$( ls c-ares-*-done 2>/dev/null | sed 's/c-ares-\(.*\)-done/\1/' ) + installed_libssh_version=$( ls libssh-*-done 2>/dev/null | sed 's/libssh-\(.*\)-done/\1/' ) + installed_nghttp2_version=$( ls nghttp2-*-done 2>/dev/null | sed 's/nghttp2-\(.*\)-done/\1/' ) + installed_nghttp3_version=$( ls nghttp3-*-done 2>/dev/null | sed 's/nghttp3-\(.*\)-done/\1/' ) + installed_libtiff_version=$( ls tiff-*-done 2>/dev/null | sed 's/tiff-\(.*\)-done/\1/' ) + installed_spandsp_version=$( ls spandsp-*-done 2>/dev/null | sed 's/spandsp-\(.*\)-done/\1/' ) + installed_speexdsp_version=$( ls speexdsp-*-done 2>/dev/null | sed 's/speexdsp-\(.*\)-done/\1/' ) + installed_bcg729_version=$( ls bcg729-*-done 2>/dev/null | sed 's/bcg729-\(.*\)-done/\1/' ) + installed_ilbc_version=$( ls ilbc-*-done 2>/dev/null | sed 's/ilbc-\(.*\)-done/\1/' ) + installed_opencore_amr_version=$( ls opencore-amr-*-done 2>/dev/null | sed 's/opencore-amr-\(.*\)-done/\1/' ) + installed_opus_version=$( ls opus-*-done 2>/dev/null | sed 's/opus-\(.*\)-done/\1/' ) + installed_python3_version=$( ls python3-*-done 2>/dev/null | sed 's/python3-\(.*\)-done/\1/' ) + installed_brotli_version=$( ls brotli-*-done 2>/dev/null | sed 's/brotli-\(.*\)-done/\1/' ) + installed_minizip_version=$( ls minizip-*-done 2>/dev/null | sed 's/minizip-\(.*\)-done/\1/' ) + installed_minizip_ng_version=$( ls minizip-ng-*-done 2>/dev/null | sed 's/minizip-ng-\(.*\)-done/\1/' ) + installed_sparkle_version=$( ls sparkle-*-done 2>/dev/null | sed 's/sparkle-\(.*\)-done/\1/' ) + + cd "$topdir" fi if [ "$do_uninstall" = "yes" ] @@ -3621,15 +3906,22 @@ fi # However, we *are* setting them in the environment, for our own # nefarious purposes, so start them out as "-g -O2". # -CFLAGS="-g -O2" -CXXFLAGS="-g -O2" +export CFLAGS="-g -O2 -I$installation_prefix/include" +export CXXFLAGS="-g -O2 -I$installation_prefix/include" +export LDFLAGS="-L$installation_prefix/lib" +export PKG_CONFIG_PATH="$installation_prefix/lib/pkgconfig" +CONFIGURE_OPTS=( --prefix="$installation_prefix" ) # if no make options are present, set default options +# Should we just set MAKEFLAGS instead? if [ -z "$MAKE_BUILD_OPTS" ] ; then # by default use 1.5x number of cores for parallel build - MAKE_BUILD_OPTS="-j $(( $(sysctl -n hw.logicalcpu) * 3 / 2))" + MAKE_BUILD_OPTS=( -j $(( $(sysctl -n hw.logicalcpu) * 3 / 2)) ) fi +CURL_REMOTE_NAME_OPTS=(--fail-with-body --location --remote-name) +CURL_LOCAL_NAME_OPTS=(--fail-with-body --location --output) + # # If we have a target release, look for the oldest SDK that's for an # OS equal to or later than that one, and build libraries against it @@ -3639,7 +3931,7 @@ fi # versions of the same release, or earlier releases if the minimum is # earlier. # -if [ ! -z "$min_osx_target" ] +if [ -n "$min_osx_target" ] then # # Get the major and minor version of the target release. @@ -3651,8 +3943,8 @@ then # # major.minor. # - min_osx_target_major=`echo "$min_osx_target" | sed -n 's/\([1-9][0-9]*\)\..*/\1/p'` - min_osx_target_minor=`echo "$min_osx_target" | sed -n 's/[1-9][0-9]*\.\(.*\)/\1/p'` + min_osx_target_major=$( echo "$min_osx_target" | sed -n 's/\([1-9][0-9]*\)\..*/\1/p' ) + min_osx_target_minor=$( echo "$min_osx_target" | sed -n 's/[1-9][0-9]*\.\(.*\)/\1/p' ) ;; [1-9][0-9]) @@ -3694,15 +3986,15 @@ then # Get a list of all the SDKs in that directory, if any. # We assume it'll be a while before there's a macOS 100. :-) # - sdklist=`(cd "$sdksdir"; ls -d MacOSX[1-9][0-9].[0-9]*.sdk 2>/dev/null)` + sdklist=$( (cd "$sdksdir"; ls -d MacOSX[1-9][0-9].[0-9]*.sdk 2>/dev/null) ) for sdk in $sdklist do # # Get the major and minor version for this SDK. # - sdk_major=`echo "$sdk" | sed -n 's/MacOSX\([1-9][0-9]*\)\..*\.sdk/\1/p'` - sdk_minor=`echo "$sdk" | sed -n 's/MacOSX[1-9][0-9]*\.\(.*\)\.sdk/\1/p'` + sdk_major=$( echo "$sdk" | sed -n 's/MacOSX\([1-9][0-9]*\)\..*\.sdk/\1/p' ) + sdk_minor=$( echo "$sdk" | sed -n 's/MacOSX[1-9][0-9]*\.\(.*\)\.sdk/\1/p' ) # # Is it for the deployment target or some later release? @@ -3732,30 +4024,31 @@ then echo "Using the $sdk_major.$sdk_minor SDK" # - # Make sure there are links to /usr/local/include and /usr/local/lib + # Make sure there are links to $installation_prefix/include and $installation_prefix/lib # in the SDK's usr/local. # - if [ ! -e $SDKPATH/usr/local/include ] - then - if [ ! -d $SDKPATH/usr/local ] - then - sudo mkdir $SDKPATH/usr/local - fi - sudo ln -s /usr/local/include $SDKPATH/usr/local/include - fi - if [ ! -e $SDKPATH/usr/local/lib ] - then - if [ ! -d $SDKPATH/usr/local ] - then - sudo mkdir $SDKPATH/usr/local - fi - sudo ln -s /usr/local/lib $SDKPATH/usr/local/lib - fi + # XXX - Is this needed any more? +# if [ ! -e $SDKPATH$installation_prefix/include ] +# then +# if [ ! -d $SDKPATH$installation_prefix ] +# then +# sudo mkdir $SDKPATH$installation_prefix +# fi +# sudo ln -s $installation_prefix/include $SDKPATH$installation_prefix/include +# fi +# if [ ! -e $SDKPATH$installation_prefix/lib ] +# then +# if [ ! -d $SDKPATH$installation_prefix ] +# then +# sudo mkdir $SDKPATH$installation_prefix +# fi +# sudo ln -s $installation_prefix/lib $SDKPATH$installation_prefix/lib +# fi # # Set the minimum OS version for which to build to the specified # minimum target OS version, so we don't, for example, end up using - # linker features supported by the OS verson on which we're building + # linker features supported by the OS version on which we're building # but not by the target version. # VERSION_MIN_FLAGS="-mmacosx-version-min=$min_osx_target" @@ -3767,9 +4060,6 @@ then fi -export CFLAGS -export CXXFLAGS - # # You need Xcode or the command-line tools installed to get the compilers (xcrun checks both). # @@ -3801,15 +4091,13 @@ if [ "$QT_VERSION" ]; then fi fi -export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig - # # Do all the downloads and untarring in a subdirectory, so all that # stuff can be removed once we've installed the support libraries. if [ ! -d "${MACOSX_SUPPORT_LIBS}" ] then - mkdir "${MACOSX_SUPPORT_LIBS}" || exit 1 + mkdir "${MACOSX_SUPPORT_LIBS}" fi cd "${MACOSX_SUPPORT_LIBS}" @@ -3820,11 +4108,9 @@ echo "" # # Indicate what paths to use for pkg-config and cmake. # -pkg_config_path=/usr/local/lib/pkgconfig if [ "$QT_VERSION" ]; then qt_base_path=$HOME/Qt$QT_VERSION/$QT_VERSION/clang_64 - pkg_config_path="$pkg_config_path":"$qt_base_path/lib/pkgconfig" - CMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH":"$qt_base_path/lib/cmake" + # CMAKE_PREFIX_PATH="$PACKAGE_CONFIG_PATH:$qt_base_path/lib/cmake" fi if $no_build; then @@ -3833,7 +4119,7 @@ if $no_build; then fi if [ "$QT_VERSION" ]; then - if [ -f qt-$QT_VERSION-done ]; then + if [ -f "qt-$QT_VERSION-done" ]; then echo "You are now prepared to build Wireshark." else echo "Qt was not installed; you will have to install it in order to build the" @@ -3851,18 +4137,16 @@ fi echo echo "To build:" echo -echo "export PKG_CONFIG_PATH=$pkg_config_path" -echo "export CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" echo "export PATH=$PATH:$qt_base_path/bin" echo echo "mkdir build; cd build" -if [ ! -z "$NINJA_VERSION" ]; then +if [ -n "$NINJA_VERSION" ]; then echo "cmake -G Ninja .." echo "ninja wireshark_app_bundle logray_app_bundle # (Modify as needed)" echo "ninja install/strip" else echo "cmake .." - echo "make $MAKE_BUILD_OPTS wireshark_app_bundle logray_app_bundle # (Modify as needed)" + echo "make ${MAKE_BUILD_OPTS[*]} wireshark_app_bundle logray_app_bundle # (Modify as needed)" echo "make install/strip" fi echo |