Skip to content

Build tips and tricks

Ivan Gotovchits edited this page May 1, 2015 · 27 revisions

Installing on a fresh Ubuntu or Mac OS X

First of all we need to install opam. To get the latest opam in Ubuntu do the following:

sudo add-apt-repository --yes ppa:avsm/ppa
sudo apt-get update
sudo apt-get --yes install opam

If you're using Mac OS X, First, get a working MacPorts up and working, the do the following:

sudo port install opam

Next we need to initialize opam and to install OCaml compiler (I suggest to answer yes, to all question, that opam may ask you):

opam init --comp=4.02.1
eval `opam config env`

And finally we can install bap and all its system dependencies

opam install depext
opam depext bap
opam install bap

Getting latest development version

With opam you can get the latest version from github, or any other source. This is called "pinning" in opam hackers jargon.

Word of caution: unless you're pretty sure about what you're doing, then please do pinning only after you've properly installed bap.

And here is the command:

opam pin add bap git://github.com/BinaryAnalysisPlatform/bap

The source URL can be anything, including local path, other repository. You can also specify particular branch with, e.g., to pin to a branch new_feature use: git://github.com/BinaryAnalysisPlatform/bap#new_feature

In order to remove pin and return to a released BAP, issue

opam pin remove bap

Using proper OPAM

Although we support older versions of opam, most of the instructions on this page silently assume opam 1.2. It that can be installed on Ubuntu with:

sudo add-apt-repository --yes ppa:avsm/ppa
sudo apt-get update
sudo apt-get --yes install opam

Macports install opam 1.2 by default.

What concerning opam 1.1, it still should work, but command line syntax is a little bit different.

Staying in sync

To update to the latest available to you version of BAP issue the following two commands:

opam update bap
opam upgrade

If you don't want to upgrade all your opam stack, then you can upgrade just bap,

opam upgrade bap

Installing system dependencies

On ubuntu and (maybe) other debian derivatives:

$ sudo apt-get install `opam install -eubuntu bap`

Compiling BAP from source tree

This is only needed if you're going to change BAP sources, it is not needed or recommended way of using BAP. You can always get the latest version with opam.

First of all, we need to install BAP dependencies. You can do this by following appropriate instructions above, but on the last stage, instead of opam install bap, use opam install bap --deps-only.

Once all the dependencies of bap have been installed, we can start the actual build. Now, run the following commands:

$ make
$ make install

This will run take care to run all configuration scripts for you. If you want to provide some specific flags to configure, then you need either to invoke it manually with ./configure or provide them to make using BAPCONFIGUREFLAGS environment variable.

Note: if you have chosen prefix that require super-user privileges, then you need to run make install using either sudo, e.g., sudo make install or switch to a super-user mode. Although it is not required, we suggest to install bap in to opam stack. In this case a proper prefix can be generated using opam config var command, e.g.,

./configure --prefix=$(opam config var prefix)

If you have installed bap previously, then use the command make reinstall instead of make install. However, this will not work if setup.log has been erased (by, for example, git clean -fdx or make clean). In that case, you can remove the old bap installation manually via the command ocamlfind remove bap.

Tips and Tricks

With the updated build system it is now possible to compile bap only with running make, so that if you're lucky Emacs user, then you need only hit C-c C-c et voila. But what if you would like to add some tricky configuration options. There're several possibilities to enumerate.

  • Use ./configure explicitly
  • Put all the needed stuff into your profile file, and forget about configuration:
export BAPCONFIGUREFLAGS="--prefix=`opam config var prefix` --enable-tests"
  • Use emacs setenv command to set BAPCONFIGUREFLAGS variable to anything you want
  • Invoke make with appropriate variables set, e.g., BAPCONFIGUREFLAGS --enable-tests make && make test

You can also hijack any other flags, like BAPBUILDFLAGS, see Makefile for a complete set of available environment variables and commands.

  • Any variable in setup.data can be overriden by environment.

Installing on other operating systems

We believe that BAP can be installed on any system with recent compiler toolchain. The hardiest problem is to install system dependencies. As a stating approximation, you can take a look at our system dependencies on Ubuntu 14.04, and extrapolate them to your system,

opam list --safe --recursive --external=ubuntu --required-by=bap

If you managed to install BAP on other system, please share your success story with us!

Clone this wiki locally