diff --git a/configure b/configure index d78992c1ed7..542bf7355fd 100755 --- a/configure +++ b/configure @@ -671,7 +671,7 @@ python_majorversion PYTHON perl_embed_ldflags perl_embed_ccflags -perl_includedir +perl_includespec perl_useshrplib perl_privlibexp perl_archlibexp @@ -7540,11 +7540,12 @@ documentation for details. Use --without-perl to disable building PL/Perl." "$LINENO" 5 fi # On most platforms, archlibexp is also where the Perl include files live ... - perl_includedir="$perl_archlibexp" - # ... but on some macOS versions, we must look under $PG_SYSROOT instead - if test x"$PG_SYSROOT" != x"" ; then + perl_includespec="-I$perl_archlibexp/CORE" + # ... but on newer macOS versions, we must use -iwithsysroot to look + # under $PG_SYSROOT + if test \! -f "$perl_archlibexp/CORE/perl.h" ; then if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then - perl_includedir="$PG_SYSROOT$perl_archlibexp" + perl_includespec="-iwithsysroot $perl_archlibexp/CORE" fi fi @@ -15183,11 +15184,6 @@ 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" @@ -15205,7 +15201,7 @@ fi # check for if test "$with_perl" = yes; then ac_save_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -I$perl_includedir/CORE" + CPPFLAGS="$CPPFLAGS $perl_includespec" ac_fn_c_check_header_compile "$LINENO" "perl.h" "ac_cv_header_perl_h" "#include " if test "x$ac_cv_header_perl_h" = xyes; then : diff --git a/configure.in b/configure.in index ec2a93f94bb..44e345666ae 100644 --- a/configure.in +++ b/configure.in @@ -927,14 +927,15 @@ documentation for details. Use --without-perl to disable building PL/Perl.]) fi # On most platforms, archlibexp is also where the Perl include files live ... - perl_includedir="$perl_archlibexp" - # ... but on some macOS versions, we must look under $PG_SYSROOT instead - if test x"$PG_SYSROOT" != x"" ; then + perl_includespec="-I$perl_archlibexp/CORE" + # ... but on newer macOS versions, we must use -iwithsysroot to look + # under $PG_SYSROOT + if test \! -f "$perl_archlibexp/CORE/perl.h" ; then if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then - perl_includedir="$PG_SYSROOT$perl_archlibexp" + perl_includespec="-iwithsysroot $perl_archlibexp/CORE" fi fi - AC_SUBST(perl_includedir)dnl + AC_SUBST(perl_includespec)dnl PGAC_CHECK_PERL_EMBED_CCFLAGS PGAC_CHECK_PERL_EMBED_LDFLAGS fi @@ -2040,11 +2041,6 @@ 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" @@ -2055,7 +2051,7 @@ fi # check for if test "$with_perl" = yes; then ac_save_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -I$perl_includedir/CORE" + CPPFLAGS="$CPPFLAGS $perl_includespec" AC_CHECK_HEADER(perl.h, [], [AC_MSG_ERROR([header file is required for Perl])], [#include ]) # While we're at it, check that we can link to libperl. diff --git a/contrib/hstore_plperl/Makefile b/contrib/hstore_plperl/Makefile index d37e99b1f44..32d7c320c60 100644 --- a/contrib/hstore_plperl/Makefile +++ b/contrib/hstore_plperl/Makefile @@ -41,8 +41,5 @@ SHLIB_LINK_INTERNAL += -L../hstore -l hstore SHLIB_LINK += $(perl_embed_ldflags) endif -# As with plperl we need to make sure that the CORE directory is included -# last, probably because it sometimes contains some header files with names -# that clash with some of ours, or with some that we include, notably on -# Windows. -override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE +# As with plperl we need to include the perl_includespec directory last. +override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) $(perl_includespec) diff --git a/src/Makefile.global.in b/src/Makefile.global.in index f76beee9b44..5d6a2ceaa92 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -306,7 +306,7 @@ else endif perl_archlibexp = @perl_archlibexp@ perl_privlibexp = @perl_privlibexp@ -perl_includedir = @perl_includedir@ +perl_includespec = @perl_includespec@ perl_embed_ccflags = @perl_embed_ccflags@ perl_embed_ldflags = @perl_embed_ldflags@ diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile index d1c84279a6a..0846e60cd81 100644 --- a/src/pl/plperl/GNUmakefile +++ b/src/pl/plperl/GNUmakefile @@ -12,12 +12,13 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID override CPPFLAGS += -Wno-comment endif -# Note: we need to make sure that the CORE directory is included last, +# Note: we need to include the perl_includespec directory last, # probably because it sometimes contains some header files with names # that clash with some of ours, or with some that we include, notably on # Windows. -override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE +override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) $(perl_includespec) +# this is often, but not always, the same directory named by perl_includespec rpathdir = $(perl_archlibexp)/CORE PGFILEDESC = "PL/Perl - procedural language" diff --git a/src/template/darwin b/src/template/darwin index 70227335669..159d8bb1275 100644 --- a/src/template/darwin +++ b/src/template/darwin @@ -3,9 +3,8 @@ # 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 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. +# Some configure tests require explicit knowledge of where the Xcode "sysroot" +# is. We try to avoid having this leak into configure's results, though. if test x"$PG_SYSROOT" = x"" ; then PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null` fi