diff --git a/configure b/configure index b7250d7f5b8..5e686b2a21f 100755 --- a/configure +++ b/configure @@ -9778,7 +9778,7 @@ PL/Perl." "$LINENO" 5 perl_includedir="$perl_archlibexp" # ... but on some macOS versions, we must look under $PG_SYSROOT instead if test x"$PG_SYSROOT" != x"" ; then - if test -d "$PG_SYSROOT$perl_archlibexp" ; then + if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then perl_includedir="$PG_SYSROOT$perl_archlibexp" fi fi @@ -18114,6 +18114,11 @@ eval TCL_SHARED_BUILD=\"$TCL_SHARED_BUILD\" as_fn_error $? "cannot build PL/Tcl because Tcl is not a shared library Use --without-tcl to disable building PL/Tcl." "$LINENO" 5 fi + # Some macOS versions report an include spec that uses -iwithsysroot. + # We don't really want to use -isysroot, so translate that if we can. + if test x"$PG_SYSROOT" != x"" ; then + TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`" + fi # now that we have TCL_INCLUDE_SPEC, we can check for ac_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS" diff --git a/configure.in b/configure.in index de5f777333b..d8487aae275 100644 --- a/configure.in +++ b/configure.in @@ -1048,7 +1048,7 @@ PL/Perl.]) perl_includedir="$perl_archlibexp" # ... but on some macOS versions, we must look under $PG_SYSROOT instead if test x"$PG_SYSROOT" != x"" ; then - if test -d "$PG_SYSROOT$perl_archlibexp" ; then + if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then perl_includedir="$PG_SYSROOT$perl_archlibexp" fi fi @@ -2211,6 +2211,11 @@ if test "$with_tcl" = yes; then AC_MSG_ERROR([cannot build PL/Tcl because Tcl is not a shared library Use --without-tcl to disable building PL/Tcl.]) fi + # Some macOS versions report an include spec that uses -iwithsysroot. + # We don't really want to use -isysroot, so translate that if we can. + if test x"$PG_SYSROOT" != x"" ; then + TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`" + fi # now that we have TCL_INCLUDE_SPEC, we can check for ac_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS" diff --git a/src/template/darwin b/src/template/darwin index cff258be26b..70227335669 100644 --- a/src/template/darwin +++ b/src/template/darwin @@ -3,14 +3,15 @@ # Note: Darwin is the original code name for macOS, also known as OS X. # We still use "darwin" as the port name, partly because config.guess does. -# Select where system include files should be sought. +# Select where some include files should be sought. +# We may eventually be forced to use "-isysroot" with this value, +# but for now, it only affects Perl and Tcl include files. if test x"$PG_SYSROOT" = x"" ; then PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null` fi +# Old xcodebuild versions may produce garbage, so validate the result. if test x"$PG_SYSROOT" != x"" ; then - if test -d "$PG_SYSROOT" ; then - CPPFLAGS="$CPPFLAGS -isysroot $PG_SYSROOT" - else + if test \! -d "$PG_SYSROOT" ; then PG_SYSROOT="" fi fi