Skip to content

Build tips and tricks

Ivan Gotovchits edited this page Apr 16, 2015 · 27 revisions

Introduction

This page is intended for BAP hackers, i.e., those who develop BAP library. If you want just to use BAP, and have problems with installation, then you should read a README file. If you still have problems, then use issue tracker to request the help.

TL;DR: To install the latest dev version, do:

eval `opam config env`
opam pin add bap git://github.com/BinaryAnalysisPlatform/bap
opam install bap.master

Installing on a fresh Ubuntu

Assuming Ubuntu, this is a way to install BAP via opam including all dependencies:

sudo add-apt-repository --yes ppa:avsm/ppa
sudo apt-get update
sudo apt-get --yes install opam
opam init --yes --comp=4.02.1
eval `opam config env`
opam pin add bap git://github.com/BinaryAnalysisPlatform/bap
sudo apt-get install --yes `opam install -eubuntu bap.master`
opam install --yes bap.master

Installing on a fresh OS X Yosemite system

First, get a working MacPorts up and working.

Then run:

sudo port install opam gmp llvm-3.4 graphviz
opam init --yes --comp=4.02.1
eval `opam config env`
opam pin add bap git://github.com/BinaryAnalysisPlatform/bap
opam install --yes bap.master

Note that graphviz and llvm-3.4 are optional, but recommended. Also note that we support only a few versions of LLVM, as their API keeps changing. Stick to the recommended LLVM until you become comfortable with the environment. If you want an updated LLVM, we are always happy to see a pull request that adds new versions.

Using proper OPAM

All instructions below assume opam 1.2 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, the only difference is that there is no aspcud for macports at the time of writting. So problems with constraint solver can be expected.

Staying in sync with master

You can pin bap package to the github version, essentially adding a small repository to OPAM:

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

You can pin to a specific version or tag, like feature_branch with

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

The commands above will automatically remove existing BAP if any and reinstall it with the pinned version (even if pinned version has lesser version number).

To keep staying in touch with the latest development, issue

opam update bap
opam upgrade bap

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

opam pin remove bap

Installing system dependencies

On ubuntu and (maybe) other debian derivatives:

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

Installing OCaml dependencies

The easiest way to install the OCaml dependencies of bap is to use the opam package manager:

$ opam install --deps-only bap

Compiling and installing bap

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.
Clone this wiki locally