Skip to content

Commit 72827d0

Browse files
authored
[Build-System] Update configure.ac for macOS updates (#2818)
This is a request to change configure.ac target libraries for Apple Silicon computers and a general cleanup/update for macOS. Different target on Apple Silicon Apple has stated that other programs should be installed into /opt for Apple Silicon computers instead of /usr/local. Homebrew installs everything in /opt. Multiple changes were made to handle this. Added code to auto change the default from /usr/local to /opt for Apple Silicon. All other systems default to /usr/local as before. Where target libraries were different, code was added to only add the correct libraries to the appropriate architecture. This eliminates a lot of warning message for missing libraries. Compiler flags were updated to conform to current clang. Obsolete code that can no longer work (for old apple ancient releases or compilers) was removed or replaced.
1 parent bd0d0db commit 72827d0

File tree

1 file changed

+28
-37
lines changed

1 file changed

+28
-37
lines changed

configure.ac

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,6 @@ elif test "x${ax_cv_c_compiler_vendor}" = "xclang" ; then
323323
esac
324324
elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
325325
case "$host" in
326-
# older Xcode test for darwin, Xcode 4/5 use clang above
327-
*darwin*)
328-
SOLINK="-dynamic -bundle -force-flat-namespace"
329-
;;
330326
*-solaris2*)
331327
SOLINK="-shared -Xlinker"
332328
;;
@@ -428,15 +424,6 @@ elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
428424
fi
429425
if test "${enable_64}" = "yes"; then
430426
case "$host" in
431-
*darwin*)
432-
osxvrm=`sw_vers -productVersion` # Get version.release.modlevel
433-
osxrel=`echo $osxvrm | cut -d. -f2` # Get release only
434-
if test "$osxrel" -ge 4; then # 10.4 and up are x64
435-
APR_ADDTO(CFLAGS, -arch x86_64)
436-
APR_ADDTO(LDFLAGS, -arch x86_64)
437-
APR_ADDTO(CXXFLAGS, -arch x86_64)
438-
fi
439-
;;
440427
*-solaris2*)
441428
APR_ADDTO(CFLAGS, -m64)
442429
APR_ADDTO(LDFLAGS, -m64)
@@ -653,8 +640,10 @@ path_push_unique () {
653640
AC_PATH_PROG([PG_CONFIG], [pg_config], [no])
654641
AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no])
655642

