1# src/template/darwin 2 3# Note: Darwin is the original code name for macOS, also known as OS X. 4# We still use "darwin" as the port name, partly because config.guess does. 5 6# Select where system include files should be sought, if user didn't say. 7if test x"$PG_SYSROOT" = x"" ; then 8 # This is far more complicated than it ought to be. We first ask 9 # "xcrun --show-sdk-path", which seems to match the default -isysroot 10 # setting of Apple's compilers. 11 PG_SYSROOT=`xcrun --show-sdk-path 2>/dev/null` 12 # That may fail, or produce a result that is not version-specific (i.e., 13 # just ".../SDKs/MacOSX.sdk"). Using a version-specific sysroot seems 14 # desirable, so if the path is a non-version-specific symlink, expand it. 15 if test -L "$PG_SYSROOT"; then 16 if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9][^/]*$' >/dev/null ; then : okay 17 else 18 PG_SYSROOT=`expr "$PG_SYSROOT" : '\(.*\)/'`/`readlink "$PG_SYSROOT"` 19 fi 20 fi 21 # If there are still not digits in the directory name, try 22 # "xcrun --sdk macosx --show-sdk-path"; and if that still doesn't work, 23 # fall back to asking xcodebuild, which is often a good deal slower. 24 if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9][^/]*$' >/dev/null ; then : okay 25 else 26 PG_SYSROOT=`xcrun --sdk macosx --show-sdk-path 2>/dev/null` 27 if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9][^/]*$' >/dev/null ; then : okay 28 else 29 PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null` 30 fi 31 fi 32fi 33# Validate the result: if it doesn't point at a directory, ignore it. 34if test x"$PG_SYSROOT" != x"" ; then 35 if test -d "$PG_SYSROOT" ; then 36 CPPFLAGS="-isysroot $PG_SYSROOT $CPPFLAGS" 37 LDFLAGS="-isysroot $PG_SYSROOT $LDFLAGS" 38 else 39 PG_SYSROOT="" 40 fi 41fi 42 43# Extra CFLAGS for code that will go into a shared library 44CFLAGS_SL="" 45 46# Select appropriate semaphore support. Darwin 6.0 (macOS 10.2) and up 47# support System V semaphores; before that we have to use named POSIX 48# semaphores, which are less good for our purposes because they eat a 49# file descriptor per backend per max_connection slot. 50case $host_os in 51 darwin[015].*) 52 USE_NAMED_POSIX_SEMAPHORES=1 53 ;; 54 *) 55 USE_SYSV_SEMAPHORES=1 56 ;; 57esac 58