|
3 | 3 | # Note: Darwin is the original code name for macOS, also known as OS X.
|
4 | 4 | # We still use "darwin" as the port name, partly because config.guess does.
|
5 | 5 |
|
6 |
| -# Select where system include files should be sought. |
| 6 | +# Select where system include files should be sought, if user didn't say. |
7 | 7 | if test x"$PG_SYSROOT" = x"" ; then
|
8 |
| - PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null` |
| 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. However, that may produce no result or |
| 11 | + # a result that is not version-specific (i.e., just ".../SDKs/MacOSX.sdk"). |
| 12 | + # Using a version-specific sysroot seems desirable, so if there are not |
| 13 | + # digits in the directory name, try "xcrun --sdk macosx --show-sdk-path"; |
| 14 | + # and if that still doesn't work, fall back to asking xcodebuild, |
| 15 | + # which is often a good deal slower. |
| 16 | + PG_SYSROOT=`xcrun --show-sdk-path 2>/dev/null` |
| 17 | + if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9][^/]*$' >/dev/null ; then : okay |
| 18 | + else |
| 19 | + PG_SYSROOT=`xcrun --sdk macosx --show-sdk-path 2>/dev/null` |
| 20 | + if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9][^/]*$' >/dev/null ; then : okay |
| 21 | + else |
| 22 | + PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null` |
| 23 | + fi |
| 24 | + fi |
9 | 25 | fi
|
10 |
| -# Old xcodebuild versions may produce garbage, so validate the result. |
| 26 | +# Validate the result: if it doesn't point at a directory, ignore it. |
11 | 27 | if test x"$PG_SYSROOT" != x"" ; then
|
12 | 28 | if test -d "$PG_SYSROOT" ; then
|
13 | 29 | CPPFLAGS="-isysroot $PG_SYSROOT $CPPFLAGS"
|
|
0 commit comments