Sophie

Sophie

distrib > Fedora > 17 > i386 > by-pkgid > 675c8c8167236dfcf8d66da674f931e8 > files > 73

erlang-doc-R15B-03.3.fc17.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../otp_doc.css" type="text/css">
<title>Erlang -- Cross Compiling Erlang/OTP</title>
</head>
<body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<img alt="Erlang logo" src="../erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="../pdf/otp-system-documentation-5.9.3.1.pdf">PDF</a><br><a href="../index.html">Top</a></small><p><strong>Installation Guide</strong><br><strong>User's Guide</strong><br><small>Version 5.9.3.1</small></p>
<br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Chapters</strong></small></p>
<ul class="flipMenu" imagepath="../js/flipmenu">
<li id="no" title="Installing the Binary Release" expanded="false">Installing the Binary Release<ul>
<li><a href="install-binary.html">
              Top of chapter
            </a></li>
<li title="UNIX"><a href="install-binary.html#id60773">UNIX</a></li>
<li title="Windows"><a href="install-binary.html#id61148">Windows</a></li>
</ul>
</li>
<li id="no" title="Installation Verification" expanded="false">Installation Verification<ul>
<li><a href="verification.html">
              Top of chapter
            </a></li>
<li title="UNIX"><a href="verification.html#id56990">UNIX</a></li>
<li title="Windows"><a href="verification.html#id63124">Windows</a></li>
</ul>
</li>
<li id="no" title="Building and Installing Erlang/OTP" expanded="false">Building and Installing Erlang/OTP<ul>
<li><a href="INSTALL.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="INSTALL.html#id69303">Introduction</a></li>
<li title="Daily Build and Test"><a href="INSTALL.html#id69396">Daily Build and Test</a></li>
<li title="Versions Known NOT to Work"><a href="INSTALL.html#id61560">Versions Known NOT to Work</a></li>
<li title="Required Utilities"><a href="INSTALL.html#id62849">Required Utilities</a></li>
<li title="How to Build and Install Erlang/OTP"><a href="INSTALL.html#id57371">How to Build and Install Erlang/OTP</a></li>
<li title="The Erlang/OTP Documentation"><a href="INSTALL.html#id62172">The Erlang/OTP Documentation</a></li>
<li title="Support for SMP (Symmetric Multi Processing)"><a href="INSTALL.html#id62469">Support for SMP (Symmetric Multi Processing)</a></li>
<li title="GS (Graphic System)"><a href="INSTALL.html#id71231">GS (Graphic System)</a></li>
<li title="Using HiPE"><a href="INSTALL.html#id71248">Using HiPE</a></li>
<li title="Mac OS X (Darwin)"><a href="INSTALL.html#id71477">Mac OS X (Darwin)</a></li>
<li title="Building universal binaries on Mac OS X (obsolete information)"><a href="INSTALL.html#id71532">Building universal binaries on Mac OS X (obsolete information)</a></li>
<li title="Building a fast Erlang VM on Mac OS Lion"><a href="INSTALL.html#id71611">Building a fast Erlang VM on Mac OS Lion</a></li>
<li title="How to Build a Debug Enabled Erlang RunTime System"><a href="INSTALL.html#id71820">How to Build a Debug Enabled Erlang RunTime System</a></li>
<li title="Authors"><a href="INSTALL.html#id71932">Authors</a></li>
<li title="Copyright and License"><a href="INSTALL.html#id71959">Copyright and License</a></li>
<li title="More Information"><a href="INSTALL.html#id71987">More Information</a></li>
<li title="Modifying This Document"><a href="INSTALL.html#id72009">Modifying This Document</a></li>
</ul>
</li>
<li id="loadscrollpos" title="Cross Compiling Erlang/OTP" expanded="true">Cross Compiling Erlang/OTP<ul>
<li><a href="INSTALL-CROSS.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="INSTALL-CROSS.html#id72357">Introduction</a></li>
<li title="Build and Install Procedure"><a href="INSTALL-CROSS.html#id72668">Build and Install Procedure</a></li>
<li title="Testing the cross compiled system"><a href="INSTALL-CROSS.html#id73393">Testing the cross compiled system</a></li>
<li title="Currently Used Configuration Variables"><a href="INSTALL-CROSS.html#id73477">Currently Used Configuration Variables</a></li>
<li title="Copyright and License"><a href="INSTALL-CROSS.html#id74530">Copyright and License</a></li>
<li title="Modifying This Document"><a href="INSTALL-CROSS.html#id74558">Modifying This Document</a></li>
</ul>
</li>
<li id="no" title="How to Build Erlang/OTP on Windows" expanded="false">How to Build Erlang/OTP on Windows<ul>
<li><a href="INSTALL-WIN32.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="INSTALL-WIN32.html#id74741">Introduction</a></li>
<li title="Frequently Asked Questions"><a href="INSTALL-WIN32.html#id74848">Frequently Asked Questions</a></li>
<li title="Tools you Need and Their Environment"><a href="INSTALL-WIN32.html#id75221">Tools you Need and Their Environment</a></li>
<li title="The Shell Environment"><a href="INSTALL-WIN32.html#id75978">The Shell Environment</a></li>
<li title="Building and Installing"><a href="INSTALL-WIN32.html#id76124">Building and Installing</a></li>
<li title="Development"><a href="INSTALL-WIN32.html#id76424">Development</a></li>
<li title="Using GIT"><a href="INSTALL-WIN32.html#id76667">Using GIT</a></li>
<li title="Final Words"><a href="INSTALL-WIN32.html#id76701">Final Words</a></li>
<li title="Copyright and License"><a href="INSTALL-WIN32.html#id76738">Copyright and License</a></li>
<li title="Modifying This Document"><a href="INSTALL-WIN32.html#id76766">Modifying This Document</a></li>
</ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<h1>4 Cross Compiling Erlang/OTP</h1>

