From 7792c023887c41cd45c08376a80d14f2fe69feae Mon Sep 17 00:00:00 2001 From: Artem Pianykh Date: Tue, 2 Jul 2019 10:01:05 -0700 Subject: [PATCH] Use xcrun to find SDK paths on OSX host during configure Summary: Previously it was required to provide SDKROOT during configure on Mojave hosts to `make` the project which in scripts was messing up local clang and somewhat error-prone. Instead we could use xcrun to find required SDK paths automatically. Reviewed By: jvillard Differential Revision: D16072354 fbshipit-source-id: 93cbf3980 --- Makefile.autoconf.in | 7 ++++--- build-infer.sh | 11 ----------- configure.ac | 12 ++++++++++-- infer/models/c/src/Makefile | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Makefile.autoconf.in b/Makefile.autoconf.in index f019da4cf..ca7eb227e 100644 --- a/Makefile.autoconf.in +++ b/Makefile.autoconf.in @@ -28,6 +28,7 @@ ENABLE_OCAMLOPT_CUSTOM_CC = @ENABLE_OCAMLOPT_CUSTOM_CC@ ENABLE_OCAML_BINANNOT = @ENABLE_OCAML_BINANNOT@ exec_prefix = @exec_prefix@ GNU_SED = @GNU_SED@ +HAS_OBJC = @HAS_OBJC@ INFER_MAJOR = @INFER_MAJOR@ INFER_MAN_LAST_MODIFIED = @INFER_MAN_LAST_MODIFIED@ INFER_MINOR = @INFER_MINOR@ @@ -74,11 +75,11 @@ SDKROOT = @SDKROOT@ SHASUM = @SHASUM@ USER_JAVA_HOME = @USER_JAVA_HOME@ UTOP = @UTOP@ -XCODE_SELECT = @XCODE_SELECT@ +WINDOWS_BUILD = @WINDOWS_BUILD@ XCODE_BASE = @XCODE_BASE@ -HAS_OBJC = @HAS_OBJC@ +XCODE_SELECT = @XCODE_SELECT@ XCPRETTY = @XCPRETTY@ -WINDOWS_BUILD = @WINDOWS_BUILD@ +XCRUN = @XCRUN@ ifneq (,$(findstring s,$(MAKEFLAGS))) # quiet mode diff --git a/build-infer.sh b/build-infer.sh index 29897f827..d4ef13c81 100755 --- a/build-infer.sh +++ b/build-infer.sh @@ -142,17 +142,6 @@ echo >&2 echo "installing infer dependencies; this can take up to 30 minutes... " >&2 opam_retry install_opam_deps -#fix for Mojave -if [ "$OSTYPE" == "darwin18" ]; then - if [ "$(command -v xcode-select)" == "" ]; then - xcode-select --install - fi - SDKROOT=${SDKROOT:-/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk} - if [ -d "$SDKROOT" ]; then - export SDKROOT - fi -fi - if [ "$ONLY_SETUP_OPAM" == "yes" ]; then exit 0 fi diff --git a/configure.ac b/configure.ac index 513f7a036..80912343b 100644 --- a/configure.ac +++ b/configure.ac @@ -130,8 +130,18 @@ AS_IF( [XCODE_BASE=$XCODE_SELECT_OUT HAS_OBJC=yes], [HAS_OBJC=no]) +AC_CHECK_TOOL([XCRUN], [xcrun], [no]) + +AC_ARG_VAR([SDKROOT], [path to the OSX platform SDK used by clang]) +AS_IF( + [test "x$SDKROOT" = "x" && test "x$XCRUN" != "xno"], + [SDKROOT=`xcrun --sdk macosx --show-sdk-path`] +) + AC_SUBST([XCODE_BASE]) AC_SUBST([HAS_OBJC]) +AC_SUBST([SDKROOT]) + # prefer clang over gcc because the plugins makes use of # clang-specific #pragma's @@ -350,8 +360,6 @@ AS_IF([test "$SED" != "xno"], [ AC_SUBST([GNU_SED]) AC_CHECK_TOOL([BREW], [brew], [no]) -AC_ARG_VAR([SDKROOT], [path to the OSX platform SDK used by clang]) -AC_SUBST([SDKROOT]) AC_CHECK_TOOL([INSTALL_NAME_TOOL], [install_name_tool], [no]) AC_SUBST([INSTALL_NAME_TOOL]) diff --git a/infer/models/c/src/Makefile b/infer/models/c/src/Makefile index 0c1bd3bcb..d8534ecad 100644 --- a/infer/models/c/src/Makefile +++ b/infer/models/c/src/Makefile @@ -11,7 +11,7 @@ CFLAGS=-c -w all: $(OBJECTS) clean: - $(QUIET)rm -rf $(OBJECTS) + $(QUIET)rm -rf $(OBJECTS) %.o: %.c $(CC) $(CFLAGS) $< -o $@