@ -8,21 +8,19 @@ include $(ROOT_DIR)/Makefile.config
#### Global declarations ####
# o verride this for faster builds (but slower infer)
# O verride this for faster builds (but slower infer)
BUILD_MODE ?= opt
BUILD_ROOT = _build
# paths to BUILD_DIR are relative because that's how dune likes it
INFER_BUILD_DIR = $( BUILD_ROOT) /default
DUNE_BUILD = dune build --profile= $( BUILD_MODE) --build-dir= $( BUILD_ROOT)
DUNE_BUILD = dune build --profile= $( BUILD_MODE)
ETC_DIR = $( INFER_DIR) /etc
#### Backend declarations ####
INFER_MAIN = infer
#### Checkers declarations ####
INFERTOP_MAIN = infertop
INFERUNIT_MAIN = inferunit
INFER_CREATE_TRACEVIEW_LINKS_MODULE = InferCreateTraceViewLinks
INFER_CREATE_TRACEVIEW_LINKS_MAIN = $( INFER_CREATE_TRACEVIEW_LINKS_MODULE)
CHECKCOPYRIGHT_MAIN = checkCopyright
INFER_ATDGEN_STUB_BASES = atd/jsonbug atd/runstate atd/java_method_decl atd/perf_profiler atd/java_profiler_samples atd/clang_profiler_samples
INFER_ATDGEN_TYPES = j t
@ -31,15 +29,8 @@ INFER_ATDGEN_SUFFIXES = $(foreach atd_t,$(INFER_ATDGEN_TYPES),_$(atd_t).ml _$(at
INFER_ATDGEN_STUBS = $( foreach base,$( INFER_ATDGEN_STUB_BASES) ,\
$( addprefix $( base) ,$( INFER_ATDGEN_SUFFIXES) ) )
#### InferCreateTraceViewLinks declarations ####
FACEBOOK_DIR = facebook
INFER_CREATE_TRACEVIEW_LINKS_MODULE = InferCreateTraceViewLinks
INFER_CREATE_TRACEVIEW_LINKS_MAIN = $( INFER_CREATE_TRACEVIEW_LINKS_MODULE)
### InferUnit declarations ###
INFERUNIT_MAIN = inferunit
#### Clang declarations ####
@ -65,21 +56,14 @@ CLANG_PLUGIN_MIRRORED_FILES = $(addprefix $(CLANG_PLUGIN_MIRROR)/, $(notdir $(FC
CLANG_BINIOU_DICT = $( ETC_DIR) /clang_ast.dict
#### scripts declarations ####
CHECKCOPYRIGHT_BIN = $( SCRIPT_DIR) /checkCopyright
CHECKCOPYRIGHT_MAIN = checkCopyright
#### End of declarations ####
i f e q ( $( ENABLE_OCAMLOPT_CUSTOM_CC ) , y e s )
EXTRA_CFLAGS += -cc,$( CC)
e n d i f
# list of ocamlbuild targets common to all build targets -- native version
INFER_CONFIG_TARGETS = $( INFER_BUILD_DIR) /$( INFER_ MAIN) .exe
INFER_CONFIG_TARGETS = $( INFER_MAIN) .exe
i f e q ( $( IS_FACEBOOK_TREE ) , y e s )
INFER_CONFIG_TARGETS += $( INFER_BUILD_DIR) /$( INFER_ CREATE_TRACEVIEW_LINKS_MAIN) .exe
INFER_CONFIG_TARGETS += $( INFER_CREATE_TRACEVIEW_LINKS_MAIN) .exe
e n d i f
OCAML_GENERATED_SOURCES = \
@ -96,7 +80,10 @@ OCAML_SOURCES = \
.PHONY : all
all : infer
GENERATED_FROM_AUTOCONF = dune.common dune-workspace base/Version.ml
GENERATED_FROM_AUTOCONF = dune.common ../dune-workspace base/Version.ml
.PHONY : dune -workspace
dune-workspace : ../dune -workspace
GENERATED_DUNES += dune
@ -108,25 +95,12 @@ endif
.PHONY : src_build_common
src_build_common : $( SRC_BUILD_COMMON )
# Single out infer.exe as the source of truth for make, knowing that in fact several
# targets are produced by the build.
# The target is marked as .PHONY because if you build with one profile `make
# BUILD_MODE=dev` and then try with another profile `make BUILD_MODE=opt`, make won't
# trigger a rebuild since it has only partial view on the dependencies.
.PHONY : $( INFER_BUILD_DIR ) /$( INFER_MAIN ) .exe
$(INFER_BUILD_DIR)/$(INFER_MAIN).exe : $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
$( QUIET) $( DUNE_BUILD) $( INFER_CONFIG_TARGETS)
# let make know that the target is up-to-date even if ocamlbuild cached it
$( QUIET) touch $@
.PHONY : test
test : BUILD_MODE = test
test : $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
# needed for dune to "install" the relevant dynamic libraries for the C stubs
$( QUIET) cd c_stubs; $( DUNE_BUILD) InferCStubs.install
$( QUIET) $( DUNE_BUILD) \
$( patsubst $( INFER_BUILD_DIR) / %.exe,%.bc, $( INFER_CONFIG_TARGETS) ) \
scripts/checkCopyright.bc $( INFERUNIT_MAIN) .bc infertop.bc
$( patsubst %.exe, %.bc.exe, $( INFER_CONFIG_TARGETS) ) \
scripts/$( CHECKCOPYRIGHT_MAIN) .bc.exe $( INFERUNIT_MAIN) .bc.exe $( INFERTOP_MAIN) .bc.exe
.PHONY : doc
doc : $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
@ -136,57 +110,54 @@ doc: $(SRC_BUILD_COMMON) $(MAKEFILE_LIST)
check : src_build_common
$( DUNE_BUILD) @check
#### Aliases for building binaries ####
INFER_BIN_ALIASES = $( foreach alias,$( INFER_COMMANDS) ,$( BIN_DIR) /$( alias ) )
# Single out infer[.bc].exe as the source of truth for make, knowing that in fact several
# targets are produced by the build.
# The targets below are marked as .PHONY because if you build with one profile `make
# BUILD_MODE=dev` and then try with another profile `make BUILD_MODE=opt`, make won't
# trigger a rebuild since it has only partial view on the dependencies.
$(INFER_BIN_ALIASES) : Makefile $( BIN_DIR ) /$( INFER_MAIN )
$( REMOVE) $@
$( QUIET) cd $( @D) && $( LN_S) -f infer $( @F)
$( QUIET) touch $@
.PHONY : $( INFER_BIN ) .exe
$(INFER_BIN).exe : $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
$( QUIET) $( DUNE_BUILD) $( INFER_CONFIG_TARGETS)
$(INFER_BIN).exe : $( INFER_BUILD_DIR ) /$( INFER_MAIN ) .exe
$( QUIET) $( MKDIR_P) $( BIN_DIR)
i f e q ( $( WINDOWS_BUILD ) , y e s )
# http://cygwin.1069669.n5.nabble.com/cp-utility-bug-when-dest-name-exe-file-exist-tp57955p58001.html
$( REMOVE) $( INFER_BIN) $( INFER_BIN) .exe
e n d i f
$( INSTALL_PROGRAM) -C $( INFER_BUILD_DIR) /$( INFER_MAIN) .exe $( INFER_BIN) .exe
i f e q ( $( IS_FACEBOOK_TREE ) , y e s )
$( INSTALL_PROGRAM) -C $( INFER_BUILD_DIR) /$( INFER_CREATE_TRACEVIEW_LINKS_MAIN) .exe \
$( INFER_CREATE_TRACEVIEW_LINKS_BIN)
e n d i f
.PHONY : $( INFER_BIN ) .bc .exe
$(INFER_BIN).bc.exe : $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
$( QUIET) $( DUNE_BUILD) $( patsubst %.exe, %.bc.exe, $( INFER_CONFIG_TARGETS) )
.PHONY : $( INFERTOP_BIN ) toplevel
$(INFERTOP_BIN) : $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
$( DUNE_BUILD) $( INFERTOP_MAIN) .bc.exe
toplevel : $( INFERTOP_BIN )
.PHONY : $( CHECKCOPYRIGHT_BIN ) checkCopyright
$(CHECKCOPYRIGHT_BIN) : $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
$( DUNE_BUILD) scripts/$( CHECKCOPYRIGHT_MAIN)
checkCopyright : $( CHECKCOPYRIGHT_BIN )
.PHONY : infer
infer : $( INFER_BIN ) .exe
$( INSTALL_PROGRAM) -C $( INFER_BIN) .exe $( INFER_BIN)
$( MAKE) $( INFER_BIN_ALIASES)
.PHONY : $( INFER_BUILD_DIR ) /$( INFER_MAIN ) .bc
$(INFER_BUILD_DIR)/$(INFER_MAIN).bc : $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
$( DUNE_BUILD) $( INFER_CONFIG_TARGETS:.exe= .bc)
$( QUIET) touch $@
.PHONY : $( INFER_BIN ) .bc
$(INFER_BIN).bc : $( INFER_BUILD_DIR ) /$( INFER_MAIN ) .bc
$( QUIET) $( MKDIR_P) $( BIN_DIR)
i f e q ( $( WINDOWS_BUILD ) , y e s )
# http://cygwin.1069669.n5.nabble.com/cp-utility-bug-when-dest-name-exe-file-exist-tp57955p58001.html
$( REMOVE) $( INFER_BIN) $( INFER_BIN) .exe
e n d i f
$( INSTALL_PROGRAM) -C $( INFER_BUILD_DIR) /$( INFER_MAIN) .bc $( INFER_BIN) .bc
i f e q ( $( IS_FACEBOOK_TREE ) , y e s )
$( INSTALL_PROGRAM) -C $( INFER_BUILD_DIR) /$( INFER_CREATE_TRACEVIEW_LINKS_MAIN) .bc \
$( INFER_CREATE_TRACEVIEW_LINKS_BIN)
$( INSTALL_PROGRAM) -C $( INFER_CREATE_TRACEVIEW_LINKS_BIN) .exe $( INFER_CREATE_TRACEVIEW_LINKS_BIN)
e n d i f
# needed for dune to "install" the relevant dynamic libraries for the C stubs
cd c_stubs; $( DUNE_BUILD) InferCStubs.install
$( MAKE) $( INFER_BIN_ALIASES)
.PHONY : byte
byte : $( INFER_BIN ) .bc
$( INSTALL_PROGRAM) -C $( INFER_BIN) .byte $( INFER_BIN)
byte : $( INFER_BIN ) .bc .exe
$( INSTALL_PROGRAM) -C $( INFER_BIN) .bc.exe $( INFER_BIN)
i f e q ( $( IS_FACEBOOK_TREE ) , y e s )
$( INSTALL_PROGRAM) -C $( INFER_CREATE_TRACEVIEW_LINKS_BIN) .bc.exe $( INFER_CREATE_TRACEVIEW_LINKS_BIN)
e n d i f
$( MAKE) $( INFER_BIN_ALIASES)
INFER_BIN_ALIASES = $( foreach alias,$( INFER_COMMANDS) ,$( BIN_DIR) /$( alias ) )
$(INFER_BIN_ALIASES) : Makefile $( BIN_DIR ) /$( INFER_MAIN )
$( REMOVE) $@
$( QUIET) cd $( @D) && $( LN_S) -f infer $( @F)
$( QUIET) touch $@
roots := Infer
i f e q ( $( IS_FACEBOOK_TREE ) , y e s )
roots += $( INFER_CREATE_TRACEVIEW_LINKS_MODULE)
@ -212,28 +183,6 @@ mod_dep.pdf: mod_dep.dot
dsort :
$( QUIET) ocamldep.opt -sort $( inc_flags) $( ml_src_files)
.PHONY : $( INFER_BUILD_DIR ) /infertop .bc
$(INFER_BUILD_DIR)/infertop.bc : $( SRC_DIR ) /infertop .ml $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
$( DUNE_BUILD) $@
# needed for dune to "install" the relevant dynamic libraries for the C stubs
cd c_stubs; $( DUNE_BUILD) InferCStubs.install
$( QUIET) touch $@
$(INFERTOP_BIN) : $( INFER_BUILD_DIR ) /infertop .bc
$( QUIET) $( INSTALL_PROGRAM) -C $< $@
$( QUIET) touch $@
.PHONY : toplevel
toplevel : $( INFERTOP_BIN )
.PHONY : checkCopyright
checkCopyright : $( CHECKCOPYRIGHT_BIN )
.PHONY : $( CHECKCOPYRIGHT_BIN )
$(CHECKCOPYRIGHT_BIN) : $( SRC_BUILD_COMMON ) $( MAKEFILE_LIST )
$( DUNE_BUILD) $( INFER_BUILD_DIR) /scripts/$( CHECKCOPYRIGHT_MAIN) .exe
$( INSTALL_PROGRAM) -C $( INFER_BUILD_DIR) /scripts/$( CHECKCOPYRIGHT_MAIN) .exe $( CHECKCOPYRIGHT_BIN)
d e f i n e g e n _ a t d g e n _ r u l e s
# generate files using atdgen
# parameters:
@ -300,7 +249,7 @@ $(GENERATED_FROM_AUTOCONF): $(MAKEFILE_LIST)
cat " $$ TMPFILE " > $@ ; \
$( REMOVE) " $$ TMPFILE "
dune.common : dune .common .in
dune-workspace: dune -workspace .in
../ dune-workspace: ../ dune -workspace .in
base/Version.ml : base /Version .ml .in
$(GENERATED_DUNES) : dune .common
@ -314,20 +263,18 @@ clean:
$( MAKE) -C deadcode clean
$( REMOVE) $( INFER_TARGET)
$( REMOVE) toplevel.mlpack
$( REMOVE_DIR) $( BUILD_DIR)
$( REMOVE) $( ETC_DIR) /clang_ast.dict
$( REMOVE) $( GENERATED_FROM_AUTOCONF)
$( REMOVE) $( GENERATED_DUNES)
$( REMOVE) base/Version.ml.tmp.* dune.tmp.* dune-workspace.tmp.*
# be a bit more aggressive than needed with what we remove here so that stale binaries that
# only existed in previous versions get removed as well
$( REMOVE) $( BIN_DIR) /Infer* $( BIN_DIR) /infer-* $( INFER_BIN) { ,.bc,.exe} $( INFER_BIN_ALIASES) \
$( INFERUNIT_BIN) $( CHECKCOPYRIGHT_BIN)
$( REMOVE) $( INFER_BIN) $( INFER_BIN_ALIASES) $( INFER_CREATE_TRACEVIEW_LINKS_BIN)
$( REMOVE) $( BIN_DIR) /llvm_sil
$( REMOVE) $( INFER_CREATE_TRACEVIEW_LINKS_BIN)
$( REMOVE) atd/*_{ j,t,v} .ml{ ,i} atd/clang_ast_*
$( REMOVE) mod_dep.dot
$( REMOVE) mod_dep.pdf
cd .. && dune clean
.PHONY : fmt
fmt :