You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

357 lines
11 KiB

dnl Copyright (c) 2015-present, Facebook, Inc.
dnl
dnl This source code is licensed under the MIT license found in the
dnl LICENSE file in the root directory of this source tree.
dnl autoconf script for Infer
dnl run ./autogen.sh to generate a configure script
AC_PREREQ([2.63])
# WARNING: the version number has to be kept in sync with:
# - the values below
# - opam
AC_INIT([Infer],
[0.15.0],
[https://github.com/facebook/infer/issues/])
AC_CONFIG_SRCDIR([infer/src/istd/IStd.ml])
# WARNING: keep in sync with above
INFER_MAJOR=0
INFER_MINOR=15
INFER_PATCH=0
AC_SUBST([INFER_MAJOR])
AC_SUBST([INFER_MINOR])
AC_SUBST([INFER_PATCH])
# are we in a release source tree
AC_CHECK_FILE([.release], [is_release_tree=yes], [is_release_tree=no])
IS_RELEASE_TREE=$is_release_tree
AC_SUBST([IS_RELEASE_TREE])
# are we in an internal source tree
AC_CHECK_FILE([.facebook], [is_facebook_tree=yes], [is_facebook_tree=no])
IS_FACEBOOK_TREE=$is_facebook_tree
AC_SUBST([IS_FACEBOOK_TREE])
AC_ARG_VAR([PATH], [the shell's $PATH list of directories to search for executables])
# to compile the facebook-clang-plugins
AC_ARG_VAR([CLANG_PREFIX], [directory where clang is installed (defaults=$PWD/facebook-clang-plugins/clang/install)])
AS_IF([test "x$CLANG_PREFIX" = "x"], [
CLANG_PREFIX="$(pwd)/facebook-clang-plugins/clang/install"
])
AC_ARG_VAR([CLANG_INCLUDES], [clang headers directories (defaults=$CLANG_PREFIX/include)])
AS_IF([test "x$CLANG_INCLUDES" = "x"], [
CLANG_INCLUDES="$CLANG_PREFIX/include"
])
AC_ARG_ENABLE(c-analyzers,
AS_HELP_STRING([--disable-c-analyzers],
[do not build the C/C++/ObjC analyzers (default is to build them)]),
,
enable_c_analyzers=yes)
BUILD_C_ANALYZERS=$enable_c_analyzers
AC_SUBST([BUILD_C_ANALYZERS])
AC_ARG_ENABLE(java-analyzers,
AS_HELP_STRING([--disable-java-analyzers],
[do not build the Java analyzers (default is to build them)]),
,
enable_java_analyzers=yes)
BUILD_JAVA_ANALYZERS=$enable_java_analyzers
AC_SUBST([BUILD_JAVA_ANALYZERS])
AC_ARG_ENABLE(python-analyzers,
AS_HELP_STRING([--disable-python-analyzers],
[do not build the Python analyzers (default is to build them)]),
,
enable_python_analyzers=yes)
BUILD_PYTHON_ANALYZERS=$enable_python_analyzers
AC_SUBST([BUILD_PYTHON_ANALYZERS])
AC_ARG_WITH(fcp-clang,
AS_HELP_STRING([--without-fcp-clang],
[do not use $CLANG_PREFIX/bin/clang to override the default compiler (default is to override if in an infer release)]),
,
with_fcp_clang=$is_release_tree)
AS_IF([test "x$enable_c_analyzers" = "xyes"], [
AC_MSG_CHECKING([whether to use the compilers in $CLANG_PREFIX/bin])
case "$with_fcp_clang" in
no)
AC_MSG_RESULT([no])
;;
yes)
CC=$CLANG_PREFIX/bin/clang
CXX=$CLANG_PREFIX/bin/clang++
OBJC=$CLANG_PREFIX/bin/clang
AC_MSG_RESULT([yes])
;;
*)
AC_MSG_ERROR([invalid value for --without-fcp-clang; use "yes" or "no"])
;;
esac
AC_CHECK_TOOL([SHASUM], [shasum], [no])
AC_ASSERT_PROG([shasum], [$SHASUM])
# cmake is required to build llvm+clang
AC_CHECK_TOOL([CMAKE], [cmake], [no])
AS_IF([test "x$is_release_tree" = "xno"], [
AC_ASSERT_PROG([cmake], [$CMAKE])
])
AC_ARG_ENABLE(ocamlopt-custom-cc,
AS_HELP_STRING([--enable-ocamlopt-custom-cc], [use CC in ocamlopt invocations]),
,
enable_ocamlopt_custom_cc=no)
ENABLE_OCAMLOPT_CUSTOM_CC=$enable_ocamlopt_custom_cc
AC_SUBST([ENABLE_OCAMLOPT_CUSTOM_CC])
])
# end if($enable_c_analyzers)
AC_CHECK_TOOL([PYTHON27], [python2.7], [no])
AC_ASSERT_PROG([python2.7], [$PYTHON27])
AC_CHECK_TOOL([XCODE_SELECT], [xcode-select], [no])
# prefer clang over gcc because the plugins makes use of
# clang-specific #pragma's
AC_PROG_CC(clang gcc)
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
if test "x$enable_c_analyzers" = "xyes"; then
AC_PROG_CPP
AC_PROG_CXX(clang++ g++)
# AC_PROG_CXX doesn't set CXX to "no" in case of failure (I have no words...); from the manual:
# "If none of those checks succeed, then as a last resort set CXX to g++. "
AS_IF([command -v "$CXX" > /dev/null], [], [AC_MSG_ERROR([no C++ compiler found])])
dnl clang wants either clang version >= 3.1 or gcc version >= 4.7.2 to
dnl compile itself
AC_MSG_CHECKING([if the C/C++ compiler is recent enough])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#ifdef __clang__
#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1)
#error compiler is too old
#endif // version check
#elif defined __GNUC__ // __clang__
#if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 7 || (__GNUC_MINOR__ == 7 && __GNUC_PATCHLEVEL__ < 2)))
#error compiler is too old
#endif // version check
#endif // __GNUC__
]])],
[AC_MSG_RESULT([yes])],
[dnl
AC_MSG_RESULT([no])
AC_MSG_ERROR([
Your C/C++ compiler seems to be too old to build clang, which is
required by the facebook-clang-plugins. Please install either
gcc version >= 4.7.2 or clang version >= 3.1.
See the output of `./configure --help` to force the use of a different
C compiler.
Alternatively, you can checkout a release of infer with clang
pre-compiled here:
https://github.com/facebook/infer/releases/])
]
)
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h locale.h malloc.h stddef.h stdint.h stdlib.h string.h sys/mount.h sys/param.h sys/socket.h sys/statfs.h sys/time.h unistd.h wchar.h wctype.h])
fi
# end if($enable_c_analyzers)
# OCaml dependencies
AC_PROG_OCAML
AC_ASSERT_PROG([ocamlc], [$OCAMLC])
# check the version of OCaml
AC_ASSERT_OCAML_MIN_VERSION([4.06.1])
AC_ASSERT_PROG([ocamlopt], [$OCAMLOPT])
AC_CHECK_TOOL([OCAMLBUILD], [ocamlbuild], [no])
AC_ASSERT_PROG([ocamlbuild], [$OCAMLBUILD])
AC_PROG_FINDLIB
AC_PROG_OCAMLLEX
AC_ASSERT_PROG([ocamllex], [$OCAMLLEX])
AC_CHECK_TOOL([MENHIR], [menhir], [no])
AC_ASSERT_PROG([menhir], [$MENHIR])
AC_ASSERT_OCAML_PKG([atdgen], [], [])
AC_ASSERT_OCAML_PKG([biniou])
AC_ASSERT_OCAML_PKG([camlzip], [zip])
AC_ASSERT_OCAML_PKG([easy-format])
AC_ASSERT_OCAML_PKG([oUnit], [], [2.0.0])
[make] s/ocamlbuild/jbuilder/g Summary: Use jbuilder to build infer instead of ocamlbuild. This is mainly to get faster builds: ``` times in 10ms, ±differences measured in speedups, 4 cores | | ocb total | jb | ±total | ocb user | jb | ±user | ocb cpu | jb | ±cpu | ocb sys | jb | ±sys | |-----------------------------------+-----------+------+--------+----------+------+-------+---------+-----+------+---------+------+------| | byte from scratch | 6428 | 2456 | 2.62 | 7743 | 6662 | 1.16 | 138 | 331 | 2.40 | 1184 | 1477 | 0.80 | | native from scratch | 9841 | 4289 | 2.29 | 9530 | 8834 | 1.08 | 110 | 245 | 2.23 | 1373 | 1712 | 0.80 | | byte after native | 29578 | 1602 | 18.46 | 4514 | 4640 | 0.97 | 170 | 325 | 1.91 | 543 | 576 | 0.94 | | change infer.ml byte | 344 | 282 | 1.22 | 292 | 215 | 1.36 | 96 | 99 | 1.03 | 040 | 066 | 0.61 | | change infer.ml native | 837 | 223 | 3.75 | 789 | 174 | 4.53 | 98 | 99 | 1.01 | 036 | 47 | 0.77 | | change Config.ml byte | 451 | 339 | 1.33 | 382 | 336 | 1.14 | 97 | 122 | 1.26 | 056 | 80 | 0.70 | | change Config.ml native | 4024 | 1760 | 2.29 | 4585 | 4225 | 1.09 | 127 | 276 | 2.17 | 559 | 644 | 0.87 | | change cFrontend_config.ml byte | 348 | 643 | 0.54 | 297 | 330 | 0.90 | 96 | 67 | 0.70 | 038 | 102 | 0.37 | | change cFrontend_config.ml native | 1480 | 584 | 2.53 | 1435 | 906 | 1.58 | 106 | 185 | 1.75 | 136 | 178 | 0.76 | #+TBLFM: $4=$2/$3;f2::$7=$5/$6;f2::$10=$9/$8;f2::$13=$11/$12;f2 50 cores | | ocb total | jb | ±total | ocb user | jb | ±user | ocb cpu | jb | ±cpu | ocb sys | jb | ±sys | |---------------------+-----------+------+--------+----------+------+-------+---------+----+------+---------+------+------| | byte from scratch | 9114 | 2061 | 4.42 | 9334 | 5133 | 1.82 | | | 0/0 | 2566 | 1726 | 1.49 | | native from scratch | 13481 | 3967 | 3.40 | 12291 | 7608 | 1.62 | | | 0/0 | 3003 | 2100 | 1.43 | | byte after native | 3467 | 1476 | 2.35 | 5067 | 3912 | 1.30 | | | 0/0 | 971 | 801 | 1.21 | #+TBLFM: $4=$2/$3;f2::$7=$5/$6;f2::$10=$9/$8;f2::$13=$11/$12;f2 ``` Menu: 1. Write a jbuild file, autogenerated from jbuild.in because we need to fill in some information at build-time (really, at configure time, but TODO), such as whether or not clang is enabled. 2. Nuke lots of stuff from infer/src/Makefile that is now in the jbuild file 3. The jbuild file lives in infer/src/ so it can see all the sources. If we put it somewhere else, eg, infer/, then `jbuilder` scans too many files (all irrelevant) and takes 2.5s to start instead of .8s. Adding irrelevant directories to jbuild-ignore does not help. 4. jbuilder does not support subdirectories, so resort to listing all the source files in the generated jbuild (only source directories need to be manually listed in jbuild.in though). Still, the generated .merlin is wrong and makes merlin find source files in _build, so manually tune it to get good merlin support. We also lose some of merlin for unit tests as it cannot see their build artefacts anymore. 5. checkCopyright gets its own jbuild because it's standalone. Also, remove some deprecation warnings in checkCopyright due to the new version of Core from a while ago. 6. Drop less-used Makefile features (they had regressed anyway) such as building individual modules. Also, building mod_dep.pdf now takes all the source files available so they better build (before, it would only take the source files from the config, eg with or without clang) (that's pretty minor). 7. The toplevel is now built as a custom toplevel because that was easier. It should soon be even easier: https://github.com/janestreet/jbuilder/issues/210 8. Move BUILTINS.mli to BUILTINS.ml because jbuilder is not happy about interface files without implementations. In particular, I did not try to migrate too much of the Makefile logic to jbuilder, more can be done in the future. Reviewed By: jberdine Differential Revision: D5573661 fbshipit-source-id: 4ca6d8f
7 years ago
AC_CHECK_TOOL([UTOP], [utop], [no])
AC_ASSERT_OCAML_PKG([yojson])
AC_ARG_VAR([CAML_LD_LIBRARY_PATH],
[Additional directories to search for dynamically-loaded libraries.])
AC_ARG_VAR([OPAMROOT], [Root of the local opam installation.])
AC_ARG_VAR([OPAMSWITCH], [Opam switch used for building infer.])
AC_CHECK_TOOL([OPAM], [opam], [no])
AS_IF([test "$OPAM" != "no"], [
AC_MSG_CHECKING([current opam root])
OPAMROOT=$("$OPAM" config var root)
AC_MSG_RESULT([$OPAMROOT])
AC_MSG_CHECKING([current opam switch])
OPAMSWITCH=$("$OPAM" switch show)
AC_MSG_RESULT([$OPAMSWITCH])
], [
OPAMROOT=no
OPAMSWITCH=no
])
AC_SUBST([OPAMROOT])
AC_SUBST([OPAMSWITCH])
if test "x$enable_java_analyzers" = "xyes"; then
AC_CHECK_TOOL([JAVA], [java], [no])
AC_CHECK_TOOL([JAVAC], [javac], [no])
AC_ASSERT_PROG([javac], [$JAVAC])
AC_ASSERT_PROG([java], [$JAVA])
AC_ASSERT_OCAML_PKG([javalib], [], [2.3.3])
AC_ASSERT_OCAML_PKG([sawja], [], [1.5.2])
AC_ASSERT_OCAML_PKG([ptrees])
AC_MSG_CHECKING([for JAVA_HOME])
cat - <<_ACEOF >conftest.java
public class conftest {
public static void main(String[[]] args) {
System.out.println(System.getProperty("java.home"));
System.exit(0);
}
}
_ACEOF
rm -f conftest.class
if $JAVAC conftest.java; then
rm -f conftest.java
_USER_JAVA_HOME=$($JAVA -cp . conftest)
if rm -f conftest.class; then
USER_JAVA_HOME=$_USER_JAVA_HOME/..
else
AC_MSG_ERROR([Could not run test program with $JAVA])
fi
else
rm -f conftest.java
AC_MSG_ERROR([Could not compile test program with $JAVAC])
fi
AC_MSG_RESULT([$USER_JAVA_HOME])
AC_SUBST([USER_JAVA_HOME])
AC_CHECK_LIB([z], [inflateEnd], [ZLIB_FOUND=yes], [ZLIB_FOUND=no])
AS_IF([test x"$ZLIB_FOUND" = xno], [AC_MSG_ERROR([zlib not found.])])
fi
# end if($enable_java_analyzers)
AC_CHECK_TOOL([ATDGEN], [atdgen], [no])
AC_ASSERT_PROG([atdgen], [$ATDGEN])
AC_ARG_ENABLE(ocaml-bin-annot,
AS_HELP_STRING([--disable-ocaml-bin-annot], [do not build ocaml .cmt files]),
,
enable_ocaml_bin_annot=yes)
ENABLE_OCAML_BINANNOT=$enable_ocaml_bin_annot
AC_SUBST([ENABLE_OCAML_BINANNOT])
# We use Buck to run the Infer tests
AC_MSG_CHECKING([which .buckversion to use])
fb_buckversion_file=facebook/dependencies/dotbuckversion
oss_buckversion_file=dotbuckversion
AS_IF([test x"$is_facebook_tree" = x"yes"],
[buckversion_file="$fb_buckversion_file"],
[buckversion_file="$oss_buckversion_file"])
cat "$buckversion_file" > ".buckversion"
AC_MSG_RESULT([$buckversion_file])
AC_CHECK_TOOL([GETCONF], [getconf], [no])
AC_MSG_CHECKING([the number of cpus the build host has])
if test "$GETCONF" != "no"; then
if test $("$GETCONF" _NPROCESSORS_ONLN); then
NCPU=$("$GETCONF" _NPROCESSORS_ONLN)
AC_MSG_RESULT([$NCPU])
fi
else
NCPU=1
AC_MSG_RESULT([failed, defaulting to 1])
fi
AC_SUBST([NCPU])
# optional progs and libraries that, eg build systems to be run in integration tests
AC_CHECK_TOOL([ANT], [ant], [no])
AC_CHECK_TOOL([BUCK], [buck], [no])
AC_CHECK_TOOL([EMACS], [emacs], [no])
AC_ARG_VAR([MVN], [command to execute Maven when running tests])
AS_IF([test "x$MVN" = "x"], [
AC_CHECK_TOOL([MVN], [mvn], [no])
], [
AC_MSG_RESULT([checking for mvn... $MVN])
])
AC_CHECK_TOOL([NDKBUILD], [ndk-build], [no])
if test x"$NDKBUILD" = x"no"; then
# ndk-build not in $PATH, look into potential android NDK install paths and record the absolute path
# to ndk-build
AC_PATH_PROG([NDKBUILD], [ndk-build], [no],
[$PATH$PATH_SEPARATOR$ANDROID_NDK$PATH_SEPARATOR/opt/android_ndk/r15c])
fi
AC_CHECK_PYTHON_MODULE([$PYTHON27], [lxml])
AC_CHECK_TOOL([XCPRETTY], [xcpretty], [no])
AC_CHECK_TOOL([SED], [sed], [no])
AS_IF([test "$SED" != "xno"], [
AC_MSG_CHECKING([if sed is GNU sed])
AS_IF(["$SED" --version 2> /dev/null | grep -q -e "GNU sed"], [
GNU_SED="$SED"
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
AC_CHECK_TOOL([GNU_SED], [gsed], [no])
])
])
AC_SUBST([GNU_SED])
AC_CHECK_TOOL([BREW], [brew], [no])
# warn about broken pkg-config version for brew users
if test "$BREW" != "no"; then
if "$BREW" info pkg-config > /dev/null && \
test x"$(which pkg-config)" = x"/usr/local/bin/pkg-config"; then
AC_MSG_NOTICE([pkg-config seems to have been installed from Homebrew])
AC_MSG_CHECKING([for bad version of pkg-config brew package])
if readlink $(which pkg-config) | grep -q -e '/0.29.1_1/'; then
AC_MSG_RESULT([found 0.29.1_1])
AC_MSG_WARN([])
AC_MSG_WARN([This version of pkg-config is known to cause issues with compiling infer.])
AC_MSG_WARN([Consider running the following command to get a working version:])
AC_MSG_WARN([])
AC_MSG_WARN([ brew remove pkg-config && brew update && brew install pkg-config])
AC_MSG_WARN([])
else
AC_MSG_RESULT([no bad version found])
fi
fi
fi
AC_CHECK_INFER_MAN_LAST_MODIFIED()
AC_CONFIG_FILES([
Makefile.autoconf
])
AC_OUTPUT