Skip to content

Commit

Permalink
add configure script
Browse files Browse the repository at this point in the history
Summary:
public
For now, the script only checks that the ocaml dependencies are present.

Reviewed By: meyering

Differential Revision: D2702956

fb-gh-sync-id: 6945b63
  • Loading branch information
jvillard authored and facebook-github-bot-7 committed Dec 3, 2015
1 parent 96b659b commit 1e3085e
Show file tree
Hide file tree
Showing 7 changed files with 480 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
# Directories generated by Ocamlbuild
_build

# autoconf-generated stuff
/acinclude.m4
/aclocal.m4
/autom4te.cache
/config.status
/configure

# IntelliJ files
/scripts/.idea/
/infer/tests/.idea/dictionaries
Expand Down
41 changes: 41 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

# 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 -e

# try to pull submodules if we are in a git repo
# might fail if git is not installed (how did you even checkout the
# repo in the first place?)
if test -d '.git'; then
echo -n 'git repository detected, updating submodule... '
if git submodule update --init > /dev/null; then
echo 'done'
else
echo 'error running git command'
fi
else
echo 'no git repository detected; not updating facebook-clang-plugins/'
fi

ACINCLUDE="acinclude.m4"
echo -n "generating $ACINCLUDE..."
cat m4/*.m4 > "$ACINCLUDE"
echo " done"

echo -n "generating ./configure script..."
autoreconf -fi
echo " done"

echo ""
echo "you may now run the following commands to build Infer:"
echo ""
echo " ./configure"
echo " make -C infer clang java"
echo ""
echo 'run `./configure --help` for more options'
52 changes: 52 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
dnl autoconf script for Infer
dnl run ./autogen.sh to generate a configure script
dnl
dnl Copyright (c) 2015 - present Facebook, Inc.
dnl All rights reserved.
dnl
dnl This source code is licensed under the BSD style license found in the
dnl LICENSE file in the root directory of this source tree. An additional grant
dnl of patent rights can be found in the PATENTS file in the same directory.

AC_PREREQ([2.63])

# TODO: use the stuff in infer/src/Makefile and version.ml.in instead
# of 0.4.0
AC_INIT([Infer],[0.4.0],[https://github.com/facebook/infer/issues/])

AC_CONFIG_SRCDIR([infer/src/backend/sil.ml])
#AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_OBJC

AC_PROG_OCAML
AC_ASSERT_PROG([ocamlc], [$OCAMLC])
AC_ASSERT_PROG([ocamlopt], [$OCAMLOPT])
AC_ASSERT_PROG([ocamlbuild], [$OCAMLBUILD])
AC_PROG_FINDLIB
AC_ASSERT_PROG([findlib], [$FINDLIB])
AC_PROG_OCAMLLEX
AC_ASSERT_PROG([ocamllex], [$OCAMLLEX])
AC_PROG_OCAMLYACC
AC_ASSERT_PROG([ocamlyacc], [$OCAMLYACC])
AC_ASSERT_OCAML_PKG([atdgen], [], [1.6.0])
AC_ASSERT_OCAML_PKG([extlib], [], [1.5.4])
AC_ASSERT_OCAML_PKG([javalib], [], [2.3.1])
AC_ASSERT_OCAML_PKG([sawja], [], [1.5.1])
AC_ASSERT_OCAML_PKG([biniou])
AC_ASSERT_OCAML_PKG([camlzip], [zip])
AC_ASSERT_OCAML_PKG([easy-format])
AC_ASSERT_OCAML_PKG([ptrees])
AC_ASSERT_OCAML_PKG([yojson])

# Checks for header files.
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])

AC_OUTPUT
36 changes: 36 additions & 0 deletions m4/ac_assert_ocaml_pkg.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
dnl Copyright (c) 2015 - present Facebook, Inc.
dnl All rights reserved.
dnl
dnl This source code is licensed under the BSD style license found in the
dnl LICENSE file in the root directory of this source tree. An additional grant
dnl of patent rights can be found in the PATENTS file in the same directory.

dnl AC_ASSERT_OCAML_PKG([pkg_name], [pkg_version])
dnl
dnl fails if $pkg_name is not installed; also fails if it is not
dnl installed at version $pkg_version if specified
AC_DEFUN([AC_ASSERT_OCAML_PKG],
[dnl
AC_CHECK_OCAML_PKG_PATH([$1], [$2], [$3])
unset has_pkg
unset pkg
has_pkg=$AS_TR_SH[OCAML_PKG_$1]
AS_IF([test "$has_pkg" = "no"],
[dnl
unset version
unset version_msg
version=".$3"
AS_IF([test "x$3" = "x"], [version=""])
version_msg=""
AS_IF([test "x$3" != "x"], [version_msg=" version $3"])
AC_MSG_ERROR([missing dependency: $1$version_msg.
If you are using opam, please run
opam install $1$version])
])
])


18 changes: 18 additions & 0 deletions m4/ac_assert_prog.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
dnl Copyright (c) 2015 - present Facebook, Inc.
dnl All rights reserved.
dnl
dnl This source code is licensed under the BSD style license found in the
dnl LICENSE file in the root directory of this source tree. An additional grant
dnl of patent rights can be found in the PATENTS file in the same directory.

dnl AC_ASSERT_PROG([program_name], [test_variable])
dnl
dnl fails if $test_variable is "no", which is taken to mean that
dnl $program_name is not installed
AC_DEFUN([AC_ASSERT_PROG],
[dnl
AS_IF([test "$2" = "no"],
[dnl
AC_MSG_ERROR([$1 not found.])
])
])
45 changes: 45 additions & 0 deletions m4/ac_check_ocaml_pkg_path.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
dnl Copyright (c) 2015 - present Facebook, Inc.
dnl All rights reserved.
dnl
dnl This source code is licensed under the BSD style license found in the
dnl LICENSE file in the root directory of this source tree. An additional grant
dnl of patent rights can be found in the PATENTS file in the same directory.

dnl this adds the following features to AC_CHECK_OCAML_PKG:
dnl - supports an optional version argument in $3
dnl - sets OCAML_PKG_PATH_$1 to be the path where the package is
dnl installed
AC_DEFUN([AC_CHECK_OCAML_PKG_PATH],
[dnl
AC_REQUIRE([AC_PROG_FINDLIB])
AC_CHECK_OCAML_PKG([$1], [$2])
unset version_msg
version_msg=""
AS_IF([test "x$3" != "x"], [version_msg=" version $3"])
AC_MSG_CHECKING([for OCaml findlib package $1$version_msg])
unset path
unset pkg
unset version
pkg=$AS_TR_SH([OCAML_PKG_$1])
found=no
if test "x$pkg" != "xno"; then
path=`$OCAMLFIND query $pkg 2>/dev/null`
version=`$OCAMLFIND query -format '%v' $pkg 2>/dev/null`
if test "x$3" = "x" || test "x$version" = "x$3"; then
AC_MSG_RESULT([$path])
AS_TR_SH([OCAML_PKG_$1])=$pkg
AS_TR_SH([OCAML_PKG_PATH_$1])=$path
found=yes
fi
fi
if test "$found" = "no" ; then
AC_MSG_RESULT([not found])
AS_TR_SH([OCAML_PKG_$1])=no
fi
AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
AC_SUBST(AS_TR_SH([OCAML_PKG_PATH_$1]))
])
Loading

0 comments on commit 1e3085e

Please sign in to comment.