In this section, we will see how to install OCaml using GODI, a package manager designed specifically to help OCaml programmers install, upgrade or uninstall applications, libraries and tools. While starting with GODI is not the easiest of tasks, using GODI is generally the best way of having a robust installation of OCaml and all the important tools.
This tutorial is meant for users of Linux, MacOS X, BSD and other variants of Unix. It could also be completed to work for Windows, but that's a new story altogether.
yoric@Blefuscu:~$ _
. Here, yoric
is my name and Blefuscu
is the name
of the computer I'm using. Depending on your name, the name of the computer you're using
and the configuration of your computer, you may see something different. However,
you will probably see the $
.
sudo apt-get install gcc m4 wget make gzip bzip2
and press <Enter>. Accept the various suggestions.
sudo yum install gcc m4 wget make gzip bzip2
and press <Enter>. Accept the various suggestions./tmp
is a good choice.
yoric@Blefuscu:~$ _
. Here, yoric
is my name and Blefuscu
is the name
of the computer I'm using. Depending on your name, the name of the computer you're using
and the configuration of your computer, you may see something different. However,
you will probably see the $
.
cd /tmp
-- if you have saved your
files to another directory than /tmp
, replace appropriately.
tar -zxf wget-1.11.tar.gz
cd wget-1.11/
./configure
yoric@Blefuscu:/tmp/wget-1.11$ ./configure
configure: configuring for GNU Wget 1.11
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
[ ...]
config.status: creating src/config.h
config.status: executing default commands
generating po/POTFILES from ./po/POTFILES.in
creating po/Makefile
yoric@Blefuscu:/tmp/wget-1.11$
Once you have reached that stage, write
make
This will instruct your computer to turn wget from
a source code (i.e. a description of what the computer
yoric@Blefuscu:/tmp/wget-1.11$ make
cd src && make CC='gcc' CPPFLAGS='' DEFS='-DHAVE_CONFIG_H -DSYSTEM_WGETRC=\"/usr/local/etc/wgetrc\" -DLOCALEDIR=\"/usr/local/share/locale\"' CFLAGS='-O2 -Wall' LDFLAGS='' LIBS='-ldl -lrt -lssl -lcrypto ' DESTDIR='' prefix='/usr/local' exec_prefix='/usr/local' bindir='/usr/local/bin' infodir='/usr/local/share/info' mandir='/usr/local/share/man' manext='1'
make[1]: Entering directory `/tmp/wget-1.11/src'
gcc -I. -I. -DHAVE_CONFIG_H -DSYSTEM_WGETRC=\"/usr/local/etc/wgetrc\" -DLOCALEDIR=\"/usr/local/share/locale\" -O2 -Wall -c cmpt.c
gcc -I. -I. -DHAVE_CONFIG_H -DSYSTEM_WGETRC=\"/usr/local/etc/wgetrc\" -DLOCALEDIR=\"/usr/local/share/locale\" -O2 -Wall -c connect.c
[...]
cd windows && make CC='gcc' CPPFLAGS='' DEFS='-DHAVE_CONFIG_H -DSYSTEM_WGETRC=\"/usr/local/etc/wgetrc\" -DLOCALEDIR=\"/usr/local/share/locale\"' CFLAGS='-O2 -Wall' LDFLAGS='' LIBS='-ldl -lrt -lssl -lcrypto ' DESTDIR='' prefix='/usr/local' exec_prefix='/usr/local' bindir='/usr/local/bin' infodir='/usr/local/share/info' mandir='/usr/local/share/man' manext='1'
make[1]: Entering directory `/tmp/wget-1.11/windows'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/tmp/wget-1.11/windows'
Once you have reached that stage, write
sudo make install
and enter your password when prompted. This will actually install wget
.
/tmp
is a good choice./tmp
is a good choice./tmp
.
yoric@Blefuscu:~$ _
. Here, yoric
is my name and Blefuscu
is the name
of the computer I'm using. Depending on your name, the name of the computer you're using
and the configuration of your computer, you may see something different. However,
you will probably see the $
.
cd /tmp
and press <Enter>.
If you have unpacked GODI in a directory other than /tmp
,
you should replace with the name of the directory you have chosen.
ls
This should display a list of everything in the directory in which you have unpacked
GODI. This may look like
yoric@Blefuscu:/tmp$ ls
acroread_1000_1000 gconfd-yoric keyring-2MSlZc orbit-yoric totem.yoric.3483895353
file8eok1j godi-rocketboost-20080630 mapping-yoric plugtmp virtual-yoric.AcfbLs
filemjfCnI godi-rocketboost-20080630.tar.gz ocaml797c01pipe ssh-MKJzlx5913
godi
and doesn .tar.gz
. The exact name will depend on when
you read this tutorial, as the numbers at the end represent the day the last version of GODI was published.
For the next few steps, we will assume that the name is godi-rocketboost-20080630
. This is the
name of the directory in which you may find the contents of the file you downloaded earlier, by the way.
cd godi-rocketboost-20080630/
and by the way, write ls
to check that you're in the correct directory.
You should see something along the lines of
yoric@Blefuscu:/tmp/godi-rocketboost-20080630$ ls
bootstrap bootstrap_stage2 cleanup godi-tools godi-tools-boot
README run
The files we're interested in are bootstrap
and bootstrap_stage2
, which
are both used to pursue the installation of GODI and OCaml.
~/usr/local
is a nice directory. For the rest of this tutorial, we'll assume that you have chosen these options.
Otherwise, write down the name of the directory you have elected, we'll need it later.
./bootstrap --section 3.11 --prefix ~/usr/local
You should see something along the lines of
*** Welcome to GODI, the O'Caml source distribution
*** RocketBoost bootstrap
GODI has been created by Gerd Stolpmann (mailto: gerd@gerd-stolpmann.de),
and is derived from the NetBSD pkgsrc system.
A number of packaging tools are now compiled and/or installed. Messages
are written to bootstrap.log.
Configuring make framework:
Looking up system commands...
/usr/bin/patch works fine
/usr/bin/patch can make backups with -V simple -b -z
/usr/bin/patch can remove empty files with -E
/usr/bin/patch can reject reverse patches with -N
/usr/bin/patch can be silent with -s
Selected release: 3.11
Installing into: /home/yoric/usr/local
Press [Return] to begin with the installation; press [CTRL-C] to abort.
===> Creating sample godi.conf
===> Building ocamlrun
===> Installing preliminary version of godi_console
===> Installing preliminary version of the make framework (godi-tools)
Bootstrap was successful!
Please remember to add
~/usr/local/bin
and
~/usr/local/sbin
to your PATH environment variable.
If necessary, please remember to add
~/usr/local/man
to your MANPATH environment variable.
An example godi.conf file has been created for you in the current
directory, and it has been installed in ~/usr/local/etc.
Selected GODI section: 3.11
(to change this, edit ~/usr/local/etc/godi.conf)
It is now recommended to start bootstrap_stage2 to download and
install a minimum set of packages. For more information, see the
file README.
yoric@Blefuscu:/tmp/godi-rocketboost-20080630$
~/.bashrc
. To edit it, write
gedit ~/.bashrc
or
kwrite ~/.bashrc
(gedit and kwrite are just two text editors, you may use another editor
if you prefer). If the file you see in your editor is empty, you have
a problem: your configuration has a different name, which I can't guess.
You may wish to try gedit ~/.tcshrc
or gedit ~/.zshrc
instead. Assuming that the file isn't empty, add the following two lines at the end:
export PATH=~/usr/local/bin:~/usr/local/sbin:$PATH
export MANPATH=~/usr/local/man:$MANPATH
You may save the file and quit your text editor.
These two lines instructs your computer to look for additional programs
in directories ~/usr/local/bin:~/usr/local/sbin
and for additional manual pages inside directory ~/usr/local/man
.
~/.bashrc
. Under older versions of MacOS X, it was
called ~/.tcshrc
. To open this file, write
open -a TextEdit .bashrc
if the file is empty, close TextEdit and try instead
open -a TextEdit .tcshrc
Once you have found the correct file, add the following two lines at the end:
export PATH=~/usr/local/bin:~/usr/local/sbin:$PATH
export MANPATH=~/usr/local/man:$MANPATH
You may save the file and quit your text editor.
These two lines instructs your computer to look for additional programs
in directories ~/usr/local/bin:~/usr/local/sbin
and for additional manual pages inside directory ~/usr/local/man
.
~/.bashrc
(if the file isn't called ~/.bashrc
, replace with ~/.tcshrc
or the name of the file).
./bootstrap_stage2
This will download and install a few OCaml-related programs on your computer.
The installation may last 10 minutes or more and present plenty of weird messages,
so don't worry -- and take a break.
godi_console
+--------------------------------------------+
| GODI Console |
+--------------------------------------------+
>>> Main Menu <<<
[1] Update the list of available packages
[2] Select source packages
[3] Exit program
+------------------------------------------------------ GODI Console ------------------------------------------------------+
>>> Select Source Packages <<<
FL NAME INSTALLED AVAILABLE COMMENT
==========Packages available as source code:================================================================================
[ 1] apps-aifad 1.0.27 A machine learning tool for structured data.
[ 2] apps-alt-ergo 0.8#1 Automated first-order theorem prover
[ 3] apps-batteries 0 Batteries Included: standard OCaml development platform.
[ 4] apps-bigbro 2.0.4#4 An http link checker.
[ 5] apps-camlmix 1.3.0 OCaml-stuffed templates
[ 6] apps-cduce 0.5.0#1 XML-oriented functional language
[ 7] apps-ceve 1.0.1 Parser for many package formats
[ 8] apps-cmigrep 1.2 1.2 module exploration utility
[ 9] apps-coq 8.1pl3#1 8.1pl4#2 Interactive proof assistant
[ 10] apps-ergo 0.7.3 DEPRECATED: ergo is now called alt-ergo. This package is only here to ease
[ 11] apps-felix 1.1.1#1 Felix Compiler
[ 12] apps-frama-c 20080701 Modular C static analyser
[ 13] apps-godiva 0.9.7 0.9.7 High-level tool for simplifying the creation of GODI packages.
[ 14] apps-headache 1.03 Tool for managing headers in source code files
[ 15] apps-hevea 1.10 1.10 Latex-to-HTML converter
[ 16] apps-ledit 1.16 1.16 Line editor wrapper
[ 17] apps-nurpawiki 1.2.2 Wiki + To-Do list
[ 18] apps-ocamldsort 0.14.3 Sort OCaml source files according to their dependencies
[ 19] apps-ocamlweb 1.36 literate programming tool for Objective Caml
[ 20] apps-ocsigen 1.1.0#1 Framework for web programming
[ 21] apps-pkglab 1.1 Distribution navigator
[ 22] apps-planets 0.1.12 Planet simulation
[ 23] apps-tart 1.0.1 Package distributor
[ 24] apps-tdir 1.1.1#4 Translation Directory
[ 25] apps-umlmon 1.0.5 A system monitor for User Mode Linux
[ 26] apps-umlmon-web 1.0.5 A system monitor for User Mode Linux
[ 27] apps-unison 2.27.57 File synchronizer
[ 28] apps-why 2.14 Verification condition generator for various systems
[ 29] apps-wyrd 1.4.1 Curses calendar app
[ 30] apps-zenon 0.5.0 "first-order automated theorem prover generating coq output"
[ 31] base-curl 7.14.0 The version of CURL for GODI
[ 32] base-expat 1.95.7#3 The version of expat for GODI
[ 33] base-gdbm 1.8.3#6 The GNU database manager
[ 34] base-pcre 7.7#1 The version of PCRE for GODI
[ 35] base-plan9-mk 1.6 The make utility from Plan9
[ 36] base-subversion-c$ 1.0.6 The subversion client allows direct access to GODI repositories
[ 37] conf-bdb 1 Configures which bdb library to use
[ 38] conf-curl 3 Configures which curl library to use
------------------------------------------------------------------------------------------------------------(more)----------
[p]rev [n]ext [u]pgrade all [s]tart/continue installation [h]elp e[x]it menu
As a start, we'll install Ledit, a small tool which is quite useful to program
in OCaml.
To install Ledit, you need to write the number corresponding to apps-ledit
and
press <Enter> -- on my example, it's 16,
but the exact number may depend on which programs are available in GODI when you
read this tutorial.
------------------ GODI Console --------------
>>> Single Package <<<
Package: apps-ledit
Status: Keep
Installed version: 1.16
Available version: 1.16 (from source)
Comment: Line editor wrapper
Description:
Ledit is a line editor, allowing to use control commands like in emacs
or in shells (bash, tcsh). To be used with interactive commands.
This package is dependent on:
- godi-ocaml>=3.10
- godi-camlp5>=5.07
GODI maintainer: Gerd Stolpmann <gerd@gerd-stolpmann.de>
-----------------------------------------------
[p]rev [n]ext [b]uild&install [r]emove [t]est configuration [h]elp e[x]it menu
To mark Ledit for installation, press <b>.
godi-batteries
and it's a few pages further into
the list of packages. On my computer, it's numbered 72 but, once again,
this may change. To navigate between pages, press <n> (to go to
the next page) or <p> (to go to the next page).
------------------ GODI Console --------------
>>> Installation <<<
GODI is going to
- remove 0 package(s)
- upgrade 0 package(s) from source
- build 10 package(s) from source
Press [ok] to execute this plan.
Important note: There are packages with configuration
options or build messages you might not yet have seen:
Package conf-zlib:
Options: GODI_ZLIB_INCDIR, GODI_ZLIB_LIBDIR
Build message:
The Zlib C library (version 1.1.3 or up) needs to be installed.
Available options for godi.conf:
- GODI_ZLIB_INCDIR: Where zlib.h can be found. Set this option
if the installed zlib library is not found.
- GODI_ZLIB_LIBDIR: Where libz can be found. Set this option
if the installed zlib library is not found.
To set options, exit this menu, select the packages
in question, and invoke their [c]onfigure menu.
-----------------------------------------------
[p]rev [n]ext [o]k [h]elp e[x]it menu
This menu informs you that there are configuration options,
which you could customize. Normally, you don't need to.