improve libdir detection + don't chicken out when a specified config site does not exist

Sun, 30 Nov 2025 12:59:19 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 30 Nov 2025 12:59:19 +0100
changeset 169
a85cb6c4275d
parent 168
4cd9757c1ad9
child 170
2b62b9a7fd38

improve libdir detection + don't chicken out when a specified config site does not exist

src/main/resources/make/configure.vm file | annotate | diff | comparison | revisions
test/configure file | annotate | diff | comparison | revisions
test/configure2 file | annotate | diff | comparison | revisions
test/make/configure.vm file | annotate | diff | comparison | revisions
--- a/src/main/resources/make/configure.vm	Sun Nov 30 10:14:33 2025 +0100
+++ b/src/main/resources/make/configure.vm	Sun Nov 30 12:59:19 2025 +0100
@@ -258,42 +258,46 @@
 
 
 # check if a config.site exists and load it
+CONFIG_SITE_OK=0
 if [ -n "$CONFIG_SITE" ]; then
     # CONFIG_SITE may contain space separated file names
     for cs in $CONFIG_SITE; do
         printf "loading defaults from $cs... "
-        . "$cs"
-        echo ok
+        if [ -f "$cs" ]; then
+            . "$cs"
+            echo ok
+            CONFIG_SITE_OK=1
+            break
+        else
+            echo "not found"
+        fi
     done
 elif [ -f "$prefix/share/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/share/config.site"
     echo ok
+    CONFIG_SITE_OK=1
 elif [ -f "$prefix/etc/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/etc/config.site"
     echo ok
-else
+    CONFIG_SITE_OK=1
+fi
+
+if [ $CONFIG_SITE_OK -eq 0 ]; then
     # try to detect the correct libdir on our own, except it was changed by the user
-    if test "$libdir" = '${exec_prefix}/lib'; then
-        if [ "$OS" = "SunOS" ]; then
-            test -d "${exec_prefix}/lib/64" && test "$TOOLCHAIN_WSIZE" = "64" && libdir='${exec_prefix}/lib/64'
-        else
-            # check if the standard libdir even exists
-            if test -d "${exec_prefix}/lib" ; then
-                :
+    if [ "$libdir" = '${exec_prefix}/lib' ] ; then
+        if [ "$TOOLCHAIN_WSIZE" = "64" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/64" ] && libdir='${exec_prefix}/lib/64'
             else
-                # if it does not, maybe a lib32 exists
-                test -d "${exec_prefix}/lib32" && libdir='${exec_prefix}/lib32'
+                [ -d "${exec_prefix}/lib64" ] && libdir='${exec_prefix}/lib64'
             fi
-            if [ "$TOOLCHAIN_WSIZE" = "64" ]; then
-                # now check if there is a special 64bit libdir that we should use
-                for i in x86_64 ppc64 s390x aarch64 aarch64_be arm64 ; do
-                    if [ $ARCH = $i ]; then
-                        test -d "${exec_prefix}/lib64" && libdir='${exec_prefix}/lib64'
-                        break
-                    fi
-                done
+        elif [ "$TOOLCHAIN_WSIZE" = "32" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/32" ] && libdir='${exec_prefix}/lib/32'
+            else
+                [ -d "${exec_prefix}/lib32" ] && libdir='${exec_prefix}/lib32'
             fi
         fi
     fi
--- a/test/configure	Sun Nov 30 10:14:33 2025 +0100
+++ b/test/configure	Sun Nov 30 12:59:19 2025 +0100
@@ -246,42 +246,46 @@
 
 
 # check if a config.site exists and load it
+CONFIG_SITE_OK=0
 if [ -n "$CONFIG_SITE" ]; then
     # CONFIG_SITE may contain space separated file names
     for cs in $CONFIG_SITE; do
         printf "loading defaults from $cs... "
-        . "$cs"
-        echo ok
+        if [ -f "$cs" ]; then
+            . "$cs"
+            echo ok
+            CONFIG_SITE_OK=1
+            break
+        else
+            echo "not found"
+        fi
     done
 elif [ -f "$prefix/share/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/share/config.site"
     echo ok
+    CONFIG_SITE_OK=1
 elif [ -f "$prefix/etc/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/etc/config.site"
     echo ok
-else
+    CONFIG_SITE_OK=1
+fi
+
+if [ $CONFIG_SITE_OK -eq 0 ]; then
     # try to detect the correct libdir on our own, except it was changed by the user
-    if test "$libdir" = '${exec_prefix}/lib'; then
-        if [ "$OS" = "SunOS" ]; then
-            test -d "${exec_prefix}/lib/64" && test "$TOOLCHAIN_WSIZE" = "64" && libdir='${exec_prefix}/lib/64'
-        else
-            # check if the standard libdir even exists
-            if test -d "${exec_prefix}/lib" ; then
-                :
+    if [ "$libdir" = '${exec_prefix}/lib' ] ; then
+        if [ "$TOOLCHAIN_WSIZE" = "64" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/64" ] && libdir='${exec_prefix}/lib/64'
             else
-                # if it does not, maybe a lib32 exists
-                test -d "${exec_prefix}/lib32" && libdir='${exec_prefix}/lib32'
+                [ -d "${exec_prefix}/lib64" ] && libdir='${exec_prefix}/lib64'
             fi
-            if [ "$TOOLCHAIN_WSIZE" = "64" ]; then
-                # now check if there is a special 64bit libdir that we should use
-                for i in x86_64 ppc64 s390x aarch64 aarch64_be arm64 ; do
-                    if [ $ARCH = $i ]; then
-                        test -d "${exec_prefix}/lib64" && libdir='${exec_prefix}/lib64'
-                        break
-                    fi
-                done
+        elif [ "$TOOLCHAIN_WSIZE" = "32" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/32" ] && libdir='${exec_prefix}/lib/32'
+            else
+                [ -d "${exec_prefix}/lib32" ] && libdir='${exec_prefix}/lib32'
             fi
         fi
     fi
--- a/test/configure2	Sun Nov 30 10:14:33 2025 +0100
+++ b/test/configure2	Sun Nov 30 12:59:19 2025 +0100
@@ -282,42 +282,46 @@
 
 
 # check if a config.site exists and load it
+CONFIG_SITE_OK=0
 if [ -n "$CONFIG_SITE" ]; then
     # CONFIG_SITE may contain space separated file names
     for cs in $CONFIG_SITE; do
         printf "loading defaults from $cs... "
-        . "$cs"
-        echo ok
+        if [ -f "$cs" ]; then
+            . "$cs"
+            echo ok
+            CONFIG_SITE_OK=1
+            break
+        else
+            echo "not found"
+        fi
     done
 elif [ -f "$prefix/share/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/share/config.site"
     echo ok
+    CONFIG_SITE_OK=1
 elif [ -f "$prefix/etc/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/etc/config.site"
     echo ok
-else
+    CONFIG_SITE_OK=1
+fi
+
+if [ $CONFIG_SITE_OK -eq 0 ]; then
     # try to detect the correct libdir on our own, except it was changed by the user
-    if test "$libdir" = '${exec_prefix}/lib'; then
-        if [ "$OS" = "SunOS" ]; then
-            test -d "${exec_prefix}/lib/64" && test "$TOOLCHAIN_WSIZE" = "64" && libdir='${exec_prefix}/lib/64'
-        else
-            # check if the standard libdir even exists
-            if test -d "${exec_prefix}/lib" ; then
-                :
+    if [ "$libdir" = '${exec_prefix}/lib' ] ; then
+        if [ "$TOOLCHAIN_WSIZE" = "64" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/64" ] && libdir='${exec_prefix}/lib/64'
             else
-                # if it does not, maybe a lib32 exists
-                test -d "${exec_prefix}/lib32" && libdir='${exec_prefix}/lib32'
+                [ -d "${exec_prefix}/lib64" ] && libdir='${exec_prefix}/lib64'
             fi
-            if [ "$TOOLCHAIN_WSIZE" = "64" ]; then
-                # now check if there is a special 64bit libdir that we should use
-                for i in x86_64 ppc64 s390x aarch64 aarch64_be arm64 ; do
-                    if [ $ARCH = $i ]; then
-                        test -d "${exec_prefix}/lib64" && libdir='${exec_prefix}/lib64'
-                        break
-                    fi
-                done
+        elif [ "$TOOLCHAIN_WSIZE" = "32" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/32" ] && libdir='${exec_prefix}/lib/32'
+            else
+                [ -d "${exec_prefix}/lib32" ] && libdir='${exec_prefix}/lib32'
             fi
         fi
     fi
--- a/test/make/configure.vm	Sun Nov 30 10:14:33 2025 +0100
+++ b/test/make/configure.vm	Sun Nov 30 12:59:19 2025 +0100
@@ -258,42 +258,46 @@
 
 
 # check if a config.site exists and load it
+CONFIG_SITE_OK=0
 if [ -n "$CONFIG_SITE" ]; then
     # CONFIG_SITE may contain space separated file names
     for cs in $CONFIG_SITE; do
         printf "loading defaults from $cs... "
-        . "$cs"
-        echo ok
+        if [ -f "$cs" ]; then
+            . "$cs"
+            echo ok
+            CONFIG_SITE_OK=1
+            break
+        else
+            echo "not found"
+        fi
     done
 elif [ -f "$prefix/share/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/share/config.site"
     echo ok
+    CONFIG_SITE_OK=1
 elif [ -f "$prefix/etc/config.site" ]; then
     printf "loading site defaults... "
     . "$prefix/etc/config.site"
     echo ok
-else
+    CONFIG_SITE_OK=1
+fi
+
+if [ $CONFIG_SITE_OK -eq 0 ]; then
     # try to detect the correct libdir on our own, except it was changed by the user
-    if test "$libdir" = '${exec_prefix}/lib'; then
-        if [ "$OS" = "SunOS" ]; then
-            test -d "${exec_prefix}/lib/64" && test "$TOOLCHAIN_WSIZE" = "64" && libdir='${exec_prefix}/lib/64'
-        else
-            # check if the standard libdir even exists
-            if test -d "${exec_prefix}/lib" ; then
-                :
+    if [ "$libdir" = '${exec_prefix}/lib' ] ; then
+        if [ "$TOOLCHAIN_WSIZE" = "64" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/64" ] && libdir='${exec_prefix}/lib/64'
             else
-                # if it does not, maybe a lib32 exists
-                test -d "${exec_prefix}/lib32" && libdir='${exec_prefix}/lib32'
+                [ -d "${exec_prefix}/lib64" ] && libdir='${exec_prefix}/lib64'
             fi
-            if [ "$TOOLCHAIN_WSIZE" = "64" ]; then
-                # now check if there is a special 64bit libdir that we should use
-                for i in x86_64 ppc64 s390x aarch64 aarch64_be arm64 ; do
-                    if [ $ARCH = $i ]; then
-                        test -d "${exec_prefix}/lib64" && libdir='${exec_prefix}/lib64'
-                        break
-                    fi
-                done
+        elif [ "$TOOLCHAIN_WSIZE" = "32" ] ; then
+            if [ "$OS" = "SunOS" ]; then
+                [ -d "${exec_prefix}/lib/32" ] && libdir='${exec_prefix}/lib/32'
+            else
+                [ -d "${exec_prefix}/lib32" ] && libdir='${exec_prefix}/lib32'
             fi
         fi
     fi

mercurial