<p><strong>Table of Contents</strong></p>
  <ul>
<li>
      <span class="bold_code"><a href="#Introduction">Introduction</a></span>
    <ul>
<li>
        <span class="bold_code"><a href="#Introduction_otpbuild-Versus-configuremake">otp_build Versus configure/make</a></span>
      </li>
<li>
        <span class="bold_code"><a href="#Introduction_Cross-Configuration">Cross Configuration</a></span>
      </li>
<li>
        <span class="bold_code"><a href="#Introduction_What-can-be-Cross-Compiled">What can be Cross Compiled?</a></span>
      </li>
<li>
        <span class="bold_code"><a href="#Introduction_Compatibility">Compatibility</a></span>
      </li>
<li>
        <span class="bold_code"><a href="#Introduction_Patches">Patches</a></span>
    </li>
</ul>
    </li>
<li>
      <span class="bold_code"><a href="#Build-and-Install-Procedure">Build and Install Procedure</a></span>
    <ul>
<li>
        <span class="bold_code"><a href="#Build-and-Install-Procedure_Building-With-configuremake-Directly">Building With configure/make Directly</a></span>
      <ul>
<li>
          <span class="bold_code"><a href="#Build-and-Install-Procedure_Building-With-configuremake-Directly_Building-a-Bootstrap-System">Building a Bootstrap System</a></span>
        </li>
<li>
          <span class="bold_code"><a href="#Build-and-Install-Procedure_Building-With-configuremake-Directly_Cross-Building-the-System">Cross Building the System</a></span>
        </li>
<li>
          <span class="bold_code"><a href="#Build-and-Install-Procedure_Building-With-configuremake-Directly_Installing">Installing</a></span>
        <ul>
<li>
            <span class="bold_code"><a href="#Build-and-Install-Procedure_Building-With-configuremake-Directly_Installing_Installing-Using-Paths-Determined-by-configure">Installing Using Paths Determined by configure</a></span>
          </li>
<li>
            <span class="bold_code"><a href="#Build-and-Install-Procedure_Building-With-configuremake-Directly_Installing_Installing-Manually">Installing Manually</a></span>
        </li>
</ul>
      </li>
</ul>
      </li>
<li>
        <span class="bold_code"><a href="#Build-and-Install-Procedure_Building-With-the-otpbuild-Script">Building With the otp_build Script</a></span>
    </li>
</ul>
    </li>
<li>
      <span class="bold_code"><a href="#Testing-the-cross-compiled-system">Testing the cross compiled system</a></span>
    </li>
<li>
      <span class="bold_code"><a href="#Currently-Used-Configuration-Variables">Currently Used Configuration Variables</a></span>
    <ul>
<li>
        <span class="bold_code"><a href="#Currently-Used-Configuration-Variables_Variables-for-otpbuild-Only">Variables for otp_build Only</a></span>
      </li>
<li>
        <span class="bold_code"><a href="#Currently-Used-Configuration-Variables_Cross-Compiler-and-Other-Tools">Cross Compiler and Other Tools</a></span>
      <ul>
<li>
          <span class="bold_code"><a href="#Currently-Used-Configuration-Variables_Cross-Compiler-and-Other-Tools_Dynamic-Erlang-Driver-Linking">Dynamic Erlang Driver Linking</a></span>
        </li>
<li>
          <span class="bold_code"><a href="#Currently-Used-Configuration-Variables_Cross-Compiler-and-Other-Tools_Large-File-Support">Large File Support</a></span>
        </li>
<li>
          <span class="bold_code"><a href="#Currently-Used-Configuration-Variables_Cross-Compiler-and-Other-Tools_Other-Tools">Other Tools</a></span>
      </li>
</ul>
      </li>
<li>
        <span class="bold_code"><a href="#Currently-Used-Configuration-Variables_Cross-System-Root-Locations">Cross System Root Locations</a></span>
      </li>
<li>
        <span class="bold_code"><a href="#Currently-Used-Configuration-Variables_Optional-Feature-and-Bug-Tests">Optional Feature, and Bug Tests</a></span>
    </li>
</ul>
    </li>
<li>
      <span class="bold_code"><a href="#Copyright-and-License">Copyright and License</a></span>
    </li>
<li>
      <span class="bold_code"><a href="#Modifying-This-Document">Modifying This Document</a></span>
  </li>
</ul>

<a name="Introduction"></a>
<h3><a name="id72357">4.1 
        Introduction</a></h3>


<p>
This document describes how to cross compile Erlang/OTP-R15B03. Note that
the support for cross compiling Erlang/OTP should be considered as
experimental. As far as we know, the R15B03 release should cross compile
fine, but since we currently have a very limited set of cross compilation
environments to test with we cannot be sure. The cross compilation support
will remain in an experimental state until we get a lot more cross compilation
environments to test with.
</p>

