From b176ce53aa2b3d13ffbfde591b318a8a07dea68a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20K=C3=B6cher?= Date: Fri, 5 May 2017 23:42:03 +0200 Subject: [PATCH] candi.sh: optimised macOS support (detects 10.12 and 10.11) --- candi.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 8 deletions(-) diff --git a/candi.sh b/candi.sh index 5585b30..67d9f2e 100755 --- a/candi.sh +++ b/candi.sh @@ -550,9 +550,6 @@ guess_platform() { # Try to guess the name of the platform we're running on if [ -f /usr/bin/cygwin1.dll ]; then echo cygwin - - elif [[ "$OSTYPE" == "darwin"* ]]; then - echo macosx elif [ -f /etc/fedora-release ]; then local FEDORANAME=`gawk '{if (match($0,/\((.*)\)/,f)) print f[1]}' /etc/fedora-release` @@ -578,11 +575,8 @@ guess_platform() { elif [ -x /usr/bin/sw_vers ]; then local MACOSVER=$(sw_vers -productVersion) case ${MACOSVER} in - 10.4*) echo tiger;; - 10.5*) echo leopard;; - 10.6*) echo snowleopard;; - 10.7*) echo lion;; - 10.8*) echo mountainlion;; + 10.11*) echo macosx;; + 10.12*) echo sierra;; esac elif [ -x /usr/bin/lsb_release ]; then @@ -605,6 +599,40 @@ guess_platform() { fi } +guess_ostype() { + # Try to guess the operating system type (ostype) + if [ -f /usr/bin/cygwin1.dll ]; then + echo cygwin + + elif [ -f /etc/fedora-release ]; then + echo linux + + elif [ -f /etc/redhat-release ]; then + echo linux + + elif [ -x /usr/bin/sw_vers ]; then + echo macos + + elif [ -x /usr/bin/lsb_release ]; then + local DISTRO=$(lsb_release -i -s) + local CODENAME=$(lsb_release -c -s) + local DESCRIPTION=$(lsb_release -d -s) + case ${DISTRO}:${CODENAME}:${DESCRIPTION} in + *:*:*Ubuntu*\ 12*) echo linux;; + *:*:*Ubuntu*\ 14*) echo linux;; + *:*:*Ubuntu*\ 15*) echo linux;; + *:xenial*:*Ubuntu*) echo linux;; + *:Tikanga*:*) echo linux;; + *:Santiago*:*) echo linux;; + Scientific:Carbon*:*) echo linux;; + *:*:*CentOS*\ 5*) echo linux;; + *:*:*CentOS*\ 6*) echo linux;; + *:*:*openSUSE\ 12*) echo linux;; + *:*:*openSUSE\ 13*) echo linux;; + esac + fi +} + guess_architecture() { # Try to guess the architecture of the platform we are running on ARCH=unknown @@ -722,6 +750,41 @@ else exit 1 fi fi +echo + +# Guess the operating system type -> PLATFORM_OSTYPE +PLATFORM_OSTYPE=`guess_ostype` +if [ -z "${PLATFORM_OSTYPE}" ]; then + cecho ${WARN} "WARNING: could not determine your Operating System Type (assuming linux)" + PLATFORM_OSTYPE=linux +fi + +cecho ${INFO} "Operating System Type detected as: ${PLATFORM_OSTYPE}" + +if [ -z "${PLATFORM_OSTYPE}" ]; then + # check if PLATFORM_OSTYPE is set and not empty failed + cecho ${BAD} "Error: (internal) could not set PLATFORM_OSTYPE" + exit 1 +fi + +# Guess dynamic shared library file extension -> LDSUFFIX +if [ ${PLATFORM_OSTYPE} == "linux" ]; then + LDSUFFIX=so + +elif [ ${PLATFORM_OSTYPE} == "macos" ]; then + LDSUFFIX=dylib + +elif [ ${PLATFORM_OSTYPE} == "cygwin" ]; then + LDSUFFIX=dll +fi + +cecho ${INFO} "Dynamic shared library file extension detected as: *.${LDSUFFIX}" + +if [ -z "${LDSUFFIX}" ]; then + # check if PLATFORM_OSTYPE is set and not empty failed + cecho ${BAD} "Error: (internal) could not set LDSUFFIX" + exit 1 +fi # Source default PACKAGES variables, if none were given so far if [ -z "${PACKAGES}" ]; then -- 2.39.5