test/configure

branch
configure-evo
changeset 60
43d6680e6410
parent 54
2b8f40c58944
child 63
ac47c2fb2c4a
--- a/test/configure	Sun Sep 17 12:34:45 2023 +0200
+++ b/test/configure	Sun Sep 17 12:39:42 2023 +0200
@@ -1,20 +1,11 @@
 #!/bin/sh
 
-failed()
-{
-    $@
-    if [ $? -ne 0 ]; then
-        return 0
-    else
-        return 1
-    fi
-}
-
-
 # create temporary directory
 TEMP_DIR=".tmp-`uname -n`"
 rm -Rf "$TEMP_DIR"
-if failed mkdir -p "$TEMP_DIR"; then
+if mkdir -p "$TEMP_DIR"; then
+    :
+else
     echo "Cannot create tmp dir $TEMP_DIR"
     echo "Abort"
     exit 1
@@ -113,21 +104,21 @@
 
 
 # set dir variables
-BINDIR=${BINDIR:-"$EPREFIX/bin"}
-SBINDIR=${SBINDIR:-"$EPREFIX/sbin"}
-LIBDIR=${LIBDIR:-"$EPREFIX/lib"}
-LIBEXECDIR=${LIBEXECDIR:-"$EPREFIX/libexec"}
-DATADIR=${DATADIR:-"$PREFIX/share"}
-SYSCONFDIR=${SYSCONFDIR:-"$PREFIX/etc"}
-SHAREDSTATEDIR=${SHAREDSTATEDIR:-"$PREFIX/com"}
-LOCALSTATEDIR=${LOCALSTATEDIR:-"$PREFIX/var"}
-INCLUDEDIR=${INCLUDEDIR:-"$PREFIX/include"}
-INFODIR=${INFODIR:-"$PREFIX/info"}
-MANDIR=${MANDIR:-"$PREFIX/man"}
+: ${BINDIR:="$EPREFIX/bin"}
+: ${SBINDIR:="$EPREFIX/sbin"}
+: ${LIBDIR:="$EPREFIX/lib"}
+: ${LIBEXECDIR:="$EPREFIX/libexec"}
+: ${DATADIR:="$PREFIX/share"}
+: ${SYSCONFDIR:="$PREFIX/etc"}
+: ${SHAREDSTATEDIR:="$PREFIX/com"}
+: ${LOCALSTATEDIR:="$PREFIX/var"}
+: ${INCLUDEDIR:="$PREFIX/include"}
+: ${INFODIR:="$PREFIX/info"}
+: ${MANDIR:="$PREFIX/man"}
 
 # Test for availability of pkg-config
 PKG_CONFIG=`command -v pkg-config`
-PKG_CONFIG=${PKG_CONFIG:-"false"}
+: ${PKG_CONFIG:="false"}
 
 # Simple uname based platform detection
 # $PLATFORM is used for platform dependent dependency selection
@@ -149,7 +140,7 @@
 if echo "$OS" | grep -i "MINGW" > /dev/null; then
     PLATFORM="windows mingw"
 fi
-PLATFORM=${PLATFORM:-"unix"}
+: ${PLATFORM:="unix"}
 
 PLATFORM_NAME=`echo "$PLATFORM" | cut -f1 -d' ' -`
 echo "$PLATFORM_NAME"
@@ -164,6 +155,16 @@
     done
     return 1
 }
+notisplatform()
+{
+    for p in $PLATFORM
+    do
+        if [ "$p" = "$1" ]; then
+            return 1
+        fi
+    done
+    return 0
+}
 
 
 # generate config.mk
@@ -202,7 +203,6 @@
     abort_configure
 fi
 
-
 #
 # DEPENDENCIES
 #
@@ -210,7 +210,7 @@
 # create buffer for make variables required by dependencies
 echo > "$TEMP_DIR/make.mk"
 
-dependency_libpq()
+dependency_error_libpq()
 {
     printf "checking for libpq... "
     # dependency libpq
@@ -219,19 +219,20 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        if failed $PKG_CONFIG libpq ; then
+        if $PKG_CONFIG libpq ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libpq`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libpq`"
+        else
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libpq`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libpq`"
         echo yes
-        return 0
+        return 1
     done
 
     echo no
-    return 1
+    return 0
 }
-dependency_openssl()
+dependency_error_openssl()
 {
     printf "checking for openssl... "
     # dependency openssl
@@ -240,36 +241,37 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        if failed $PKG_CONFIG openssl ; then
+        if $PKG_CONFIG openssl ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`"
+        else
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags openssl`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs openssl`"
         echo yes
-        return 0
+        return 1
     done
 
     # dependency openssl platform="bsd"
     while true
     do
-        if failed isplatform "bsd"; then
+        if notisplatform "bsd"; then
             break
         fi
         TEMP_LDFLAGS="$TEMP_LDFLAGS -lssl -lcrypto"
         echo yes
-        return 0
+        return 1
     done
 
     echo no
-    return 1
+    return 0
 }
-dependency_libxml2()
+dependency_error_libxml2()
 {
     printf "checking for libxml2... "
     # dependency libxml2 platform="macos"
     while true
     do
-        if failed isplatform "macos"; then
+        if notisplatform "macos"; then
             break
         fi
         if tmp_flags=`xml2-config --cflags` ; then
@@ -283,7 +285,7 @@
             break
         fi
         echo yes
-        return 0
+        return 1
     done
 
     # dependency libxml2
@@ -292,17 +294,18 @@
         if [ -z "$PKG_CONFIG" ]; then
             break
         fi
-        if failed $PKG_CONFIG libxml-2.0 ; then
+        if $PKG_CONFIG libxml-2.0 ; then
+            TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`"
+            TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`"
+        else
             break
         fi
-        TEMP_CFLAGS="$TEMP_CFLAGS `"$PKG_CONFIG" --cflags libxml-2.0`"
-        TEMP_LDFLAGS="$TEMP_LDFLAGS `"$PKG_CONFIG" --libs libxml-2.0`"
         echo yes
-        return 0
+        return 1
     done
 
     echo no
-    return 1
+    return 0
 }
 
 DEPENDENCIES_FAILED=
@@ -341,11 +344,11 @@
 TEMP_CFLAGS=
 TEMP_LDFLAGS=
 
-if failed dependency_libxml2; then
+if dependency_error_libxml2; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED libxml2 "
     ERROR=1
 fi
-if failed dependency_openssl; then
+if dependency_error_openssl; then
     DEPENDENCIES_FAILED="$DEPENDENCIES_FAILED openssl "
     ERROR=1
 fi
@@ -353,7 +356,7 @@
 # Features
 if [ -n "$FEATURE_PG" ]; then
     # check dependency
-    if failed dependency_libpq ; then
+    if dependency_error_libpq ; then
         # "auto" features can fail and are just disabled in this case
         if [ "$FEATURE_PG" = "auto" ]; then
             unset FEATURE_PG

mercurial