<p>
You are advised to read the whole document before attempting to cross
compile Erlang/OTP. However, before reading this document, you should read
the <span class="bold_code"><a href="INSTALL.html">$ERL_TOP/INSTALL.md</a></span> document which describes building and installing
Erlang/OTP in general. <span class="code">$ERL_TOP</span> is the top directory in the source tree.
</p>

<a name="Introduction_otpbuild-Versus-configuremake"></a>
<h4>otp_build Versus configure/make</h4>


<p>
Building Erlang/OTP can be done either by using the <span class="code">$ERL_TOP/otp_build</span>
script, or by invoking <span class="code">$ERL_TOP/configure</span> and <span class="code">make</span> directly. Building using
<span class="code">otp_build</span> is easier since it involves fewer steps, but the <span class="code">otp_build</span> build
procedure is not as flexible as the <span class="code">configure</span>/<span class="code">make</span> build procedure. Note
that <span class="code">otp_build configure</span> will produce a default configuration that differs
from what <span class="code">configure</span> will produce by default. For example, currently
<span class="code">--disable-dynamic-ssl-lib</span> is added to the <span class="code">configure</span> command line arguments
unless <span class="code">--enable-dynamic-ssl-lib</span> has been explicitly passed. The binary
releases that we deliver are built using <span class="code">otp_build</span>.  The defaults used by
<span class="code">otp_build configure</span> may change at any time without prior notice.
</p>



<a name="Introduction_Cross-Configuration"></a>
<h4>Cross Configuration</h4>


<p>
The <span class="code">$ERL_TOP/xcomp/erl-xcomp.conf.template</span> file contains all available cross
configuration variables and can be used as a template when creating a cross
compilation configuration. All <span class="bold_code"><a href="#Currently-Used-Configuration-Variables">cross configuration variables</a></span> are also
listed at the end of this document. For examples of working cross
configurations see the <span class="code">$ERL_TOP/xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf</span>
file and the <span class="code">$ERL_TOP/xcomp/erl-xcomp-x86_64-saf-linux-gnu.conf</span> file. If the
default behavior of a variable is satisfactory, the variable does not need to
be set. However, the <span class="code">configure</span> script will issue a warning when a default
value is used. When a variable has been set, no warning will be issued.
</p>

<p>
A cross configuration file can be passed to <span class="code">otp_build configure</span> using the
<span class="code">--xcomp-conf</span> command line argument. Note that <span class="code">configure</span> does not accept
this command line argument. When using the <span class="code">configure</span> script directly, pass
the configuration variables as arguments to <span class="code">configure</span> using a
<span class="code">&lt;VARIABLE&gt;=&lt;VALUE&gt;</span> syntax. Variables can also be passed as environment
variables to <span class="code">configure</span>. However, if you pass the configuration in the
environment, make sure to unset all of these environment variables before
invoking <span class="code">make</span>; otherwise, the environment variables might set make variables
in some applications, or parts of some applications, and you may end up with
an erroneously configured build. 
</p>



<a name="Introduction_What-can-be-Cross-Compiled"></a>
<h4>What can be Cross Compiled?</h4>


<p>
All Erlang/OTP applications except the <span class="code">wx</span> application can be cross compiled.
The build of the <span class="code">wx</span> driver will currently be automatically disabled when
cross compiling.
</p>



<a name="Introduction_Compatibility"></a>
<h4>Compatibility</h4>


<p>
The build system, including cross compilation configuration variables used,
may be subject to non backward compatible changes without prior notice.
Current cross build system has been tested when cross compiling some Linux/GNU
systems, but has only been partly tested for more esoteric platforms. The
VxWorks example file is highly dependent on our environment and is here more
or less only for internal use.
</p>



<a name="Introduction_Patches"></a>
<h4>Patches</h4>


<p>
Please submit any patches for cross compiling in a way consistent with this
system. All input is welcome as we have a very limited set of cross compiling
environments to test with. If a new configuration variable is needed, add it
to <span class="code">$ERL_TOP/xcomp/erl-xcomp.conf.template</span>, and use it in <span class="code">configure.in</span>.
Other files that might need to be updated are:
</p>

<ul>
<li>
<span class="code">$ERL_TOP/xcomp/erl-xcomp-vars.sh</span>

</li>
<li>
<span class="code">$ERL_TOP/erl-build-tool-vars.sh</span>

</li>
<li>
<span class="code">$ERL_TOP/erts/aclocal.m4</span>

</li>
<li>
<span class="code">$ERL_TOP/xcomp/README.md</span>

</li>
<li>
<span class="code">$ERL_TOP/xcomp/erl-xcomp-*.conf</span>

</li>
</ul>
<p>
Note that this might be an incomplete list of files that need to be updated.
</p>

<p>
General information on how to submit patches can be found at:
  <span class="bold_code"><a href="http://wiki.github.com/erlang/otp/submitting-patches">http://wiki.github.com/erlang/otp/submitting-patches</a></span>
</p>





<a name="Build-and-Install-Procedure"></a>
<h3><a name="id72668">4.2 
        Build and Install Procedure</a></h3>


<p>
If you are building in Git, you want to read the <span class="bold_code"><a href="INSTALL.html#How-to-Build-and-Install-ErlangOTP_Building-in-Git">Building in Git</a></span> section
of <span class="bold_code"><a href="INSTALL.html">$ERL_TOP/INSTALL.md</a></span> before proceeding.
</p>

