| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Select where system include files should be sought. If the user specified a |
| 4 |
# sysroot, validate it. |
| 5 |
# |
| 6 |
# A separate script so it can be shared between autoconf and meson. |
| 7 |
|
| 8 |
PG_SYSROOT=$1 |
| 9 |
|
| 10 |
if test x"$PG_SYSROOT" = x"" ; then |
| 11 |
# This is far more complicated than it ought to be. We first ask |
| 12 |
# "xcrun --show-sdk-path", which seems to match the default -isysroot |
| 13 |
# setting of Apple's compilers. |
| 14 |
PG_SYSROOT=`xcrun --show-sdk-path 2>/dev/null` |
| 15 |
# That may fail, or produce a result that is not version-specific (i.e., |
| 16 |
# just ".../SDKs/MacOSX.sdk"). Using a version-specific sysroot seems |
| 17 |
# desirable, so if the path is a non-version-specific symlink, expand it. |
| 18 |
if test -L "$PG_SYSROOT"; then |
| 19 |
if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9][^/]*$' >/dev/null ; then : okay |
| 20 |
else |
| 21 |
PG_SYSROOT=`expr "$PG_SYSROOT" : '\(.*\)/'`/`readlink "$PG_SYSROOT"` |
| 22 |
fi |
| 23 |
fi |
| 24 |
# If there are still not digits in the directory name, try |
| 25 |
# "xcrun --sdk macosx --show-sdk-path"; and if that still doesn't work, |
| 26 |
# fall back to asking xcodebuild, which is often a good deal slower. |
| 27 |
if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9][^/]*$' >/dev/null ; then : okay |
| 28 |
else |
| 29 |
PG_SYSROOT=`xcrun --sdk macosx --show-sdk-path 2>/dev/null` |
| 30 |
if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9][^/]*$' >/dev/null ; then : okay |
| 31 |
else |
| 32 |
PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null` |
| 33 |
fi |
| 34 |
fi |
| 35 |
fi |
| 36 |
# Validate the result: if it doesn't point at a directory, ignore it. |
| 37 |
if test x"$PG_SYSROOT" != x"" ; then |
| 38 |
if test -d "$PG_SYSROOT" ; then |
| 39 |
echo $PG_SYSROOT |
| 40 |
fi |
| 41 |
fi |