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