<p>
We will first go through the <span class="code">configure</span>/<span class="code">make</span> build procedure which people
probably are most familiar with.
</p>

<a name="Build-and-Install-Procedure_Building-With-configuremake-Directly"></a>
<h4>Building With configure/make Directly</h4>


<p>
  (1)
</p>

<p>
Change directory into the top directory of the Erlang/OTP source tree.
</p>

<div class="example"><pre>
$ cd $ERL_TOP
</pre></div>
<p>
In order to compile Erlang code, a small Erlang bootstrap system has to be
built, or an Erlang/OTP system of the same release as the one being built
has to be provided in the <span class="code">$PATH</span>. The Erlang/OTP for the target system will
be built using this Erlang system, together with the cross compilation tools
provided.
</p>

<p>
If you want to build the documentation out of the same source tree as you are
cross compiling in, you currently need a full Erlang/OTP system of the same
release as the one being built for the build machine. If this is the case,
build and install one for the build machine (or use one already built) and add
it to the <span class="code">$PATH</span> before cross building, and building the documentation. See
the <span class="bold_code"><a href="INSTALL.html#The-ErlangOTP-Documentation_How-to-Build-the-Documentation">How to Build the Documentation</a></span> section in the <span class="bold_code"><a href="INSTALL.html">$ERL_TOP/INSTALL.md</a></span>
document for information on how to build the documentation.
</p>

<p>
If you want to build using a compatible Erlang/OTP system in the <span class="code">$PATH</span>,
jump to (3).
</p>

<a name="Build-and-Install-Procedure_Building-With-configuremake-Directly_Building-a-Bootstrap-System"></a>
<p><strong>Building a Bootstrap System</strong></p>

<p>
  (2)
</p>

<div class="example"><pre>
$ ./configure --enable-bootstrap-only
$ make
</pre></div>
<p>
The <span class="code">--enable-bootstrap-only</span> argument to <span class="code">configure</span> isn't strictly necessary,
but will speed things up. It will only run <span class="code">configure</span> in applications
necessary for the bootstrap, and will disable a lot of things not needed by
the bootstrap system. If you run <span class="code">configure</span> without <span class="code">--enable-boostrap-only</span>
you also have to run make as <span class="code">make bootstrap</span>; otherwise, the whole system will
be built.
</p>

<a name="Build-and-Install-Procedure_Building-With-configuremake-Directly_Cross-Building-the-System"></a>
<p><strong>Cross Building the System</strong></p>

<p>
  (3)
</p>

<div class="example"><pre>
$ ./configure --host=&lt;HOST&gt; --build=&lt;BUILD&gt; [Other Config Args]
$ make
</pre></div>
<p>
<span class="code">&lt;HOST&gt;</span> is the host/target system that you build for. It does not have to be
a full <span class="code">CPU-VENDOR-OS</span> triplet, but can be. The full <span class="code">CPU-VENDOR-OS</span> triplet
will be created by executing <span class="code">$ERL_TOP/erts/autoconf/config.sub &lt;HOST&gt;</span>. If
<span class="code">config.sub</span> fails, you need to be more specific.
</p>

<p>
<span class="code">&lt;BUILD&gt;</span> should equal the <span class="code">CPU-VENDOR-OS</span> triplet of the system that you
build on. If you execute <span class="code">$ERL_TOP/erts/autoconf/config.guess</span>, it will in
most cases print the triplet you want to use for this.
</p>

<p>
Pass the cross compilation variables as command line arguments to <span class="code">configure</span>
using a <span class="code">&lt;VARIABLE&gt;=&lt;VALUE&gt;</span> syntax.
</p>

<div class="note">
<div class="label">Note</div>
<div class="content"><p>
<p>
You can <strong>not</strong> pass a configuration file using the <span class="code">--xcomp-conf</span>
 argument when you invoke <span class="code">configure</span> directly. The <span class="code">--xcomp-conf</span> argument
 can only be passed to <span class="code">otp_build configure</span>.
</p>
</p></div>
</div>

<p>
<span class="code">make</span> will verify that the Erlang/OTP system used when building is of the
same release as the system being built, and will fail if this is not the case.
It is possible, however not recommended, to force the cross compilation even
though the wrong Erlang/OTP system is used. This by invoking <span class="code">make</span> like this:
<span class="code">make ERL_XCOMP_FORCE_DIFFERENT_OTP=yes</span>.
</p>

<div class="warning">
<div class="label">Warning</div>
<div class="content"><p>
<p>
Invoking <span class="code">make ERL_XCOMP_FORCE_DIFFERENT_OTP=yes</span> might fail,
 silently produce suboptimal code, or silently produce erroneous code.
</p>
</p></div>
</div>

<a name="Build-and-Install-Procedure_Building-With-configuremake-Directly_Installing"></a>
<p><strong>Installing</strong></p>

<p>
You can either install using the installation paths determined by <span class="code">configure</span>
(4), or install manually using (5).
</p>

<a name="Build-and-Install-Procedure_Building-With-configuremake-Directly_Installing_Installing-Using-Paths-Determined-by-configure"></a>
<p><strong>Installing Using Paths Determined by configure</strong></p>

<p>
  (4)
</p>