643+
# These 2 x86 libraries are not required on macOS 15 Sequoia on x86 as of June 2025. Not needed on aarch64 systems.
644+
# They are left here since they are likely required on older macOS systems.
656645
case $host in
657-
*-darwin*)
646+
x86_64-apple-darwin*)
658647
path_push_unique PKG_CONFIG_PATH /usr/local/opt/libpq/lib/pkgconfig
659648
path_push_unique PKG_CONFIG_PATH /usr/local/opt/openssl/lib/pkgconfig
660649
;;
@@ -735,33 +724,33 @@ PLATFORM_CORE_LIBS=
735724
# tweak platform specific flags
736725
case "$host" in
737726
*darwin*)
738-
# Common Apple Darwin settings
727+
case "$host" in
728+
aarch64-apple-darwin*)
729+
# Homebrew package required libraries on Apple Silicon
730+
APR_ADDTO(CPPFLAGS, -I/opt/homebrew/include)
731+
APR_ADDTO(LDFLAGS, -L/opt/homebrew/lib)
732+
;;
733+
*)
734+
# Default package libraries on Apple x86_64
735+
# The following 4 x86_64 libraries are not required on macOS 15 Sequoia as of June 2025.
736+
# They are left here since they are likely required on older macOS systems.
737+
APR_ADDTO(CPPFLAGS, -I/usr/local/include) # Xcode 6 drops std lib search, add it to clang
738+
APR_ADDTO(LDFLAGS, -L/usr/local/lib) # Xcode 6 drops std lib search, add it to clang
739+
APR_ADDTO(CPPFLAGS, -I/usr/local/opt/openssl/include)
740+
APR_ADDTO(LDFLAGS, -L/usr/local/opt/openssl/lib)
741+
;;
742+
esac
743+
# Common Apple Clang flags
744+
APR_ADDTO(CFLAGS, -pipe)
745+
APR_ADDTO(LDFLAGS, -pipe)
746+
APR_ADDTO(CXXFLAGS, -pipe)
747+
# Common Apple Darwin settings
739748
APR_ADDTO(SWITCH_AM_CFLAGS, -DMACOSX)
740749
APR_REMOVEFROM(SWITCH_AM_CFLAGS, -fPIC)
741-
APR_ADDTO(CPPFLAGS, -I/usr/local/opt/openssl/include)
742-
APR_ADDTO(LDFLAGS, -L/usr/local/opt/openssl/lib)
743-
APR_ADDTO(CPPFLAGS, -I/opt/homebrew/include)
744-
APR_ADDTO(LDFLAGS, -L/opt/homebrew/lib)
745750
if test "x$enable_core_odbc_support" != "xno"; then
746751
APR_ADDTO([PLATFORM_CORE_LDFLAGS], [--framework CoreFoundation])
747752
fi
748753
APR_ADDTO([PLATFORM_CORE_LIBS], [-ldl])
749-
# Get OSX and clang version
750-
osxvrm=`sw_vers -productVersion` # Get version.release.modlevel
751-
osxrel=`echo $osxvrm | cut -d. -f2` # Get release only
752-
clangvers="`clang -v 2>&1 >/dev/null | grep version | sed -e 's/.*version \([[0-9]]*\).*$/\1/'`"
753-
if test "$clangvers" -ge 6; then # Xcode 6 drops std lib search, add it to clang
754-
APR_ADDTO(LDFLAGS, -L/usr/local/lib)
755-
APR_ADDTO(CPPFLAGS, -I/usr/local/include)
756-
fi
757-
if test "$clangvers" -ge 4; then # Xcode 4 / 10.7 and up
758-
APR_ADDTO(CFLAGS, -Wno-deprecated-declarations)
759-
fi
760-
if test "$osxrel" -ge 6; then # 10.6 and up
761-
APR_ADDTO(CFLAGS, -pipe -no-cpp-precomp)
762-
APR_ADDTO(LDFLAGS, -pipe -bind_at_load)
763-
APR_ADDTO(CXXFLAGS, -pipe)
764-
fi
765754
;;
766755
*-solaris2*)
767756
if test "${enable_64}" = "yes"; then
@@ -1261,13 +1250,15 @@ GETSOUNDS="${SHELL} $switch_builddir/build/getsounds.sh"
12611250
AC_SUBST(GETSOUNDS)
12621251

12631252
case $host in
1253+
aarch64-apple-darwin*)
1254+
path_push_unique PKG_CONFIG_PATH /opt/homebrew/opt/pkgconf/
1255+
path_push_unique PKG_CONFIG_PATH /opt/homebrew/opt/sqlite/lib/pkgconfig/
1256+
;;
12641257
*-darwin*)
12651258
path_push_unique PKG_CONFIG_PATH /usr/local/opt/curl/lib/pkgconfig
12661259
path_push_unique PKG_CONFIG_PATH /usr/local/opt/sqlite/lib/pkgconfig/
12671260
path_push_unique PKG_CONFIG_PATH /usr/local/opt/ldns/lib/pkgconfig/
12681261
path_push_unique PKG_CONFIG_PATH /usr/local/opt/ffmpeg/lib/pkgconfig/
1269-
path_push_unique PKG_CONFIG_PATH /opt/homebrew/lib/pkgconfig/
1270-
path_push_unique PKG_CONFIG_PATH /opt/homebrew/opt/sqlite/lib/pkgconfig/
12711262
;;
12721263
esac
12731264

0 commit comments

Comments
 (0)