<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.10">
<title>Installation</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css">
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20201002</a>
</div>
</div>
<div id="header">
<h1>Installation</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p>MLton runs on a variety of platforms and is distributed in both source and
binary form.</p></div>
<div class="paragraph"><p>A <span class="monospaced">.tgz</span> or <span class="monospaced">.tbz</span> binary package can be extracted at any location, yielding
<span class="monospaced">README.adoc</span> (this file), <span class="monospaced">CHANGELOG.adoc</span>, <span class="monospaced">LICENSE</span>, <span class="monospaced">Makefile</span>, <span class="monospaced">bin/</span>,
<span class="monospaced">lib/</span>, and <span class="monospaced">share/</span>.  The compiler and tools can be executed in-place (e.g.,
<span class="monospaced">./bin/mlton</span>).</p></div>
<div class="paragraph"><p>A small set of <span class="monospaced">Makefile</span> variables can be used to customize the binary package
via <span class="monospaced">make update</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">CC</span>: Specify C compiler.  Can be used for alternative tools (e.g.,
   <span class="monospaced">CC=clang</span> or <span class="monospaced">CC=gcc-7</span>).
</p>
</li>
<li>
<p>
<span class="monospaced">WITH_GMP_DIR</span>, <span class="monospaced">WITH_GMP_INC_DIR</span>, <span class="monospaced">WITH_GMP_LIB_DIR</span>: Specify GMP include
   and library paths, if not on default search paths.  (If <span class="monospaced">WITH_GMP_DIR</span> is
   set, then <span class="monospaced">WITH_GMP_INC_DIR</span> defaults to <span class="monospaced">$(WITH_GMP_DIR)/include</span> and
   <span class="monospaced">WITH_GMP_LIB_DIR</span> defaults to <span class="monospaced">$(WITH_GMP_DIR)/lib</span>.)
</p>
</li>
</ul></div>
<div class="paragraph"><p>For example:</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="n">$</span><span class="w"> </span><span class="n">make</span><span class="w"> </span><span class="n">CC</span><span class="p">=</span><span class="n">clang</span><span class="w"> </span><span class="n">WITH_GMP_DIR=/opt/gmp</span><span class="w"> </span><span class="n">update</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>On typical platforms, installing MLton (after optionally performing
<span class="monospaced">make update</span>) to <span class="monospaced">/usr/local</span> can be accomplished via:</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="n">$</span><span class="w"> </span><span class="n">make</span><span class="w"> </span><span class="n">install</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>A small set of <span class="monospaced">Makefile</span> variables can be used to customize the installation:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">PREFIX</span>: Specify the installation prefix.
</p>
</li>
<li>
<p>
<span class="monospaced">CC</span>: Specify C compiler.  Can be used for alternative tools (e.g.,
   <span class="monospaced">CC=clang</span> or <span class="monospaced">CC=gcc-7</span>).
</p>
</li>
<li>
<p>
<span class="monospaced">WITH_GMP_DIR</span>, <span class="monospaced">WITH_GMP_INC_DIR</span>, <span class="monospaced">WITH_GMP_LIB_DIR</span>: Specify GMP include
   and library paths, if not on default search paths.  (If <span class="monospaced">WITH_GMP_DIR</span> is
   set, then <span class="monospaced">WITH_GMP_INC_DIR</span> defaults to <span class="monospaced">$(WITH_GMP_DIR)/include</span> and
   <span class="monospaced">WITH_GMP_LIB_DIR</span> defaults to <span class="monospaced">$(WITH_GMP_DIR)/lib</span>.)
</p>
</li>
</ul></div>
<div class="paragraph"><p>For example:</p></div>
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span></span><span class="n">$</span><span class="w"> </span><span class="n">make</span><span class="w"> </span><span class="n">PREFIX=/opt/mlton</span><span class="w"> </span><span class="n">install</span><span class="w"></span>
</pre></div></div></div>
<div class="paragraph"><p>Installation of MLton creates the following files and directories.</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced"><em>prefix</em>/bin/mllex</span>
</p>
<div class="paragraph"><p>The <a href="MLLex">MLLex</a> lexer generator.</p></div>
</li>
<li>
<p>
<span class="monospaced"><em>prefix</em>/bin/mlnlffigen</span>
</p>
<div class="paragraph"><p>The <a href="MLNLFFI">ML-NLFFI</a> tool.</p></div>
</li>
<li>
<p>
<span class="monospaced"><em>prefix</em>/bin/mlprof</span>
</p>
<div class="paragraph"><p>A <a href="Profiling">Profiling</a> tool.</p></div>
</li>
<li>
<p>
<span class="monospaced"><em>prefix</em>/bin/mlton</span>
</p>
<div class="paragraph"><p>A script to call the compiler.  This script may be moved anywhere,
however, it makes use of files in <span class="monospaced"><em>prefix</em>/lib/mlton</span>.</p></div>
</li>
<li>
<p>
<span class="monospaced"><em>prefix</em>/bin/mlyacc</span>
</p>
<div class="paragraph"><p>The <a href="MLYacc">MLYacc</a> parser generator.</p></div>
</li>
<li>
<p>
<span class="monospaced"><em>prefix</em>/lib/mlton</span>
</p>
<div class="paragraph"><p>Directory containing libraries and include files needed during compilation.</p></div>
</li>
<li>
<p>
<span class="monospaced"><em>prefix</em>/share/man/man1/{mllex,mlnlffigen,mlprof,mlton,mlyacc}.1</span>
</p>
<div class="paragraph"><p>Man pages.</p></div>
</li>
<li>
<p>
<span class="monospaced"><em>prefix</em>/share/doc/mlton</span>
</p>
<div class="paragraph"><p>Directory containing the user guide for MLton, mllex, and mlyacc, as
well as example SML programs (in the <span class="monospaced">examples</span> directory), and license
information.</p></div>
</li>
</ul></div>
</div>
</div>
<div class="sect1">
<h2 id="_hello_world">Hello, World!</h2>
<div class="sectionbody">
<div class="paragraph"><p>Once you have installed MLton, create a file called <span class="monospaced">hello-world.sml</span>
with the following contents.</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>print "Hello, world!\n";</pre>
</div></div>
<div class="paragraph"><p>Now create an executable, <span class="monospaced">hello-world</span>, with the following command.</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>mlton hello-world.sml</pre>
</div></div>
<div class="paragraph"><p>You can now run <span class="monospaced">hello-world</span> to verify that it works.  There are more
small examples in <span class="monospaced"><em>prefix</em>/share/doc/mlton/examples</span>.</p></div>
</div>
</div>
<div class="sect1">
<h2 id="_installation_on_cygwin">Installation on Cygwin</h2>
<div class="sectionbody">
<div class="paragraph"><p>When installing the Cygwin <span class="monospaced">tgz</span>, you should use Cygwin&#8217;s <span class="monospaced">bash</span> and
<span class="monospaced">tar</span>.  The use of an archiving tool that is not aware of Cygwin&#8217;s
mounts will put the files in the wrong place.</p></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