<div class="example"><pre>
$ make install DESTDIR=&lt;TEMPORARY_PREFIX&gt;
</pre></div>
<p>
<span class="code">make install</span> will install at a location specified when doing <span class="code">configure</span>.
<span class="code">configure</span> arguments specifying where the installation should reside are for
example: <span class="code">--prefix</span>, <span class="code">--exec-prefix</span>, <span class="code">--libdir</span>, <span class="code">--bindir</span>, etc. By default
it will install under <span class="code">/usr/local</span>. You typically do not want to install your
cross build under <span class="code">/usr/local</span> on your build machine. Using <span class="bold_code"><a href="http://www.gnu.org/prep/standards/html_node/DESTDIR.html">DESTDIR</a></span>
will cause the installation paths to be prefixed by <span class="code">$DESTDIR</span>. This makes it
possible to install and package the installation on the build machine without
having to place the installation in the same directory on the build machine as
it should be executed from on the target machine.
</p>

<p>
When <span class="code">make install</span> has finished, change directory into <span class="code">$DESTDIR</span>, package
the system, move it to the target machine, and unpack it. Note that the
installation will only be working on the target machine at the location
determined by <span class="code">configure</span>.
</p>

<a name="Build-and-Install-Procedure_Building-With-configuremake-Directly_Installing_Installing-Manually"></a>
<p><strong>Installing Manually</strong></p>

<p>
  (5)
</p>

<div class="example"><pre>
$ make release RELEASE_ROOT=&lt;RELEASE_DIR&gt;
</pre></div>
<p>
<span class="code">make release</span> will copy what you have built for the target machine to
<span class="code">&lt;RELEASE_DIR&gt;</span>. The <span class="code">Install</span> script will not be run. The content of
<span class="code">&lt;RELEASE_DIR&gt;</span> is what by default ends up in <span class="code">/usr/local/lib/erlang</span>.
</p>

<p>
The <span class="code">Install</span> script used when installing Erlang/OTP requires common Unix
tools such as <span class="code">sed</span> to be present in your <span class="code">$PATH</span>. If your target system
does not have such tools, you need to run the <span class="code">Install</span> script on your
build machine before packaging Erlang/OTP. The <span class="code">Install</span> script should
currently be invoked as follows in the directory where it resides
(the top directory):
</p>

<div class="example"><pre>
$ ./Install [-cross] [-minimal|-sasl] &lt;ERL_ROOT&gt;
</pre></div>
<p>
where:
</p>

<ul>
<li>
<span class="code">-minimal</span> Creates an installation that starts up a minimal amount
of applications, i.e., only <span class="code">kernel</span> and <span class="code">stdlib</span> are started. The
minimal system is normally enough, and is what <span class="code">make install</span> uses.

</li>
<li>
<span class="code">-sasl</span> Creates an installation that also starts up the <span class="code">sasl</span>
application.

</li>
<li>
<span class="code">-cross</span> For cross compilation. Informs the install script that it
is run on the build machine.

</li>
<li>
<span class="code">&lt;ERL_ROOT&gt;</span> - The absolute path to the Erlang installation to use
at run time. This is often the same as the current working directory,
but does not have to be. It can follow any other path through the file
system to the same directory.

</li>
</ul>
<p>
If neither <span class="code">-minimal</span>, nor <span class="code">-sasl</span> is passed as argument you will be
prompted.
</p>

<p>
You can now either do:
</p>

<p>
  (6)
</p>

<ul><li>
<p>Decide where the installation should be located on the target machine,
run the <span class="code">Install</span> script on the build machine, and package the installed
installation. The installation just need to be unpacked at the right
location on the target machine:
</p>

<div class="example"><pre>
$ cd &lt;RELEASE_DIR&gt;
$ ./Install -cross [-minimal|-sasl] &lt;ABSOLUTE_INSTALL_DIR_ON_TARGET&gt;
</pre></div>
</li></ul>
<p>
or:
</p>

<p>
  (7)
</p>

<ul><li>
<p>Package the installation in <span class="code">&lt;RELEASE_DIR&gt;</span>, place it wherever you want
on your target machine, and run the <span class="code">Install</span> script on your target
machine:
</p>

<div class="example"><pre>
$ cd &lt;ABSOLUTE_INSTALL_DIR_ON_TARGET&gt;
$ ./Install [-minimal|-sasl] &lt;ABSOLUTE_INSTALL_DIR_ON_TARGET&gt;
</pre></div>
</li></ul>


<a name="Build-and-Install-Procedure_Building-With-the-otpbuild-Script"></a>
<h4>Building With the otp_build Script</h4>


<p>
  (8)
</p>

<div class="example"><pre>
$ cd $ERL_TOP
</pre></div>
<p>
  (9)
</p>

<div class="example"><pre>
$ ./otp_build configure --xcomp-conf=&lt;FILE&gt; [Other Config Args]
</pre></div>
<p>
alternatively:
</p>

<div class="example"><pre>
$ ./otp_build configure --host=&lt;HOST&gt; --build=&lt;BUILD&gt; [Other Config Args]
</pre></div>
<p>
If you have your cross compilation configuration in a file, pass it using the
<span class="code">--xcomp-conf=&lt;FILE&gt;</span> command line argument. If not, pass <span class="code">--host=&lt;HOST&gt;</span>,
<span class="code">--build=&lt;BUILD&gt;</span>, and the configuration variables using a <span class="code">&lt;VARIABLE&gt;=&lt;VALUE&gt;</span>
syntax on the command line  (same as in (3)). Note that <span class="code">&lt;HOST&gt;</span> and <span class="code">&lt;BUILD&gt;</span>
have to be passed one way or the other; either by using <span class="code">erl_xcomp_host=&lt;HOST&gt;</span>
and <span class="code">erl_xcomp_build=&lt;BUILD&gt;</span> in the configuration file, or by using the
<span class="code">--host=&lt;HOST&gt;</span>, and <span class="code">--build=&lt;BUILD&gt;</span> command line arguments.
</p>

