@ -17,13 +17,9 @@ ATDGEN = @ATDGEN@
#### Global declarations ####
BUILD_DIR = $( INFER_DIR) /_build-infer
JAVA_BUILD_DIR = $( BUILD_DIR) /java
CLANG_BUILD_DIR = $( BUILD_DIR) /clang
BUILD_DIR = $( INFER_DIR) /_build
INFER_BUILD_DIR = $( BUILD_DIR) /infer
LLVM_BUILD_DIR = $( BUILD_DIR) /llvm
SCRIPTS_BUILD_DIR = $( BUILD_DIR) /scripts
TEST_BUILD_DIR = $( BUILD_DIR) /test
UNIT_BUILD_DIR = $( BUILD_DIR) /unit
ANNOT_DIR = $( SRC_DIR) /_build
ETC_DIR = $( INFER_DIR) /etc
@ -111,6 +107,7 @@ CLANG_BINIOU_DICT = $(ETC_DIR)/clang_ast.dict
#### LLVM declarations ####
LLVM_SOURCES = llvm
MENHIR_SOURCES = menhir
INFERLLVM_MAIN = $( LLVM_SOURCES) /lMain
INFERLLVM_BIN = $( BIN_DIR) /InferLLVM
@ -132,78 +129,107 @@ endif
DEPENDENCIES = IR backend checkers eradicate harness \
facebook/checkers facebook/checkers/graphql facebook/scripts $( EXTRA_DEPS)
OCAMLBUILD = rebuild $( OCAMLBUILD_OPTIONS) -j $( NCPU) $( addprefix -I , $( DEPENDENCIES) )
# ocamlbuild command with options common to all build targets
OCAMLBUILD_BASE = rebuild $( OCAMLBUILD_OPTIONS) -j $( NCPU) $( addprefix -I , $( DEPENDENCIES) )
.PHONY : all java clang llvm unit checkCopyright build_java build_clang build_llvm build_unit \
build_checkCopyright java_annotations clang_annotations llvm_annotations \
scripts_annotations init version sanitize clean
# ocamlbuild with options necessary to build all targets at once, regardless of configure flags
OCAMLBUILD_ALL = $( OCAMLBUILD_BASE) $( JAVA_OCAMLBUILD_OPTIONS)
default : $( INFER_ANALYZERS )
# list of ocamlbuild targets common to all build targets -- native version
INFER_BASE_TARGETS = \
$( INFERANALYZE_MAIN) .native \
$( INFERPRINT_MAIN) .native \
$( INFERUNIT_MAIN) .native \
$( CHECKCOPYRIGHT_MAIN) .native \
$( INFERUNIT_MAIN) .native
all : java clang llvm checkCopyright unit
INFER_ALL_TARGETS = $( INFER_BASE_TARGETS) \
$( INFERJAVA_MAIN) .native \
$( INFERCLANG_MAIN) .native \
$( INFERLLVM_MAIN) .native
java : $( INFERJAVA_BIN )
# configure-aware ocamlbuild commands and targets
OCAMLBUILD_CONFIG = $( OCAMLBUILD_BASE)
INFER_CONFIG_TARGETS = $( INFER_BASE_TARGETS)
clang : $( INFERCLANG_BIN ) $( CLANG_BINIOU_DICT )
llvm : $( INFERLLVM_BIN )
unit : $( INFERUNIT_BIN )
i f e q ( @ B U I L D _ J A V A _ A N A L Y Z E R S @ , y e s )
OCAMLBUILD_CONFIG += $( JAVA_OCAMLBUILD_OPTIONS)
INFER_CONFIG_TARGETS += $( INFERJAVA_MAIN) .native
e n d i f
i f e q ( @ B U I L D _ C _ A N A L Y Z E R S @ , y e s )
INFER_CONFIG_TARGETS += $( INFERCLANG_MAIN) .native
e n d i f
i f e q ( @ B U I L D _ L L V M _ A N A L Y Z E R S @ , y e s )
INFER_CONFIG_TARGETS += $( INFERLLVM_MAIN) .native
e n d i f
checkCopyright : $( CHECKCOPYRIGHT_BIN )
.PHONY: all infer init version sanitize clean
build_java : init $( INFERPRINT_ATDGEN_STUBS )
$( OCAMLBUILD) -build-dir $( JAVA_BUILD_DIR) $( JAVA_OCAMLBUILD_OPTIONS) \
$( INFERANALYZE_MAIN) .native \
$( INFERPRINT_MAIN) .native \
$( INFERJAVA_MAIN) .native
all : infer
build_clang : init $( INFERPRINT_ATDGEN_STUBS ) $( CLANG_ATDGEN_STUBS ) $( INFER_CLANG_FCP_MIRRORED_FILES )
$( OCAMLBUILD) -build-dir $( CLANG_BUILD_DIR) \
$( INFERANALYZE_MAIN) .native \
$( INFERPRINT_MAIN) .native \
$( INFERCLANG_MAIN) .native
infer : init $( INFERPRINT_ATDGEN_STUBS )
$( OCAMLBUILD_CONFIG) -build-dir $( INFER_BUILD_DIR) $( INFER_CONFIG_TARGETS)
$( COPY) $( INFER_BUILD_DIR) /$( INFERANALYZE_MAIN) .native $( INFERANALYZE_BIN)
$( COPY) $( INFER_BUILD_DIR) /$( INFERPRINT_MAIN) .native $( INFERPRINT_BIN)
$( COPY) $( INFER_BUILD_DIR) /$( CHECKCOPYRIGHT_MAIN) .native $( CHECKCOPYRIGHT_BIN)
$( COPY) $( INFER_BUILD_DIR) /$( INFERUNIT_MAIN) .native $( INFERUNIT_BIN)
i f e q ( @ B U I L D _ L L V M _ A N A L Y Z E R S @ , y e s )
$( COPY) $( INFER_BUILD_DIR) /$( INFERLLVM_MAIN) .native $( INFERLLVM_BIN)
e n d i f
i f e q ( @ B U I L D _ J A V A _ A N A L Y Z E R S @ , y e s )
$( COPY) $( INFER_BUILD_DIR) /$( INFERJAVA_MAIN) .native $( INFERJAVA_BIN)
e n d i f
i f e q ( @ B U I L D _ C _ A N A L Y Z E R S @ , y e s )
$( COPY) $( INFER_BUILD_DIR) /$( INFERCLANG_MAIN) .native $( INFERCLANG_BIN)
e n d i f
i f e q ( @ E N A B L E _ O C A M L _ A N N O T @ , y e s )
rsync -a --include '*/' --include '*.annot' --exclude '*' $( INFER_BUILD_DIR) / $( ANNOT_DIR) /
e n d i f
build_llvm :
$( OCAMLBUILD) -build-dir $( LLVM_BUILD_DIR) -use-menhir $( INFERLLVM_MAIN) .native
i f e q ( @ B U I L D _ C _ A N A L Y Z E R S @ , y e s )
infer : $( CLANG_ATDGEN_STUBS ) $( INFER_CLANG_FCP_MIRRORED_FILES )
e n d i f
i f e q ( @ B U I L D _ L L V M _ A N A L Y Z E R S @ , y e s )
infer : $( LLVM_SOURCES ) /lLexer .ml $( LLVM_SOURCES ) /lParser .ml
e n d i f
build_checkCopyright :
$( OCAMLBUILD) -build-dir $( SCRIPTS_BUILD_DIR) -I $( SCRIPT_SOURCES) \
$( CHECKCOPYRIGHT_MAIN) .native
$(LLVM_SOURCES)/lLexer.ml $(LLVM_SOURCES)/lParser.ml: init
$( OCAMLBUILD_BASE) -build-dir $( LLVM_BUILD_DIR) -I $( LLVM_SOURCES) -use-menhir $( MENHIR_SOURCES) /$( @F)
$( COPY) $( LLVM_BUILD_DIR) /$( MENHIR_SOURCES) /$( @F) $@
build_unit :
$( OCAMLBUILD) -build-dir $( UNIT_BUILD_DIR) -I $( UNIT_SOURCES) \
$( INFERUNIT_MAIN) .native
$(LLVM_SOURCES)/lLexer.ml : $( MENHIR_SOURCES ) /lLexer .mll
# avoid race condition between concurrently running ocamlbuild instances by making the parser depend
# on the lexer
$(LLVM_SOURCES)/lParser.ml : $( MENHIR_SOURCES ) /lParser .mly $( LLVM_SOURCES ) /lLexer .ml
byte : init $( INFERPRINT_ATDGEN_STUBS ) $( CLANG_ATDGEN_STUBS ) $( INFER_CLANG_FCP_MIRRORED_FILES )
$( OCAMLBUILD) -build-dir $( TEST_BUILD_DIR) $( JAVA_OCAMLBUILD_OPTIONS) \
$( INFERANALYZE_MAIN) .byte \
$( INFERPRINT_MAIN) .byte \
$( INFERJAVA_MAIN) .byte \
$( INFERCLANG_MAIN) .byte \
$( INFERUNIT_MAIN) .byte \
$( CHECKCOPYRIGHT_MAIN) .byte
byte : init $( INFERPRINT_ATDGEN_STUBS ) $( CLANG_ATDGEN_STUBS ) $( INFER_CLANG_FCP_MIRRORED_FILES ) \
$( LLVM_SOURCES) /lLexer.ml $( LLVM_SOURCES) /lParser.ml
$( OCAMLBUILD_ALL) -build-dir $( INFER_BUILD_DIR) $( INFER_ALL_TARGETS:.native= .byte)
# to build only the single module <Module> (and its dependencies) with extra flags execute:
# make INFER_CFLAGS=<flags> M=<Module>.cm{o,x} module
M =
INFER_CFLAGS =
module : init $( INFERPRINT_ATDGEN_STUBS ) $( CLANG_ATDGEN_STUBS ) $( INFER_CLANG_FCP_MIRRORED_FILES )
$( OCAMLBUILD) -build-dir $( TEST_BUILD_DIR) $( JAVA_OCAMLBUILD_OPTIONS) \
module : init $( INFERPRINT_ATDGEN_STUBS ) $( CLANG_ATDGEN_STUBS ) $( INFER_CLANG_FCP_MIRRORED_FILES ) \
$( LLVM_SOURCES) /lLexer.ml $( LLVM_SOURCES) /lParser.ml
$( OCAMLBUILD_ALL) -build-dir $( INFER_BUILD_DIR) \
-cflags -warn-error,$( OCAML_FATAL_WARNINGS) \
-cflags $( INFER_CFLAGS) \
$( M)
test_build : init $( INFERPRINT_ATDGEN_STUBS ) $( CLANG_ATDGEN_STUBS ) $( INFER_CLANG_FCP_MIRRORED_FILES )
$( OCAMLBUILD) -build-dir $( TEST_BUILD_DIR) $( JAVA_OCAMLBUILD_OPTIONS) \
test_build : init $( INFERPRINT_ATDGEN_STUBS ) $( CLANG_ATDGEN_STUBS ) $( INFER_CLANG_FCP_MIRRORED_FILES ) \
$( LLVM_SOURCES) /lLexer.ml $( LLVM_SOURCES) /lParser.ml
$( OCAMLBUILD_ALL) -build-dir $( INFER_BUILD_DIR) \
-cflags -warn-error,$( OCAML_FATAL_WARNINGS) \
$( INFERANALYZE_MAIN) .byte \
$( INFERPRINT_MAIN) .byte \
$( INFERJAVA_MAIN) .byte \
$( INFERCLANG_MAIN) .byte \
$( INFERUNIT_MAIN) .byte \
$( CHECKCOPYRIGHT_MAIN) .byte
$( INFER_ALL_TARGETS)
$( COPY) $( INFER_BUILD_DIR) /$( INFERANALYZE_MAIN) .native $( INFERANALYZE_BIN)
$( COPY) $( INFER_BUILD_DIR) /$( INFERPRINT_MAIN) .native $( INFERPRINT_BIN)
$( COPY) $( INFER_BUILD_DIR) /$( CHECKCOPYRIGHT_MAIN) .native $( CHECKCOPYRIGHT_BIN)
$( COPY) $( INFER_BUILD_DIR) /$( INFERUNIT_MAIN) .native $( INFERUNIT_BIN)
$( COPY) $( INFER_BUILD_DIR) /$( INFERLLVM_MAIN) .native $( INFERLLVM_BIN)
$( COPY) $( INFER_BUILD_DIR) /$( INFERJAVA_MAIN) .native $( INFERJAVA_BIN)
$( COPY) $( INFER_BUILD_DIR) /$( INFERCLANG_MAIN) .native $( INFERCLANG_BIN)
$(DEPENDENCIES_DIR)/ocamldot/ocamldot :
$( MAKE) -C $( DEPENDENCIES_DIR) /ocamldot
@ -218,25 +244,6 @@ mod_dep.dot: $(DEPENDENCIES_DIR)/ocamldot/ocamldot $(src_files)
| $( DEPENDENCIES_DIR) /ocamldot/ocamldot -lr $( root_flags) \
> mod_dep.dot
i f e q ( @ E N A B L E _ O C A M L _ A N N O T @ , y e s )
java_annotations : build_java
rsync -a --include '*/' --include '*.annot' --exclude '*' $( JAVA_BUILD_DIR) / $( ANNOT_DIR) /
clang_annotations : build_clang
rsync -a --include '*/' --include '*.annot' --exclude '*' $( CLANG_BUILD_DIR) / $( ANNOT_DIR) /
llvm_annotations : build_llvm
rsync -a --include '*/' --include '*.annot' --exclude '*' $( LLVM_BUILD_DIR) / $( ANNOT_DIR) /
scripts_annotations : build_checkCopyright
rsync -a --include '*/' --include '*.annot' --exclude '*' $( SCRIPTS_BUILD_DIR) / $( ANNOT_DIR) /
java : java_annotations
clang : clang_annotations
llvm : llvm_annotations
checkCopyright : scripts_annotations
e n d i f
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:
@ -303,33 +310,17 @@ version: backend/version.ml.in Makefile
$(BUILD_DIR) :
$( MKDIR_P) $( BUILD_DIR)
$(INFERJAVA_BIN) : build_java
$( COPY) $( JAVA_BUILD_DIR) /$( INFERANALYZE_MAIN) .native $( INFERANALYZE_BIN)
$( COPY) $( JAVA_BUILD_DIR) /$( INFERPRINT_MAIN) .native $( INFERPRINT_BIN)
$( COPY) $( JAVA_BUILD_DIR) /$( INFERJAVA_MAIN) .native $( INFERJAVA_BIN)
$(INFERCLANG_BIN) : build_clang
$( COPY) $( CLANG_BUILD_DIR) /$( INFERANALYZE_MAIN) .native $( INFERANALYZE_BIN)
$( COPY) $( CLANG_BUILD_DIR) /$( INFERPRINT_MAIN) .native $( INFERPRINT_BIN)
$( COPY) $( CLANG_BUILD_DIR) /$( INFERCLANG_MAIN) .native $( INFERCLANG_BIN)
$(INFERLLVM_BIN) : build_llvm
$( COPY) $( LLVM_BUILD_DIR) /$( INFERLLVM_MAIN) .native $( INFERLLVM_BIN)
$(INFERUNIT_BIN) : build_unit
$( COPY) $( UNIT_BUILD_DIR) /$( INFERUNIT_MAIN) .native $( INFERUNIT_BIN)
$(CHECKCOPYRIGHT_BIN) : build_checkCopyright
$( COPY) $( SCRIPTS_BUILD_DIR) /$( CHECKCOPYRIGHT_MAIN) .native $( CHECKCOPYRIGHT_BIN)
test_clean :
$( REMOVE_DIR) $( TEST _BUILD_DIR)
$( REMOVE_DIR) $( INFER_BUILD_DIR)
clean :
$( REMOVE_DIR) $( BUILD_DIR)
$( REMOVE) $( ETC_DIR) /clang_ast.dict
i f e q ( @ E N A B L E _ O C A M L _ A N N O T @ , y e s )
$( REMOVE_DIR) $( ANNOT_DIR)
e n d i f
i f e q ( @ B U I L D _ L L V M _ A N A L Y Z E R S @ , y e s )
$( REMOVE) $( LLVM_SOURCES) /lLexer.ml $( LLVM_SOURCES) /lParser.ml
e n d i f
$( REMOVE) backend/version.ml
$( REMOVE) backend/version.ml.tmp.*