Skip to content

Build tips and tricks

Ivan Gotovchits edited this page Jan 18, 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.

Installing OCaml dependencies

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

$ opam install $(cat opam.deps)

If you are using a development version, e.g., you have just cloned this from github, then you will also need the oasis package in order to create a build environment.

$ opam install oasis

We also recommend you install utop for running BAP.

$ opam install utop

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 --enable-serialization"
  • 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.

Clone this wiki locally