<p>
<span class="code">otp_build configure</span> will configure both for the boostrap system on the
build machine and the cross host system.
</p>

<p>
  (10)
</p>

<div class="example"><pre>
$ ./otp_build boot -a
</pre></div>
<p>
<span class="code">otp_build boot -a</span> will first build a bootstrap system for the build machine
and then do the cross build of the system.
</p>

<p>
  (11)
</p>

<div class="example"><pre>
$ ./otp_build release -a &lt;RELEASE_DIR&gt;
</pre></div>
<p>
<span class="code">otp_build release -a</span> will do the same as (5), and you will after this have
to do a manual install either by doing (6), or (7).
</p>





<a name="Testing-the-cross-compiled-system"></a>
<h3><a name="id73393">4.3 
        Testing the cross compiled system</a></h3>

Some of the tests that come with erlang use native code to test. This means
that when cross compiling erlang you also have to cross compile test suites
in order to run tests on the target host. To do this you first have to release
the tests as usual.

<div class="example"><pre>
$ make release_tests
</pre></div>
<p>
or
</p>

<div class="example"><pre>
$ ./otp_build tests
</pre></div>
<p>
The tests will be released into <span class="code">$ERL_TOP/release/tests</span>. After releasing the
tests you have to install the tests on the build machine. You supply the same
xcomp file as to <span class="code">./otp_build</span> in (9).
</p>

<div class="example"><pre>
$ cd $ERL_TOP/release/tests/test_server/
$ $ERL_TOP/bootstrap/bin/erl -eval 'ts:install([{xcomp,"&lt;FILE&gt;"}])' -s ts compile_testcases -s init stop
</pre></div>
<p>
You should get a lot of printouts as the testcases are compiled. Once done you
should copy the entire <span class="code">$ERL_TOP/release/tests</span> folder to the cross host system.
</p>

<p>
Then go to the cross host system and setup the erlang installed in (4) or (5)
to be in your <span class="code">$PATH</span>. Then go to what previously was
<span class="code">$ERL_TOP/release/tests/test_server</span> and issue the following command.
</p>

<div class="example"><pre>
$ erl -s ts install -s ts run all_tests -s init stop
</pre></div>
<p>
The configure should be skipped and all tests should hopefully pass. For more
details about how to use ts run <span class="code">erl -s ts help -s init stop</span>
</p>



<a name="Currently-Used-Configuration-Variables"></a>
<h3><a name="id73477">4.4 
        Currently Used Configuration Variables</a></h3>


<p>
Note that you cannot define arbitrary variables in a cross compilation
configuration file. Only the ones listed below will be guaranteed to be
visible throughout the whole execution of all <span class="code">configure</span> scripts. Other
variables needs to be defined as arguments to <span class="code">configure</span> or exported in
the environment.
</p>

<a name="Currently-Used-Configuration-Variables_Variables-for-otpbuild-Only"></a>
<h4>Variables for otp_build Only</h4>


<p>
Variables in this section are only used, when configuring Erlang/OTP for
cross compilation using <span class="code">$ERL_TOP/otp_build configure</span>.
</p>

<div class="note">
<div class="label">Note</div>
<div class="content"><p>
<p>
These variables currently have <strong>no</strong> effect if you configure using
 the <span class="code">configure</span> script directly.
</p>
</p></div>
</div>

<ul>
<li>
<p><span class="code">erl_xcomp_build</span> - The build system used. This value will be passed as
<span class="code">--build=$erl_xcomp_build</span> argument to the <span class="code">configure</span> script. It does
not have to be a full <span class="code">CPU-VENDOR-OS</span> triplet, but can be. The full
<span class="code">CPU-VENDOR-OS</span> triplet will be created by
<span class="code">$ERL_TOP/erts/autoconf/config.sub $erl_xcomp_build</span>. If set to <span class="code">guess</span>,
the build system will be guessed using
<span class="code">$ERL_TOP/erts/autoconf/config.guess</span>.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_host</span> - Cross host/target system to build for. This value will
be passed as <span class="code">--host=$erl_xcomp_host</span> argument to the <span class="code">configure</span> script.
It does not have to be a full <span class="code">CPU-VENDOR-OS</span> triplet, but can be. The
full <span class="code">CPU-VENDOR-OS</span> triplet will be created by
<span class="code">$ERL_TOP/erts/autoconf/config.sub $erl_xcomp_host</span>.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_configure_flags</span> - Extra configure flags to pass to the
<span class="code">configure</span> script.
</p>
</li>
</ul>


<a name="Currently-Used-Configuration-Variables_Cross-Compiler-and-Other-Tools"></a>
<h4>Cross Compiler and Other Tools</h4>


<p>
If the cross compilation tools are prefixed by <span class="code">&lt;HOST&gt;-</span> you probably do
not need to set these variables (where <span class="code">&lt;HOST&gt;</span> is what has been passed as
<span class="code">--host=&lt;HOST&gt;</span> argument to <span class="code">configure</span>).
</p>

