| 1 |
= Installation |
| 2 |
|
| 3 |
MLton runs on a variety of platforms and is distributed in both source and |
| 4 |
binary form. |
| 5 |
|
| 6 |
A `.tgz` or `.tbz` binary package can be extracted at any location, yielding |
| 7 |
`README.adoc` (this file), `CHANGELOG.adoc`, `LICENSE`, `Makefile`, `bin/`, |
| 8 |
`lib/`, and `share/`. The compiler and tools can be executed in-place (e.g., |
| 9 |
`./bin/mlton`). |
| 10 |
|
| 11 |
A small set of `Makefile` variables can be used to customize the binary package |
| 12 |
via `make update`: |
| 13 |
|
| 14 |
* `CC`: Specify C compiler. Can be used for alternative tools (e.g., |
| 15 |
`CC=clang` or `CC=gcc-7`). |
| 16 |
* `WITH_GMP_DIR`, `WITH_GMP_INC_DIR`, `WITH_GMP_LIB_DIR`: Specify GMP include |
| 17 |
and library paths, if not on default search paths. (If `WITH_GMP_DIR` is |
| 18 |
set, then `WITH_GMP_INC_DIR` defaults to `$(WITH_GMP_DIR)/include` and |
| 19 |
`WITH_GMP_LIB_DIR` defaults to `$(WITH_GMP_DIR)/lib`.) |
| 20 |
|
| 21 |
For example: |
| 22 |
|
| 23 |
[source,sml] |
| 24 |
---- |
| 25 |
$ make CC=clang WITH_GMP_DIR=/opt/gmp update |
| 26 |
---- |
| 27 |
|
| 28 |
On typical platforms, installing MLton (after optionally performing |
| 29 |
`make update`) to `/usr/local` can be accomplished via: |
| 30 |
|
| 31 |
[source,sml] |
| 32 |
---- |
| 33 |
$ make install |
| 34 |
---- |
| 35 |
|
| 36 |
A small set of `Makefile` variables can be used to customize the installation: |
| 37 |
|
| 38 |
* `PREFIX`: Specify the installation prefix. |
| 39 |
* `CC`: Specify C compiler. Can be used for alternative tools (e.g., |
| 40 |
`CC=clang` or `CC=gcc-7`). |
| 41 |
* `WITH_GMP_DIR`, `WITH_GMP_INC_DIR`, `WITH_GMP_LIB_DIR`: Specify GMP include |
| 42 |
and library paths, if not on default search paths. (If `WITH_GMP_DIR` is |
| 43 |
set, then `WITH_GMP_INC_DIR` defaults to `$(WITH_GMP_DIR)/include` and |
| 44 |
`WITH_GMP_LIB_DIR` defaults to `$(WITH_GMP_DIR)/lib`.) |
| 45 |
|
| 46 |
For example: |
| 47 |
|
| 48 |
[source,sml] |
| 49 |
---- |
| 50 |
$ make PREFIX=/opt/mlton install |
| 51 |
---- |
| 52 |
|
| 53 |
Installation of MLton creates the following files and directories. |
| 54 |
|
| 55 |
* ``__prefix__/bin/mllex`` |
| 56 |
+ |
| 57 |
The <<MLLex#>> lexer generator. |
| 58 |
|
| 59 |
* ``__prefix__/bin/mlnlffigen`` |
| 60 |
+ |
| 61 |
The <<MLNLFFI#,ML-NLFFI>> tool. |
| 62 |
|
| 63 |
* ``__prefix__/bin/mlprof`` |
| 64 |
+ |
| 65 |
A <<Profiling#>> tool. |
| 66 |
|
| 67 |
* ``__prefix__/bin/mlton`` |
| 68 |
+ |
| 69 |
A script to call the compiler. This script may be moved anywhere, |
| 70 |
however, it makes use of files in ``__prefix__/lib/mlton``. |
| 71 |
|
| 72 |
* ``__prefix__/bin/mlyacc`` |
| 73 |
+ |
| 74 |
The <<MLYacc#>> parser generator. |
| 75 |
|
| 76 |
* ``__prefix__/lib/mlton`` |
| 77 |
+ |
| 78 |
Directory containing libraries and include files needed during compilation. |
| 79 |
|
| 80 |
* ``__prefix__/share/man/man1/{mllex,mlnlffigen,mlprof,mlton,mlyacc}.1`` |
| 81 |
+ |
| 82 |
Man pages. |
| 83 |
|
| 84 |
* ``__prefix__/share/doc/mlton`` |
| 85 |
+ |
| 86 |
Directory containing the user guide for MLton, mllex, and mlyacc, as |
| 87 |
well as example SML programs (in the `examples` directory), and license |
| 88 |
information. |
| 89 |
|
| 90 |
|
| 91 |
== Hello, World! |
| 92 |
|
| 93 |
Once you have installed MLton, create a file called `hello-world.sml` |
| 94 |
with the following contents. |
| 95 |
|
| 96 |
---- |
| 97 |
print "Hello, world!\n"; |
| 98 |
---- |
| 99 |
|
| 100 |
Now create an executable, `hello-world`, with the following command. |
| 101 |
---- |
| 102 |
mlton hello-world.sml |
| 103 |
---- |
| 104 |
|
| 105 |
You can now run `hello-world` to verify that it works. There are more |
| 106 |
small examples in ``__prefix__/share/doc/mlton/examples``. |
| 107 |
|
| 108 |
|
| 109 |
== Installation on Cygwin |
| 110 |
|
| 111 |
When installing the Cygwin `tgz`, you should use Cygwin's `bash` and |
| 112 |
`tar`. The use of an archiving tool that is not aware of Cygwin's |
| 113 |
mounts will put the files in the wrong place. |