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"
You can build differently instrumented variants of the Beam emulator.
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 use the
makefile in the erts/emulator
subdirectory directly:
> export ERL_TOP=`pwd`
> (cd $ERL_TOP/erts/emulator && make debug)
A special launch script $ERL_TOP/bin/cerl
should be used to start an
instrumented emulator:
> $ERL_TOP/bin/cerl -debug
There are several such instrumented variants that can be built, for example
valgrind
. See HOWTO/INSTALL.md
for details.