]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
configure: Determine system architecture properly on *BSD systems
authorBrad Smith <brad@comstyle.com>
Mon, 17 Nov 2025 05:50:47 +0000 (00:50 -0500)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 18 Nov 2025 12:07:14 +0000 (13:07 +0100)
uname -m on a BSD system will provide the architecture port .e.g.
arm64, macppc, octeon instead of the machine architecture .e.g.
aarch64, powerpc, mips64. uname -p will provide the machine
architecture. NetBSD uses x86_64, OpenBSD uses amd64, FreeBSD
is a mix between uname -p and the compiler output.

configure

index 267abcf75d8a2644af6061734b385f0bf5185bdf..d9f3278fdc0479a232af3fd3ca96fcfb1d67e358 100755 (executable)
--- a/configure
+++ b/configure
@@ -29,11 +29,17 @@ if [ -n "${CHOST}" ]; then
     CROSS_PREFIX="${CHOST}-"
     ARCH="$(echo "${NORM_CHOST}" | sed -e 's/-.*//')"
 else
-    ARCH="$(uname -m)"
+    # BSD systems use uname -p for architecture names vs port names
+    case "$(uname -s)" in
+      *BSD | *bsd* | DragonFly)
+          ARCH="$(uname -p)" ;;
+      *)
+          ARCH="$(uname -m)" ;;
+    esac
 fi
 
 case "${ARCH}" in
-    x86_64)
+    amd64 | x86_64)
         case "${CFLAGS}" in
             *-m32*)
                 ARCH=i686
@@ -337,7 +343,7 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then
       else
         ARCH=$CC_ARCH
       fi ;;
-    x86_64)
+    amd64 | x86_64)
       # Honor user choice if gcc is multilib and 32-bit is requested
       if test $build32 -ne 1; then
         ARCH=$CC_ARCH
@@ -1794,7 +1800,7 @@ ARCH_SHARED_OBJS=''
 # Set ARCH specific FLAGS
 case "${ARCH}" in
     # x86/amd64 specific optimizations
-    i386 | i486 | i586 | i686 |x86_64)
+    i386 | i486 | i586 | i686 | amd64 | x86_64)
         ARCHDIR=arch/x86
 
         # Enable arch-specific optimizations