# Copyright (c) 2015 - present Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

@SET_MAKE@

PLATFORM = $(shell uname)

ATDGEN = @ATDGEN@
bindir = @bindir@
BUILD_C_ANALYZERS = @BUILD_C_ANALYZERS@
BUILD_JAVA_ANALYZERS = @BUILD_JAVA_ANALYZERS@
BUILD_LLVM_ANALYZERS = @BUILD_LLVM_ANALYZERS@
CC = @CC@
CFLAGS = @CFLAGS@
CLANG_INCLUDES = @CLANG_INCLUDES@
CLANG_PREFIX = @CLANG_PREFIX@
CPP = @CPP@
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@
ENABLE_OCAML_ANNOT = @ENABLE_OCAML_ANNOT@
ENABLE_OCAML_BINANNOT = @ENABLE_OCAML_BINANNOT@
exec_prefix = @exec_prefix@
INFER_MAJOR = @INFER_MAJOR@
INFER_MINOR = @INFER_MINOR@
INFER_PATCH = @INFER_PATCH@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
IS_FACEBOOK_TREE = @IS_FACEBOOK_TREE@
IS_RELEASE_TREE = @IS_RELEASE_TREE@
LDFLAGS = @LDFLAGS@
libdir = @libdir@
LIBS = @LIBS@
MKDIR_P_CMD = case "@MKDIR_P@" in \
    ./*) printf "$(ROOT_DIR)/@MKDIR_P@\n";; \
    *) printf "@MKDIR_P@\n";; \
    esac
MKDIR_P = $(shell $(MKDIR_P_CMD))
NCPU = @NCPU@
prefix = @prefix@
USER_JAVA_HOME = @USER_JAVA_HOME@
XCODE_SELECT = @XCODE_SELECT@

ifneq (,$(findstring s,$(MAKEFLAGS)))
# quiet mode
LN_S = @LN_S@
REMOVE = rm -f
REMOVE_DIR = rm -rf
RSYNC_A = rsync -av
else
LN_S = @LN_S@ -v
REMOVE = rm -vf
REMOVE_DIR = rm -rvf
RSYNC_A = rsync -aq
endif
COPY = cp -f -p
COPY_DIR = cp -Rf

ABSOLUTE_ROOT_DIR = $(shell cd $(ROOT_DIR) && pwd)

DEPENDENCIES_DIR = $(ABSOLUTE_ROOT_DIR)/dependencies
DOCKER_DIR = $(ABSOLUTE_ROOT_DIR)/docker
EXAMPLES_DIR = $(ABSOLUTE_ROOT_DIR)/examples
INFER_DIR = $(ABSOLUTE_ROOT_DIR)/infer
FCP_DIR = $(ABSOLUTE_ROOT_DIR)/facebook-clang-plugins
M4_DIR = $(ABSOLUTE_ROOT_DIR)/m4
SCRIPT_DIR = $(ABSOLUTE_ROOT_DIR)/scripts

FCP_CLANG_OCAML_DIR = $(FCP_DIR)/clang-ocaml

ANNOTATIONS_DIR = $(INFER_DIR)/annotations
BIN_DIR = $(INFER_DIR)/bin
BUILD_DIR = $(INFER_DIR)/_build
ETC_DIR = $(INFER_DIR)/etc
LIB_DIR = $(INFER_DIR)/lib
MODELS_DIR = $(INFER_DIR)/models
JAVA_BUILTINS_DIR = $(MODELS_DIR)/java/builtins
SRC_DIR = $(INFER_DIR)/src

ANNOT_DIR = $(SRC_DIR)/_build
INFER_BUILD_DIR = $(BUILD_DIR)/infer
LLVM_BUILD_DIR = $(BUILD_DIR)/llvm
TEST_BUILD_DIR = $(BUILD_DIR)/test

JAVA_LIB_DIR = $(LIB_DIR)/java
SPECS_LIB_DIR = $(LIB_DIR)/specs

PYTHON_DIR = $(LIB_DIR)/python
PYTHON_LIB_DIR = $(PYTHON_DIR)/inferlib
CAPTURE_LIB_DIR = $(PYTHON_LIB_DIR)/capture

INFERANALYZE_BIN = $(BIN_DIR)/InferAnalyze
INFERCLANG_BIN = $(BIN_DIR)/InferClang
INFERJAVA_BIN = $(BIN_DIR)/InferJava
INFERSTATS_BIN = $(BIN_DIR)/InferStatsAggregator
INFERPRINT_BIN = $(BIN_DIR)/InferPrint
INFERUNIT_BIN = $(BIN_DIR)/InferUnit
INFER_BUCK_COMPILATION_DATABASE_BIN = $(BIN_DIR)/InferBuckCompilationDatabase
INFER_BIN = $(LIB_DIR)/infer
INFERTRACEBUGS_BIN = $(BIN_DIR)/inferTraceBugs
# paths relative to $(ROOT_DIR)
INFER_BIN_SYMLINK = infer/bin/infer
INFERTRACEBUGS_BIN_RELPATH = infer/bin/inferTraceBugs

ifeq ($(BUILD_JAVA_ANALYZERS),yes)
JAVA_HOME=$(USER_JAVA_HOME)
endif

JAVA_DEPS = $(addprefix $(PYTHON_LIB_DIR)/, \
              analyze.py config.py issues.py jwlib.py source.py utils.py) \
            $(addprefix $(CAPTURE_LIB_DIR)/, javac.py util.py) \
            $(INFER_BIN) \
            $(INFERANALYZE_BIN) \
            $(INFERJAVA_BIN) \
            $(INFERPRINT_BIN)

CLANG_DEPS = $(addprefix $(PYTHON_LIB_DIR)/, \
               analyze.py config.py issues.py source.py utils.py) \
             $(addprefix $(CAPTURE_LIB_DIR)/, make.py util.py) \
             $(INFER_BIN) \
             $(INFERANALYZE_BIN) \
             $(INFERCLANG_BIN) \
             $(INFERPRINT_BIN)

JAVA_MODELS_JAR = $(LIB_DIR)/java/models.jar
