Building and Installing Erlang/OTP

Please read the whole file before attempting to build and install Erlang/OTP. You can find more information about Open Source Erlang/OTP at:

http://www.erlang.org/

The source code for Erlang/OTP can also be found in a Git repository:

http://github.com/erlang/otp

Portability

Erlang/OTP should be possible to build from source on any Unix system, including Mac OS X. This document describes how to native compile Erlang/OTP on Unix. For detailed instructions on how to

However, you are in any case advised to read this document first, since it covers building Erlang/OTP in general as well as other important information.

Daily Build and Test

At Ericsson we have a "Daily Build and Test" that runs on:

We also have the following "Daily Cross Builds":

and the following "Daily Cross Build Tests":

Versions Known not to Work

Required Utilities

These are the tools you will need in order to unpack and build Erlang/OTP.

Unpacking

Building

If you are building in a Git working directory you also have to have a GNU autoconf of at least version 2.59. Autoconf is however not needed if you build an unmodified version of the released source.

Building Documentation

Installing

How to Build and Install Erlang/OTP

The following instructions are for building using the source tar ball.

The variable $ERL_TOP will be mentioned a lot of times. It refers to the top directory in the source tree. More information about $ERL_TOP can be found in the "make and $ERL_TOP" section below. If you are building in git you probably want to take a look at the "Building in Git" section below before proceeding.

Unpacking

Step 1: Start by unpacking the Erlang/OTP distribution file with your GNU compatible TAR program.

$ gunzip -c otp_src_R13B04.tar.gz | tar xf -
$ zcat otp_src_R13B04.tar.gz | tar xf -

Step 2: Now cd into the base directory ($ERL_TOP).

$ cd otp_src_R13B04

Configuring

Step 3: On some platforms Perl may behave strangely if certain locales are set, so optionally you may need to set the LANG variable:

# Bourne shell
$ LANG=C; export LANG

or

# C-Shell
$ setenv LANG C

Step 4: Run the following commands to configure the build:

$ ./configure  [ options ]

By default, Erlang/OTP will be installed in /usr/local/{bin,lib/erlang}. To instead install in <BaseDir>/{bin,lib/erlang}, use the --prefix=<BaseDir> option.

If you upgraded the source with some patch you may need to clean up from previous builds before the new build. Do a make clean; see "Caveats" below.

Building

Step 5: Build the Erlang/OTP package.

$ make

Installing

Step 6: Install then Erlang/OTP package

$ make install

A Closer Look at the individual Steps

Let us go through them in some detail.

Configuring

Step 4 runs a configuration script created by the GNU autoconf utility, which checks for system specific features and then creates a number of makefiles.

The configure script allows you to customize a number of parameters; type ./configure --help or ./configure --help=recursive for details. ./configure --help=recursive will give help for all configure scripts in all applications.

One of the things you can specify is where Erlang/OTP should be installed: by default Erlang/OTP will be installed in /usr/local/{bin,lib/erlang}; to keep the same structure but install in a different place, <Dir> say, use the --prefix argument like this: ./configure --prefix=<Dir>.

Some of the available configure options are:

If you or your system has special requirements please read the Makefile for additional configuration information.

Building

Step 5 builds the Erlang/OTP system. On a fast computer, this will take about 5 minutes. After completion of this step, you should have a working Erlang/OTP system which you can try by typing bin/erl. This should start up Erlang/OTP and give you a prompt.

Installing

Step 6 is optional. It installs Erlang/OTP at a standardized location (if you change your mind about where you wish to install you can rerun step 4, without having to do step 5 again).

Alternative Installation Procedures

Symbolic Links in --bindir

When doing make install and the default installation prefix is used, relative symbolic links will be created from /usr/local/bin to all public Erlang/OTP executables in /usr/local/lib/erlang/bin. The installation phase will try to create relative symbolic links as long as --bindir and the Erlang bin directory, located under --libdir, both have --exec-prefix as prefix. Where --exec-prefix defaults to --prefix. --prefix, --exec-prefix, --bindir, and --libdir are all arguments that can be passed to configure. One can force relative, or absolute links by passing BINDIR_SYMLINKS=relative|absolute as arguments to make during the install phase. Note that such a request might cause a failure if the request cannot be satisfied.

