Skip to content

Commit

Permalink
Add macOS-specific compiler options.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Nov 21, 2024
1 parent 3d6bfe0 commit 39f9e25
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
22 changes: 22 additions & 0 deletions config-scripts/cups-compiler.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand All @@ -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])
])
44 changes: 44 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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*) :

Expand All @@ -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; }
;; #(
*) :
;;
Expand Down

0 comments on commit 39f9e25

Please sign in to comment.