Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0551912

Browse files
committed
Move darwin sysroot determination into separate file
The sysroot determination is fairly complex and will soon also be needed when building with meson. Instead of duplicating the logic, move it to a dedicated shell script invoked both by configure and meson. Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com> Discussion: https://postgr.es/m/2180a97c-c026-1b6c-cec8-d6e499f97017@enterprisedb.com
1 parent 2f2b18b commit 0551912

File tree

2 files changed

+47
-35
lines changed

2 files changed

+47
-35
lines changed

src/template/darwin

+6-35
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,12 @@
33
# Note: Darwin is the original code name for macOS, also known as OS X.
44
# We still use "darwin" as the port name, partly because config.guess does.
55

6-
# Select where system include files should be sought, if user didn't say.
7-
if 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
32-
fi
33-
# Validate the result: if it doesn't point at a directory, ignore it.
34-
if 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
6+
# Select where system include files should be sought
7+
PG_SYSROOT=`${srcdir}/src/tools/darwin_sysroot $PG_SYSROOT`
8+
9+
if test -d "$PG_SYSROOT" ; then
10+
CPPFLAGS="-isysroot $PG_SYSROOT $CPPFLAGS"
11+
LDFLAGS="-isysroot $PG_SYSROOT $LDFLAGS"
4112
fi
4213

4314
# Extra CFLAGS for code that will go into a shared library

src/tools/darwin_sysroot

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

0 commit comments

Comments
 (0)