Building in Git

When building in a Git working directory you also have to have a GNU autoconf of at least version 2.59 on your system. This since you need to generate the configure scripts before you can start building.

The configure scripts are generated by invoking ./otp_build autoconf in the $ERL_TOP directory. The configure scripts also have to be regenerated when a configure.in or aclocal.m4 file has been modified. Note that when checking out a branch a configure.in or aclocal.m4 file may change content, and you may therefore have to regenerate the configure scripts when checking out a branch. Regenerated configure scripts imply that you have to run configure and build again.

Note that running ./otp_build autoconf is not needed when building an unmodified version the released source.

Other useful information can be found at our github wiki: http://wiki.github.com/erlang/otp

Pre-built Source Tree

The source tree is delivered with a lot of platform independent build results already pre-built. If you want to remove these pre-built files, invoke ./otp_build remove_prebuilt_files from the $ERL_TOP directory. After you have done this, you can build exactly the same way as before, but the build process will take a much longer time.

NOTE: Doing make clean in an arbitrary directory of the source tree, may remove files needed for bootstrapping the build. Doing ./otp_build save_bootstrap from the $ERL_TOP directory before doing make clean will ensure that it will be possible to build after doing make clean. ./otp_build save_bootstrap will be invoked automatically when make is invoked from $ERL_TOP with either the clean target, or the default target. It is also automatically invoked if ./otp_build remove_prebuilt_files is invoked.

make and $ERL_TOP

All the makefiles in the entire directory tree use the environment variable ERL_TOP to find the absolute path of the installation. The configure script will figure this out and set it in the top level Makefile (which, when building, it will pass on). However, when developing it is sometimes convenient to be able to run make in a subdirectory. To do this you must set the ERL_TOP variable before you run make.

For example, assume your GNU make program is called make and you want to rebuild the application STDLIB, then you could do:

$ cd lib/stdlib; env ERL_TOP=<Dir> make

where <Dir> would be what you find ERL_TOP is set to in the top level Makefile.

How to Build the Erlang/OTP Documentation

$ cd $ERL_TOP

If you have just built Erlang/OTP in the current source tree, you have already ran configure and do not need to do this again; otherwise, run configure.

$ ./configure [Configure Args]

When building the documentation you need a full Erlang/OTP-R13B04 system in the $PATH.

$ export PATH=<Erlang/OTP-R13B04 bin dir>:$PATH     # Assuming bash/sh

This document as well as some other documents have been written using Markdown notation. HTML versions of these documents are created and included in the HTML documentation if the environment variable MD2HTML is set to a command that generates HTML on stdout for a Markdown document passed as argument. This is a last minute hack, which will be handled in a better way in the future. We currently set MD2HTML as follows.

$ export MD2HTML="perl <path to script>/Markdown.pl --html4tags"

Build the documentation.

$ make docs

The documentation can be installed either using the install-docs target, or using the release_docs target.

Build Issues

We have sometimes experienced problems with suns java running out of memory when running fop. Increasing the amount of memory available as follows has in our case solved the problem.

$ export FOP_OPTS="-Xmx<Installed amount of RAM in MB>m"

More information can be found at http://xmlgraphics.apache.org/fop/0.95/running.html#memory.

How to Install the Pre-formatted Erlang/OTP Documentation

Pre-formatted documentation can be downloaded at http://www.erlang.org/download.html.

For some graphical tools to find the on-line help you have to install the HTML documentation on top of the installed OTP applications, i.e.

$ cd <ReleaseDir>
$ gunzip -c otp_html_R13B04.tar.gz | tar xf -

For erl -man <page> to work the Unix manual pages have to be installed in the same way, i.e.

$ cd <ReleaseDir>
$ gunzip -c otp_man_R13B04.tar.gz | tar xf -

Where <ReleaseDir> is

Support for SMP (Symmetric Multi Processing)

An emulator with SMP support will be built by default on most platforms if a usable POSIX thread library or native Windows threads is found.

You can force building of an SMP emulator, by using ./configure --enable-smp-support. However, if configure does not automatically enable SMP support, the build is very likely to fail.

