update build script and instructions

Summary:
public
Use the autotools now.

Closes #211

update-submodule: facebook-clang-plugins

Reviewed By: jeremydubreil

Differential Revision: D2734372

fb-gh-sync-id: e2baa30
master
Jules Villard 9 years ago committed by facebook-github-bot-5
parent 24d28c6858
commit 1e75ee6789

@ -22,7 +22,8 @@ is required to be able to [use the
release](http://fbinfer.com/docs/getting-started.html) (faster), or to
compile everything from source (see the end of this document).
- opam (instructions [here](https://opam.ocaml.org/doc/Install.html#OSX))
- autoconf >= 2.63 and automake >= 1.11.1
- opam >= 1.2.0 (instructions [here](https://opam.ocaml.org/doc/Install.html#OSX))
- Python 2.7
- Java (only needed for the Java analysis)
- clang in Xcode command line tools. You can install them with the command
@ -33,21 +34,8 @@ You can install some of these dependencies using
[Homebrew](http://brew.sh/):
```sh
brew install opam
```
Once you have all the dependencies above installed, configure opam as
follows:
```sh
opam init -y
eval $(opam config env)
opam update
opam install -y \
atdgen.1.6.0 \
extlib.1.5.4 \
javalib.2.3.1 \
sawja.1.5.1
brew install autoconf automake opam caskroom/cask/brew-cask && \
brew cask install caskroom/versions/java7
```
@ -58,21 +46,67 @@ is required to be able to [use the
release](http://fbinfer.com/docs/getting-started.html) (faster), or to
compile everything from source (see the end of this document).
- gcc >= 4.7.2
- opam
- autoconf >= 2.63 and automake >= 1.11.1
- gcc >= 4.7.2 or clang >= 3.1 (only needed for the C/Objective-C analysis)
- opam >= 1.2.0
- Python 2.7
- Java (only needed for the Java analysis)
### How to install the dependencies on Ubuntu 12.04.4 LTS
See also the distro-specific instructions for Ubuntu and Debian below.
## Install Infer from source
Run the following commands to get Infer up and running:
```sh
# Checkout Infer
git clone https://github.com/facebook/infer.git
cd infer
# Compile Infer
./build-infer.sh java
# Install Infer into your PATH
export PATH=`pwd`/infer/bin:$PATH
```
Replace `./build-infer.sh java` with `./build-infer.sh clang` to build
the C and Objective-C analyzer from source. Beware that this command
may take a really long time because it will compile a custom version
of clang. This custom version is used by Infer to parse C and
Objective-C source code. We encourage you to use [a
release](https://github.com/facebook/infer/releases/) instead, which
ship with clang already compiled.
See `./build-infer.sh --help` for more options, eg `./build-infer.sh`
on its own will build the analyzers for both Java and C/ObjC.
## Install Infer from source without opam
If for some reason you prefer to install Infer's OCaml dependencies by
some means other than opam, you can still compile Infer by running:
```sh
./autogen.sh
./configure
make # or make java
# Install Infer into your PATH
export PATH=`pwd`/infer/bin:$PATH
```
## How to install the dependencies on Linux
Here are instructions on how to install the dependencies needed to
compile Infer on a few Linux distributions.
### Debian 7 and Ubuntu 14.04 LTS
```sh
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y \
build-essential \
g++-4.8 \
gcc-4.8 \
git \
libgmp-dev \
libmpc-dev \
@ -82,18 +116,18 @@ sudo apt-get install -y \
python-software-properties \
unzip \
zlib1g-dev
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.8
```
### How to install the dependencies on Debian 7 / Ubuntu 14.04
### Ubuntu 12.04.4 LTS
```sh
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y \
build-essential \
g++-4.8 \
gcc-4.8 \
git \
libgmp-dev \
libmpc-dev \
@ -103,9 +137,12 @@ sudo apt-get install -y \
python-software-properties \
unzip \
zlib1g-dev
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 \
--slave /usr/bin/g++ g++ /usr/bin/g++-4.8
```
### Setting up Opam
### Setting up opam
Unfortunately, the version of opam that ships with some Linux
distributions is broken, so you'll have to get it from the web:
@ -117,61 +154,3 @@ chmod +x opam
Alternatively, follow the instructions [from the opam
webpage](https://opam.ocaml.org/doc/Install.html).
Once opam is installed, run the following commands:
```sh
./opam init -y
eval $(./opam config env)
./opam update
./opam install -y \
atdgen.1.6.0 \
extlib.1.5.4 \
javalib.2.3.1 \
sawja.1.5.1
```
## Compile Infer from source for the Java analysis
If you use Infer to analyze Java programs only, you can simple use
these steps to get Infer up and running:
```sh
# Checkout Infer
git clone https://github.com/facebook/infer.git
cd infer
# Compile Infer
./autogen.sh
./configure
make java
# Install Infer into your PATH
export PATH=`pwd`/infer/bin:$PATH
```
## Compile Infer from source with clang enabled
You do not need to follow the instructions below if you are using a
[release of Infer](http://fbinfer.com/docs/getting-started.html) or if
you only need to run Infer on Java programs.
Infer uses a special version of clang along with a clang
plugin. Follow these steps to compile them from source and install
Infer.
```sh
# Checkout Infer
git clone https://github.com/facebook/infer.git
cd infer
./autogen.sh
# Compile clang
facebook-clang-plugins/clang/setup.sh # go have a coffee :)
# Compile the clang plugin
./compile-fcp.sh
# Compile Infer
./configure
make
# Install Infer into your PATH
export PATH=`pwd`/infer/bin:$PATH
```

@ -1,5 +1,7 @@
#!/usr/bin/env bash
# Convenience script to build Infer when using opam
# Copyright (c) 2015 - present Facebook, Inc.
# All rights reserved.
#
@ -14,26 +16,28 @@ INFER_ROOT="$SCRIPT_DIR/../"
PLATFORM="$(uname)"
function usage() {
echo "Usage: $0 [targets]"
echo "Usage: $0 [-y] [targets]"
echo
echo " targets:"
echo " all build everything"
echo " clang build clang support (C/Objective-C)"
echo " java build Java support"
echo " all build everything (default)"
echo " clang build C and Objective-C analyzer"
echo " java build Java analyzer"
echo
echo " options:"
echo " -h,--help show this message"
echo " -y,--yes automatically agree to everything"
echo
echo " examples:"
echo " $0 all # build Java and C/Objective-C support"
echo " $0 # build Java and C/Objective-C analyzers"
echo " $0 java clang # equivalent way of doing the above"
echo " $0 java # build Java support only"
echo " $0 java # build only the Java analyzer"
}
if [[ $# == 0 ]]; then
usage
exit 1
fi
BUILD_JAVA=0
# arguments
BUILD_CLANG=0
BUILD_JAVA=0
INTERACTIVE=yes
while [[ $# > 0 ]]; do
opt_key="$1"
case $opt_key in
@ -57,6 +61,11 @@ while [[ $# > 0 ]]; do
usage
exit 0
;;
-y|--yes)
INTERACTIVE=no
shift
continue
;;
*)
usage
exit 1
@ -64,58 +73,90 @@ while [[ $# > 0 ]]; do
shift
done
# if no arguments then build both clang and Java
if [ "$BUILD_CLANG" = "0" ] && [ "$BUILD_JAVA" = "0" ]; then
BUILD_CLANG=1
BUILD_JAVA=1
fi
check_installed () {
local CMD=$1
if ! which $1 >/dev/null 2>&1; then
echo "dependency not found: $CMD"
exit 1
fi
}
# enable --yes option for some commands in non-interactive mode
YES=
if [ "$INTERACTIVE" = "no" ]; then
YES=--yes
fi
check_version () {
local CMD=$1
local VERSION=$2
if ! $1 2>&1 | grep -e "$VERSION" >/dev/null 2>&1; then
echo "version mismatch: the output of \"$CMD\" does not match \"$VERSION\""
check_installed () {
local cmd=$1
if ! which $cmd >/dev/null 2>&1; then
echo "dependency not found: $cmd"
exit 1
fi
}
set -x
echo "initializing opam... "
check_installed opam
opam switch 4.01.0 -y
opam install -y \
atdgen.1.6.0 \
extlib.1.5.4 \
javalib.2.3.1 \
sawja.1.5.1
# Java-specific dependencies
if [ "$BUILD_JAVA" == "1" ]; then
check_installed javac
check_version "javac -version" "\b1\.[78]"
fi
# opam is noisy
opam init --no-setup --yes > /dev/null
eval $(opam config env)
# OSX-specific dependencies
if [ "$PLATFORM" == "Darwin" ]; then
check_installed xcodebuild
check_version "xcodebuild -version" "\(\b6\.[1-9]\+\|\b7\.[0-9]\+\)"
echo "preparing build... "
if [ ! -f .release ]; then
./autogen.sh > /dev/null
elif [ ! -d .git ] && [ ! -f .release ]; then
git submodule update --init --recursive
fi
# prepare build targets
TARGETS=""
if [ "$BUILD_JAVA" = "1" ]; then
TARGETS+=" java"
fi
if [ "$BUILD_CLANG" = "1" ]; then
TARGETS+=" clang"
if [ ! -f ".release" ]; then
./facebook-clang-plugins/clang/setup.sh
if [ ! -f .release ]; then
if ! facebook-clang-plugins/clang/setup.sh --only-check-install; then
echo ""
echo " Warning: you are not using a release of Infer. The C and"
echo " Objective-C analyses require a custom clang to be compiled"
echo " now. This step takes ~30-60 minutes, possibly more."
echo ""
echo " To speed this along, you are encouraged to use a release of"
echo " Infer instead:"
echo ""
echo " http://fbinfer.com/docs/getting-started.html"
echo ""
echo " If you are only interested in analyzing Java programs, simply"
echo " run this script with only the \"java\" argument:"
echo ""
echo " $0 java"
echo ""
confirm="n"
printf "Are you sure you want to compile clang? (y/N) "
if [ "$INTERACTIVE" = "no" ]; then
confirm="y"
echo "$confirm"
else
read confirm
fi
if [ "x$confirm" != "xy" ]; then
exit 0
fi
./facebook-clang-plugins/clang/setup.sh
fi
./compile-fcp.sh
fi
fi
make -C infer clean $TARGETS
echo
echo " *************************"
echo " ** **"
echo " ** Building Infer **"
echo " ** **"
echo " *************************"
echo
./configure
make $TARGETS || (echo "compilation failure; try running `make clean`"; exit 1)

@ -1 +1 @@
Subproject commit 07c2aabb21fb201ac01b261095b665a53a00a9a1
Subproject commit 8133136d734be727f8f0951c5a42b166b60cb1cd

@ -22,9 +22,8 @@ AC_DEFUN([AC_ASSERT_OCAML_PKG],
If you are using opam, please run
\# create an "infer" opam package
opam pin add --no-action --yes -k path .
\# install dependencies
opam update
opam pin add --yes --no-action .
opam install --deps-only infer])
])
])

@ -35,14 +35,14 @@ AC_DEFUN([AC_CHECK_OCAML_PKG_PATH],
unset minor_inst
unset patch_inst
major_req=$(printf $3 | cut -d . -f 1)
minor_req=$(printf $3 | cut -d . -f 2)
patch_req=$(printf $3 | cut -d . -f 3)
major_req=$(printf "$3" | cut -d . -f 1)
minor_req=$(printf "$3" | cut -d . -f 2)
patch_req=$(printf "$3" | cut -d . -f 3)
major_inst=$(printf $version | cut -d . -f 1)
minor_inst=$(printf $version | cut -d . -f 2)
major_inst=$(printf "$version" | cut -d . -f 1)
minor_inst=$(printf "$version" | cut -d . -f 2)
# discard trailing characters after patch number, eg 1.2.3+4~5 -> 3
patch_inst=$(printf $version | cut -d . -f 3 | grep -o -e '^[[:digit:]]*')
patch_inst=$(printf "$version" | cut -d . -f 3 | grep -o -e '^[[[:digit:]]]*')
if test $major_inst -gt $major_req || \
(test $major_inst -eq $major_req && \
(test $minor_inst -gt $minor_req || \

Loading…
Cancel
Save