4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta name="generator" content="AsciiDoc 8.6.9">
6 <title>Installation</title>
7 <link rel="stylesheet" href="./asciidoc.css" type="text/css">
8 <link rel="stylesheet" href="./pygments.css" type="text/css">
11 <script type="text/javascript" src="./asciidoc.js"></script>
12 <script type="text/javascript">
17 <link rel="stylesheet" href="./mlton.css" type="text/css">
19 <body class="article">
21 <div id="banner-home">
22 <a href="./Home">MLton 20180207</a>
30 <div class="sectionbody">
31 <div class="paragraph"><p>MLton runs on a variety of platforms and is distributed in both source and
32 binary form.</p></div>
33 <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
34 <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>,
35 <span class="monospaced">lib/</span>, and <span class="monospaced">share/</span>. The compiler and tools can be executed in-place (e.g.,
36 <span class="monospaced">./bin/mlton</span>).</p></div>
37 <div class="paragraph"><p>A small set of <span class="monospaced">Makefile</span> variables can be used to customize the binary package
38 via <span class="monospaced">make update</span>:</p></div>
39 <div class="ulist"><ul>
42 <span class="monospaced">CC</span>: Specify C compiler. Can be used for alternative tools (e.g.,
43 <span class="monospaced">CC=clang</span> or <span class="monospaced">CC=gcc-7</span>).
48 <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
49 and library paths, if not on default search paths. (If <span class="monospaced">WITH_GMP_DIR</span> is
50 set, then <span class="monospaced">WITH_GMP_INC_DIR</span> defaults to <span class="monospaced">$(WITH_GMP_DIR)/include</span> and
51 <span class="monospaced">WITH_GMP_LIB_DIR</span> defaults to <span class="monospaced">$(WITH_GMP_DIR)/lib</span>.)
55 <div class="paragraph"><p>For example:</p></div>
56 <div class="listingblock">
57 <div class="content"><div class="highlight"><pre><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>
58 </pre></div></div></div>
59 <div class="paragraph"><p>On typical platforms, installing MLton (after optionally performing
60 <span class="monospaced">make update</span>) to <span class="monospaced">/usr/local</span> can be accomplished via:</p></div>
61 <div class="listingblock">
62 <div class="content"><div class="highlight"><pre><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>
63 </pre></div></div></div>
64 <div class="paragraph"><p>A small set of <span class="monospaced">Makefile</span> variables can be used to customize the installation:</p></div>
65 <div class="ulist"><ul>
68 <span class="monospaced">PREFIX</span>: Specify the installation prefix.
73 <span class="monospaced">CC</span>: Specify C compiler. Can be used for alternative tools (e.g.,
74 <span class="monospaced">CC=clang</span> or <span class="monospaced">CC=gcc-7</span>).
79 <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
80 and library paths, if not on default search paths. (If <span class="monospaced">WITH_GMP_DIR</span> is
81 set, then <span class="monospaced">WITH_GMP_INC_DIR</span> defaults to <span class="monospaced">$(WITH_GMP_DIR)/include</span> and
82 <span class="monospaced">WITH_GMP_LIB_DIR</span> defaults to <span class="monospaced">$(WITH_GMP_DIR)/lib</span>.)
86 <div class="paragraph"><p>For example:</p></div>
87 <div class="listingblock">
88 <div class="content"><div class="highlight"><pre><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>
89 </pre></div></div></div>
90 <div class="paragraph"><p>Installation of MLton creates the following files and directories.</p></div>
91 <div class="ulist"><ul>
94 <span class="monospaced"><em>prefix</em>/bin/mllex</span>
96 <div class="paragraph"><p>The <a href="MLLex">MLLex</a> lexer generator.</p></div>
100 <span class="monospaced"><em>prefix</em>/bin/mlnlffigen</span>
102 <div class="paragraph"><p>The <a href="MLNLFFI">ML-NLFFI</a> tool.</p></div>
106 <span class="monospaced"><em>prefix</em>/bin/mlprof</span>
108 <div class="paragraph"><p>A <a href="Profiling">Profiling</a> tool.</p></div>
112 <span class="monospaced"><em>prefix</em>/bin/mlton</span>
114 <div class="paragraph"><p>A script to call the compiler. This script may be moved anywhere,
115 however, it makes use of files in <span class="monospaced"><em>prefix</em>/lib/mlton</span>.</p></div>
119 <span class="monospaced"><em>prefix</em>/bin/mlyacc</span>
121 <div class="paragraph"><p>The <a href="MLYacc">MLYacc</a> parser generator.</p></div>
125 <span class="monospaced"><em>prefix</em>/lib/mlton</span>
127 <div class="paragraph"><p>Directory containing libraries and include files needed during compilation.</p></div>
131 <span class="monospaced"><em>prefix</em>/share/man/man1/{mllex,mlnlffigen,mlprof,mlton,mlyacc}.1</span>
133 <div class="paragraph"><p>Man pages.</p></div>
137 <span class="monospaced"><em>prefix</em>/share/doc/mlton</span>
139 <div class="paragraph"><p>Directory containing the user guide for MLton, mllex, and mlyacc, as
140 well as example SML programs (in the <span class="monospaced">examples</span> directory), and license
141 information.</p></div>
147 <h2 id="_hello_world">Hello, World!</h2>
148 <div class="sectionbody">
149 <div class="paragraph"><p>Once you have installed MLton, create a file called <span class="monospaced">hello-world.sml</span>
150 with the following contents.</p></div>
151 <div class="listingblock">
152 <div class="content monospaced">
153 <pre>print "Hello, world!\n";</pre>
155 <div class="paragraph"><p>Now create an executable, <span class="monospaced">hello-world</span>, with the following command.</p></div>
156 <div class="listingblock">
157 <div class="content monospaced">
158 <pre>mlton hello-world.sml</pre>
160 <div class="paragraph"><p>You can now run <span class="monospaced">hello-world</span> to verify that it works. There are more
161 small examples in <span class="monospaced"><em>prefix</em>/share/doc/mlton/examples</span>.</p></div>
165 <h2 id="_installation_on_cygwin">Installation on Cygwin</h2>
166 <div class="sectionbody">
167 <div class="paragraph"><p>When installing the Cygwin <span class="monospaced">tgz</span>, you should use Cygwin’s <span class="monospaced">bash</span> and
168 <span class="monospaced">tar</span>. The use of an archiving tool that is not aware of Cygwin’s
169 mounts will put the files in the wrong place.</p></div>
173 <div id="footnotes"><hr></div>
175 <div id="footer-text">
177 <div id="footer-badges">