]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add macOS-specific compiler options.
authorMichael R Sweet <msweet@msweet.org>
Thu, 21 Nov 2024 18:39:26 +0000 (13:39 -0500)
committerMichael R Sweet <msweet@msweet.org>
Thu, 21 Nov 2024 18:39:26 +0000 (13:39 -0500)
config-scripts/cups-compiler.m4
configure

index 802bf53824f97cf339a2941ee312d8883bd5ba5e..91805464665aee601bb2bc48689a6de610b1bf1c 100644 (file)
@@ -225,6 +225,7 @@ AS_IF([test -n "$GCC"], [
 ])
 
 # Add general compiler options per platform...
+AC_MSG_CHECKING([for OS-specific compiler options])
 AS_CASE([$host_os_name], [linux*], [
     # glibc 2.8 and higher breaks peer credentials unless you
     # define _GNU_SOURCE...  32-bit Linux needs 64-bit time/file offsets...
@@ -235,4 +236,25 @@ AS_CASE([$host_os_name], [linux*], [
     AS_IF([test x$enable_relro = xyes], [
        RELROFLAGS="-Wl,-z,relro,-z,now"
     ])
+
+    AC_MSG_RESULT([-D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 $RELROFLAGS])
+], [darwin*], [
+    # When not building for debug, target macOS 11 or later, "universal"
+    # binaries when possible...
+    AS_IF([echo "$CPPFLAGS $CFLAGS $LDFLAGS $OPTIM" | grep -q "\\-arch "], [
+       # Don't add architecture/min-version flags if they are already present
+       AC_MSG_RESULT([none])
+    ], [echo "$CPPFLAGS $CFLAGS $LDFLAGS $OPTIM" | grep -q "\\-mmacosx-version-"], [
+       # Don't add architecture/min-version flags if they are already present
+       AC_MSG_RESULT([none])
+    ], [test "$host_os_version" -ge 200 -a x$enable_debug != xyes], [
+       # macOS 11.0 and higher support the Apple Silicon (arm64) CPUs
+       OPTIM="$OPTIM -mmacosx-version-min=11.0 -arch x86_64 -arch arm64"
+       AC_MSG_RESULT([-mmacosx-version-min=11.0 -arch x86_64 -arch arm64])
+    ], [
+       # Don't add architecture/min-version flags if debug enabled
+       AC_MSG_RESULT([none])
+    ])
+], [*], [
+    AC_MSG_RESULT([none])
 ])
index 08d0d5546a5a839802c536e6047a49feeb9323c7..9469bf370f52ea389a7fcd353accba6d3957df04 100755 (executable)
--- a/configure
+++ b/configure
@@ -8255,6 +8255,8 @@ esac
 fi
 
 # Add general compiler options per platform...
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for OS-specific compiler options" >&5
+printf %s "checking for OS-specific compiler options... " >&6; }
 case $host_os_name in #(
   linux*) :
 
@@ -8270,6 +8272,48 @@ then :
        RELROFLAGS="-Wl,-z,relro,-z,now"
 
 fi
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 $RELROFLAGS" >&5
+printf "%s\n" "-D_GNU_SOURCE -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 $RELROFLAGS" >&6; }
+ ;; #(
+  darwin*) :
+
+    # When not building for debug, target macOS 11 or later, "universal"
+    # binaries when possible...
+    if echo "$CPPFLAGS $CFLAGS $LDFLAGS $OPTIM" | grep -q "\\-arch "
+then :
+
+       # Don't add architecture/min-version flags if they are already present
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
+printf "%s\n" "none" >&6; }
+
+elif echo "$CPPFLAGS $CFLAGS $LDFLAGS $OPTIM" | grep -q "\\-mmacosx-version-"
+then :
+
+       # Don't add architecture/min-version flags if they are already present
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
+printf "%s\n" "none" >&6; }
+
+elif test "$host_os_version" -ge 200 -a x$enable_debug != xyes
+then :
+
+       # macOS 11.0 and higher support the Apple Silicon (arm64) CPUs
+       OPTIM="$OPTIM -mmacosx-version-min=11.0 -arch x86_64 -arch arm64"
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -mmacosx-version-min=11.0 -arch x86_64 -arch arm64" >&5
+printf "%s\n" "-mmacosx-version-min=11.0 -arch x86_64 -arch arm64" >&6; }
+
+else $as_nop
+
+       # Don't add architecture/min-version flags if debug enabled
+       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
+printf "%s\n" "none" >&6; }
+
+fi
+ ;; #(
+  *) :
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5
+printf "%s\n" "none" >&6; }
  ;; #(
   *) :
      ;;