<p>
All variables in this section can also be used when native compiling.
</p>

<ul>
<li>
<p><span class="code">CC</span> - C compiler.
</p>

</li>
<li>
<p><span class="code">CFLAGS</span> - C compiler flags.
</p>

</li>
<li>
<p><span class="code">STATIC_CFLAGS</span> - Static C compiler flags.
</p>

</li>
<li>
<p><span class="code">CFLAG_RUNTIME_LIBRARY_PATH</span> - This flag should set runtime library
search path for the shared libraries. Note that this actually is a
linker flag, but it needs to be passed via the compiler.
</p>

</li>
<li>
<p><span class="code">CPP</span> - C pre-processor.
</p>

</li>
<li>
<p><span class="code">CPPFLAGS</span> - C pre-processor flags.
</p>

</li>
<li>
<p><span class="code">CXX</span> - C++ compiler.
</p>

</li>
<li>
<p><span class="code">CXXFLAGS</span> - C++ compiler flags.
</p>

</li>
<li>
<p><span class="code">LD</span> - Linker.
</p>

</li>
<li>
<p><span class="code">LDFLAGS</span> - Linker flags.
</p>

</li>
<li>
<p><span class="code">LIBS</span> - Libraries.
</p>
</li>
</ul>
<a name="Currently-Used-Configuration-Variables_Cross-Compiler-and-Other-Tools_Dynamic-Erlang-Driver-Linking"></a>
<p><strong>Dynamic Erlang Driver Linking</strong></p>

<div class="note">
<div class="label">Note</div>
<div class="content"><p>
<p>
Either set all or none of the <span class="code">DED_LD*</span> variables.
</p>
</p></div>
</div>

<ul>
<li>
<p><span class="code">DED_LD</span> - Linker for Dynamically loaded Erlang Drivers.
</p>

</li>
<li>
<p><span class="code">DED_LDFLAGS</span> - Linker flags to use with <span class="code">DED_LD</span>.
</p>

</li>
<li>
<p><span class="code">DED_LD_FLAG_RUNTIME_LIBRARY_PATH</span> - This flag should set runtime library
search path for shared libraries when linking with <span class="code">DED_LD</span>.
</p>
</li>
</ul>
<a name="Currently-Used-Configuration-Variables_Cross-Compiler-and-Other-Tools_Large-File-Support"></a>
<p><strong>Large File Support</strong></p>

<div class="note">
<div class="label">Note</div>
<div class="content"><p>
<p>
Either set all or none of the <span class="code">LFS_*</span> variables.
</p>
</p></div>
</div>

<ul>
<li>
<p><span class="code">LFS_CFLAGS</span> - Large file support C compiler flags.
</p>

</li>
<li>
<p><span class="code">LFS_LDFLAGS</span> - Large file support linker flags.
</p>

</li>
<li>
<p><span class="code">LFS_LIBS</span> - Large file support libraries.
</p>
</li>
</ul>
<a name="Currently-Used-Configuration-Variables_Cross-Compiler-and-Other-Tools_Other-Tools"></a>
<p><strong>Other Tools</strong></p>

<ul>
<li>
<p><span class="code">RANLIB</span> - <span class="code">ranlib</span> archive index tool.
</p>

</li>
<li>
<p><span class="code">AR</span> - <span class="code">ar</span> archiving tool.
</p>

</li>
<li>
<p><span class="code">GETCONF</span> - <span class="code">getconf</span> system configuration inspection tool. <span class="code">getconf</span> is
currently used for finding out large file support flags to use, and
on Linux systems for finding out if we have an NPTL thread library or
not.
</p>
</li>
</ul>


<a name="Currently-Used-Configuration-Variables_Cross-System-Root-Locations"></a>
<h4>Cross System Root Locations</h4>


<ul>
<li>
<p><span class="code">erl_xcomp_sysroot</span> - The absolute path to the system root of the cross
compilation environment. Currently, the <span class="code">crypto</span>, <span class="code">odbc</span>, <span class="code">ssh</span> and
<span class="code">ssl</span> applications need the system root. These applications will be
skipped if the system root has not been set. The system root might be
needed for other things too. If this is the case and the system root
has not been set, <span class="code">configure</span> will fail and request you to set it.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_isysroot</span> - The absolute path to the system root for includes
of the cross compilation environment. If not set, this value defaults
to <span class="code">$erl_xcomp_sysroot</span>, i.e., only set this value if the include system
root path is not the same as the system root path.
</p>
</li>
</ul>


<a name="Currently-Used-Configuration-Variables_Optional-Feature-and-Bug-Tests"></a>
<h4>Optional Feature, and Bug Tests</h4>


<p>
These tests cannot (always) be done automatically when cross compiling. You
usually do not need to set these variables.
</p>

<div class="warning">
<div class="label">Warning</div>
<div class="content"><p>
<p>
Setting these variables wrong may cause hard to detect
 runtime errors. If you need to change these values, <strong>really</strong> make sure
 that the values are correct.
</p>
</p></div>
</div>

<div class="note">
<div class="label">Note</div>
<div class="content"><p>
<p>
Some of these values will override results of tests performed
 by <span class="code">configure</span>, and some will not be used until <span class="code">configure</span> is sure that
 it cannot figure the result out.
</p>
</p></div>
</div>