Use ./configure --disable-smp-support if you for some reason do not want to have the emulator with SMP support built.

If SMP support is enabled, support for threaded I/O will also be turned on (also in the emulator without SMP support).

The erl command will automatically start the SMP emulator if the computer has more than one logical processor. You can force a start of the emulator with SMP support by passing -smp enable as command line arguments to erl, and you can force a start of the emulator without SMP support by passing -smp disable.

GS (Graphic System)

GS now Tcl/Tk 8.4. It will be searched for when starting GS.

Using HiPE

HiPE supports the following system configurations:

HiPE is automatically enabled on the following systems:

On other supported systems you need to ./configure --enable-hipe.

If you are running on a platform supporting HiPE and if you have not disabled HiPE, you can compile a module into native code like this from the Erlang shell:

1> c(Module, native).

or

1> c(Module, [native|OtherOptions]).

Using the erlc program, write like this:

$ erlc +native Module.erl

The native code will be placed into the beam file and automatically loaded when the beam file is loaded.

To add hipe options, write like this from the Erlang shell:

1> c(Module, [native,{hipe,HipeOptions}|MoreOptions]).

Use hipe:help_options/0 to print out the available options.

1> hipe:help_options().

Mac OS X (Darwin)

We test Mac OS X 10.4.11 (Tiger) and Mac OS X 10.5.x (Leopard) in our daily builds (but only on Intel processors).

Make sure that the command hostname returns a valid fully qualified host name (this is configured in /etc/hostconfig).

If you develop linked-in drivers (shared library) you need to link using gcc and the flags -bundle -flat_namespace -undefined suppress. You also include -fno-common in CFLAGS when compiling. Use .so as the library suffix.

Universal 32bit binaries can be built on an Intel Mac using the --enable-darwin-universal configure option. There still may occur problems with certain applications using this option, but the base system should run smoothly.

When building universal binaries on a PowerPC Mac (at least on Tiger), you must point out a suitable SDK that contains universal binaries. For instance, to build universal binaries for Tiger (10.4):

$ CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
LDFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
./configure --enable-darwin-universal

Also, if you run Leopard, but want to build for Tiger, you must do by setting the MACOSX_DEPLOYMENT_TARGET environmental variable.

$ export MACOSX_DEPLOYMENT_TARGET=10.4

Experimental support for 64bit x86 darwin binaries can be enabled using the --enable-darwin-64bit configure flag. The 64bit binaries are best built and run on Leopard, but most of the system also works on Tiger (Tiger's 64bit libraries are, however, limited; therefore e.g. odbc, crypto, ssl etc. are not supported in Tiger). 64bit PPC binaries are not supported and we have no plans to add such support (no machines to test on).

Universal binaries and 64bit binaries are mutually exclusive options.

How to Build a Debug Enabled Erlang RunTime System

After completing all the normal building steps described above a debug enabled runtime system can be built. To do this you have to change directory to $ERL_TOP/erts/emulator.

In this directory execute:

$ make debug FLAVOR=$FLAVOR

where $FLAVOR is either plain or smp. The flavor options will produce a beam.debug and beam.smp.debug executable respectively. The files are installed along side with the normal (opt) versions beam.smp and beam.

To start the debug enabled runtime system execute:

$ $ERL_TOP/bin/cerl -debug

The debug enabled runtime system features lock violation checking, assert checking and various sanity checks to help a developer ensure correctness. Some of these features can be enabled on a normal beam using appropriate configure options.

There are other types of runtime systems that can be built as well using the similar steps just described.

$ make $TYPE FLAVOR=$FLAVOR

where $TYPE is opt, gcov, gprof, debug, valgrind, or lcnt. These different beam types are useful for debugging and profiling purposes.

Authors

Authors are mostly listed in the application's AUTHORS files, that is $ERL_TOP/lib/*/AUTHORS and $ERL_TOP/erts/AUTHORS, not in the individual source files.

Copyright and License

%CopyrightBegin%

Copyright Ericsson AB 1998-2010. All Rights Reserved.

The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/.

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

%CopyrightEnd%

More Information

More information can be found at http://www.erlang.org.