# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# Template configuration file for make.
# You may use $(LEVEL) to refer to the directory containing this file.

# --- targeted clang compiler ----

# Where to find clang installation directories
CLANG_PREFIX?=$(LEVEL)/clang/install
# Where to find clang headers (possibly a list, see below)
CLANG_INCLUDES?=$(CLANG_PREFIX)/include

# example of alternative paths to compile and load the plugin into a locally compiled, not yet installed llvm/clang
#CLANG_PREFIX=llvm-build/Debug+Asserts
#CLANG_INCLUDES=llvm/tools/clang/include llvm-build/tools/clang/include llvm-build/include llvm/include

# target compiler, must match the exact same version of clang as the include files
CLANG?=$(CLANG_PREFIX)/bin/clang

LLVM_CXXFLAGS?=`$(CLANG_PREFIX)/bin/llvm-config --cxxflags 2>/dev/null || true`
LLVM_LDFLAGS?=`$(CLANG_PREFIX)/bin/llvm-config --ldflags --libs --system-libs 2>/dev/null || true`

# --- local clang compiler ---

# Which compiler to use to compile the plugin themselves.
LOCAL_CLANG?=clang
CC=$(LOCAL_CLANG)
CXX=$(LOCAL_CLANG)++

# Which preprocessor to use to extract ATD comments from cpp files.
# @requires clang >= 3.4 (The nonstandard part here is that we want to expand doc-comments contained in macros.)
ATD_CPP?=$(LOCAL_CLANG) -cc1 -E -traditional-cpp -w -P -main-file-name - -o -

# Which preprocessor to use on ocaml "pre-source" files.
OCAML_CPP?=$(LOCAL_CLANG) -cc1 -E -P -x c -main-file-name - -o -

# --- Objective C ---

# Which SDK to use (if any)
SDKPATH?=$(shell ls -d "`xcode-select --print-path 2> /dev/null`"/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.sdk 2> /dev/null | sort -r | head -n 1 || true)
ifeq ($SDKPATH,)
  SDKPATH?=$(shell ls -d "`xcode-select --print-path 2> /dev/null`"/SDKs/MacOSX.sdk 2> /dev/null | sort -r | head -n 1 || true)
endif

ifeq ($(SDKPATH),)
HAS_OBJC=no
else
HAS_OBJC=yes
endif