diff --git a/configure b/configure index 75d6875023..fb5d4a2fcb 100755 --- a/configure +++ b/configure @@ -7508,7 +7508,7 @@ $as_echo "$perl_useshrplib" >&6; } 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 @@ -14680,7 +14680,12 @@ eval TCL_LIBS=\"$TCL_LIBS\" eval TCL_LIB_SPEC=\"$TCL_LIB_SPEC\" eval TCL_SHARED_BUILD=\"$TCL_SHARED_BUILD\" - # now that we have TCL_INCLUDE_SPEC, we can check for + # 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" ac_fn_c_check_header_mongrel "$LINENO" "tcl.h" "ac_cv_header_tcl_h" "$ac_includes_default" diff --git a/configure.in b/configure.in index 11b4af801a..9a29fd7887 100644 --- a/configure.in +++ b/configure.in @@ -919,7 +919,7 @@ if test "$with_perl" = yes; then 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 @@ -1933,6 +1933,11 @@ if test "$with_tcl" = yes; then PGAC_EVAL_TCLCONFIGSH([$TCL_CONFIG_SH], [TCL_INCLUDE_SPEC,TCL_LIB_FILE,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD]) AC_SUBST(TCL_SHLIB_LD_LIBS)dnl don't want to double-evaluate that one + # 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 cff258be26..7022733566 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