In this chapter we will look at different way to configure and build Erlang/OTP to suite your needs. We will use an Ubuntu Linux for most of the examples. If you are using a different OS you can find detailed instructions on how to build for that OS in the documentation in the source code (in HOWTO/INSTALL.md), or on the web INSTALL.html.
There are basically two ways to build the runtime system, the traditional way with autoconf, configure and make or with the help of kerl.
I recommend that you first give the traditional way a try, that way you will get a better understanding of what happens when you build and what settings you can change. Then go over to using kerl for your day to day job of managing configurations and builds.
To get you started we will go though a step by step process of building the system from scratch and then we will look at how you can configure your system for different purposes.
This step by step guide assumes that you have a modern Ubuntu installation. We will look at how to build on OS X and Windows later in this chapter.
You will need a number of tools in order to fetch, unpack and
build from source. The file HOWTO/INSTALL.md
lists the most
important ones.
Given that we have a recent Ubuntu installation to start with some of the tools such as sed, tar, and perl should already be installed. But others like git, make, gcc, m4 and ncurses will probably need to be installed.
On a recent Ubuntu installation, the following command will get most of the tools you need:
> sudo apt-get install build-essential git autoconf m4 \
> zlib1g-dev ncurses-dev libssl-dev
If you want to build with support for wxWidgets you need to also install the wx libraries:
> sudo apt-get install libwxgtk3.2-dev wx3.2-i18n \
> wx3.2-examples wx3.2-doc
and optionally for WebView support in WX:
> sudo apt-get install libwxgtk-webview3.2-1t64
If you also want to be able to build the Erlang/OTP documentation, you’ll need some more tools:
> sudo apt-get install xsltproc libxml2-utils
There are two main ways of getting the source. You can download a tarball from erlang.org or you can check out the source code directly from Github.
If you want to quickly download a stable version of the source try:
> cd ~/otp
> wget http://erlang.org/download/otp_src_27.0.tar.gz
> tar -xzf otp_src_27.0.tar.gz
> cd otp_src_27.0
or if you want to be able to easily update to the latest bleeding edge or you want to contribute fixes back to the community you can check out the source through git:
> git clone https://github.com/erlang/otp.git
> cd otp
If you build an older version of Erlang you might need to run autoconf.
> ./otp_build autoconf
Now you are ready to build and install Erlang. To avoid interfering with any system wide installation, you’ll probably want to configure the installation prefix to be some directory private to you:
> ./configure --prefix=$HOME/.local
> make
> make install
> export PATH="$HOME/.local/bin:$PATH"
There are currently two main flavors of emulator builds: the JIT-enabled
flavor, jit
(which is the default on supported platforms), and the
non-JIT flavor emu
. You may also see the name smp
, but that is just an
alias meaning the default flavor on the current platform.
When you run make
, you can select the flavor as follows:
> make FLAVOR=emu
(Naturally, if you have configured with --disable-jit
, or your platform
does not support it, it will not be able to build the jit
flavor even if
you ask it to do so.)
You can also build differently instrumented variants of the emulator by
specifying a build type. At runtime, calling
erlang:system_info(build_type)
will tell you how the currently running
emulator was built. The standard build is called opt
.
To build one of the alternative emulator types, you need to set the TYPE
variable. You can combine this with the FLAVOR
variable.
> make
> make TYPE=debug
> make FLAVOR=emu TYPE=lcnt
Apart from debug
, there are several other instrumented variants that can
be built, for example valgrind
. To run these directly out of the build
tree (from the top directory of the source code), a special launch script
bin/cerl
can be used to start an instrumented emulator:
> bin/cerl -debug
The cerl
script also helps you with the additional output files created
when running for example a valgrind
-instrumented emulator. See
HOWTO/INSTALL.md
and HOWTO/DEVELOPMENT.md
for details.
If you want make install
to include these variant builds and not just the
default build, you will need to run it separately for each specific
combination:
> make install
> make install TYPE=debug
> make install FLAVOR=emu TYPE=lcnt
It will then be possible for a user to select the variant they want to run,
using the -emu_flavor
and -emu_type
flags:
> erl -emu_flavor emu -emu_type lcnt