diff --git a/configure b/configure index 43ae8c869d..0686941331 100755 --- a/configure +++ b/configure @@ -627,6 +627,7 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS vpath_build +PG_SYSROOT PG_VERSION_NUM PROVE FOP @@ -18815,6 +18816,15 @@ _ACEOF +# If we are inserting PG_SYSROOT into CPPFLAGS, do so symbolically not +# literally, so that it's possible to override it at build time using +# a command like "make ... PG_SYSROOT=path". This has to be done after +# we've finished all configure checks that depend on CPPFLAGS. +if test x"$PG_SYSROOT" != x; then + CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"` +fi + + # Begin output steps diff --git a/configure.in b/configure.in index 519ecd5e1e..7586deb7ee 100644 --- a/configure.in +++ b/configure.in @@ -2357,6 +2357,15 @@ $AWK '{printf "%d%04d", $1, $2}'`"] AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a number]) AC_SUBST(PG_VERSION_NUM) +# If we are inserting PG_SYSROOT into CPPFLAGS, do so symbolically not +# literally, so that it's possible to override it at build time using +# a command like "make ... PG_SYSROOT=path". This has to be done after +# we've finished all configure checks that depend on CPPFLAGS. +if test x"$PG_SYSROOT" != x; then + CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"` +fi +AC_SUBST(PG_SYSROOT) + # Begin output steps diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml index 4487d0cfd1..d3326ce182 100644 --- a/doc/src/sgml/installation.sgml +++ b/doc/src/sgml/installation.sgml @@ -2513,6 +2513,57 @@ PHSS_30849 s700_800 u2comp/be/plugin library Patch + + macOS + + + macOS + installation on + + + + On recent macOS releases, it's necessary to + embed the sysroot path in the include switches used to + find some system header files. This results in the outputs of + the configure script varying depending on + which SDK version was used during configure. + That shouldn't pose any problem in simple scenarios, but if you are + trying to do something like building an extension on a different machine + than the server code was built on, you may need to force use of a + different sysroot path. To do that, set PG_SYSROOT, + for example + +make PG_SYSROOT=/desired/path all + + To find out the appropriate path on your machine, run + +xcodebuild -version -sdk macosx Path + + Note that building an extension using a different sysroot version than + was used to build the core server is not really recommended; in the + worst case it could result in hard-to-debug ABI inconsistencies. + + + + You can also select a non-default sysroot path when configuring, by + specifying PG_SYSROOT + to configure: + +./configure ... PG_SYSROOT=/desired/path + + + + + macOS's System Integrity + Protection (SIP) feature breaks make check, + because it prevents passing the needed setting + of DYLD_LIBRARY_PATH down to the executables being + tested. You can work around that by doing make + install before make check. + Most Postgres developers just turn off SIP, though. + + + MinGW/Native Windows diff --git a/src/Makefile.global.in b/src/Makefile.global.in index bdf394bb38..218c65a788 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -241,6 +241,7 @@ BITCODE_CXXFLAGS = @BITCODE_CXXFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +PG_SYSROOT = @PG_SYSROOT@ override CPPFLAGS := $(ICU_CFLAGS) $(CPPFLAGS) diff --git a/src/template/darwin b/src/template/darwin index 159d8bb127..c05adca0bf 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. -# Some configure tests require explicit knowledge of where the Xcode "sysroot" -# is. We try to avoid having this leak into configure's results, though. +# Select where system include files should be sought. 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 + if test -d "$PG_SYSROOT" ; then + CPPFLAGS="-isysroot $PG_SYSROOT $CPPFLAGS" + else PG_SYSROOT="" fi fi