<p>
The <span class="code">configure</span> script will issue a warning when a default value is used.
When a variable has been set, no warning will be issued.
</p>

<ul>
<li>
<p><span class="code">erl_xcomp_after_morecore_hook</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span>. If <span class="code">yes</span>,
the target system must have a working <span class="code">__after_morecore_hook</span> that can be
used for tracking used <span class="code">malloc()</span> implementations core memory usage.
This is currently only used by unsupported features.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_bigendian</span> - <span class="code">yes|no</span>. No default. If <span class="code">yes</span>, the target system
must be big endian. If <span class="code">no</span>, little endian. This can often be
automatically detected, but not always. If not automatically detected,
<span class="code">configure</span> will fail unless this variable is set. Since no default
value is used, <span class="code">configure</span> will try to figure this out automatically.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_double_middle</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span>. 
If <span class="code">yes</span>, the target system must have doubles in "middle-endian" format. If
<span class="code">no</span>, it has "regular" endianness. 
</p>

</li>
<li>
<p><span class="code">erl_xcomp_clock_gettime_cpu_time</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span>. If <span class="code">yes</span>,
the target system must have a working <span class="code">clock_gettime()</span> implementation
that can be used for retrieving process CPU time.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_getaddrinfo</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span>. If <span class="code">yes</span>, the target
system must have a working <span class="code">getaddrinfo()</span> implementation that can
handle both IPv4 and IPv6.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_gethrvtime_procfs_ioctl</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span>. If <span class="code">yes</span>,
the target system must have a working <span class="code">gethrvtime()</span> implementation and
is used with procfs <span class="code">ioctl()</span>.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_dlsym_brk_wrappers</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span>. If <span class="code">yes</span>, the
target system must have a working <span class="code">dlsym(RTLD_NEXT, &lt;S&gt;)</span> implementation
that can be used on <span class="code">brk</span> and <span class="code">sbrk</span> symbols used by the <span class="code">malloc()</span>
implementation in use, and by this track the <span class="code">malloc()</span> implementations
core memory usage. This is currently only used by unsupported features.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_kqueue</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span>. If <span class="code">yes</span>, the target
system must have a working <span class="code">kqueue()</span> implementation that returns a file
descriptor which can be used by <span class="code">poll()</span> and/or <span class="code">select()</span>. If <span class="code">no</span> and
the target system has not got <span class="code">epoll()</span> or <span class="code">/dev/poll</span>, the kernel-poll
feature will be disabled.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_linux_clock_gettime_correction</span> - <span class="code">yes|no</span>. Defaults to <span class="code">yes</span> on
Linux; otherwise, <span class="code">no</span>. If <span class="code">yes</span>, <span class="code">clock_gettime(CLOCK_MONOTONIC, _)</span> on
the target system must work. This variable is recommended to be set to
<span class="code">no</span> on Linux systems with kernel versions less than 2.6.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_linux_nptl</span> - <span class="code">yes|no</span>. Defaults to <span class="code">yes</span> on Linux; otherwise,
<span class="code">no</span>. If <span class="code">yes</span>, the target system must have NPTL (Native POSIX Thread
Library). Older Linux systems have LinuxThreads instead of NPTL (Linux
kernel versions typically less than 2.6).
</p>

</li>
<li>
<p><span class="code">erl_xcomp_linux_usable_sigaltstack</span> - <span class="code">yes|no</span>. Defaults to <span class="code">yes</span> on Linux;
otherwise, <span class="code">no</span>. If <span class="code">yes</span>, <span class="code">sigaltstack()</span> must be usable on the target
system. <span class="code">sigaltstack()</span> on Linux kernel versions less than 2.4 are
broken.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_linux_usable_sigusrx</span> - <span class="code">yes|no</span>. Defaults to <span class="code">yes</span>. If <span class="code">yes</span>,
the <span class="code">SIGUSR1</span> and <span class="code">SIGUSR2</span> signals must be usable by the ERTS. Old
LinuxThreads thread libraries (Linux kernel versions typically less than
2.2) used these signals and made them unusable by the ERTS.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_poll</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span> on Darwin/MacOSX; otherwise,
<span class="code">yes</span>. If <span class="code">yes</span>, the target system must have a working <span class="code">poll()</span>
implementation that also can handle devices. If <span class="code">no</span>, <span class="code">select()</span> will be
used instead of <span class="code">poll()</span>.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_putenv_copy</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span>. If <span class="code">yes</span>, the target
system must have a <span class="code">putenv()</span> implementation that stores a copy of the
key/value pair.
</p>

</li>
<li>
<p><span class="code">erl_xcomp_reliable_fpe</span> - <span class="code">yes|no</span>. Defaults to <span class="code">no</span>. If <span class="code">yes</span>, the target
system must have reliable floating point exceptions.
</p>
</li>
</ul>




<a name="Copyright-and-License"></a>
<h3><a name="id74530">4.5 
        Copyright and License</a></h3>


<p>
Copyright Ericsson AB 2009-2012. All Rights Reserved.
</p>

<p>
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/.
</p>

<p>
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.
</p>



<a name="Modifying-This-Document"></a>
<h3><a name="id74558">4.6 
        Modifying This Document</a></h3>


<p>
Before modifying this document you need to have a look at the
<span class="code">$ERL_TOP/README.md.txt</span> document.
</p>




</div>
<div class="footer">
<hr>
<p>Copyright © 1997-2012 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div></body>
</html>