summaryrefslogtreecommitdiff
path: root/INSTALL
blob: e52603fe9fd82b8749148a1283cd9d40944fb277 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
PREREQUISITES

* The GNU C compiler gcc is recommended, as the bytecode
  interpreter takes advantage of gcc-specific features to enhance
  performance. Versions 2.5.8, 2.6.3, 2.7.0 and 2.7.2 have all been
  tested at some point and appear to work. 2.7.2.1 has known problems,
  at least under Linux; use some other version.

* Under HP/UX, gcc, the GNU binutils, and GNU make are all required.
  The native cc, as, and make have major problems.


INSTALLATION INSTRUCTIONS

1- Configure the system. From the top directory, do:

        ./configure

This generates the three configuration files "Makefile", "m.h" and "s.h"
in the config/ subdirectory.

The "configure" script accepts the following options:

-bindir <dir>                   (default: /usr/local/bin)
        Directory where the binaries will be installed

-libdir <dir>                   (default: /usr/local/lib/ocaml)
        Directory where the Caml library will be installed

-mandir <dir>                   (default: /usr/local/man/man1)
        Directory where the manual pages will be installed

-cc <C compiler and options>    (default: gcc or cc, depending on availability)
        C compiler to use for building the system

-libs <extra libraries>         (default: none)
        Extra libraries to link with the system

-host <hosttype>                (default: determined automatically)
        The type of the host machine, in GNU's "configuration name"
        format (CPU-COMPANY-SYSTEM). This info is generally determined
        automatically by the "configure" script, and rarely ever
        needs to be provided by hand. The installation instructions
        for gcc or emacs contain a complete list of configuration names.

-x11include <include_dir>       (default: determined automatically)
-x11lib     <lib_dir>           (default: determined automatically)
        Location of the X11 include directory (e.g. /usr/X11R6/include)
        and the X11 library directory (e.g. /usr/X11R6/lib).

Examples:
    ./configure -bindir /usr/bin -libdir /usr/lib/ocaml -mandir /usr/man/manl
    ./configure -cc "acc -fast" -libs "-lucb"

If something goes wrong during the automatic configuration, or if the
generated files cause errors later on, then look at the template files

        config/Makefile-templ
        config/m-templ.h
        config/s-templ.h

for guidance on how to edit the generated files by hand.

2- From the top directory, do:

        make world

This builds the Objective Caml bytecode compiler for the first time.
This phase is fairly verbose; consider redirecting the output to a file:

        make world > log.world 2>&1     # in sh
        make world >& log.world         # in csh

3- To be sure everything works well, you can try to bootstrap the
system --- that is, to recompile all Objective Caml sources with
the newly created compiler. From the top directory, do:

        make bootstrap

or, better:

        make bootstrap > log.bootstrap 2>&1     # in sh
        make bootstrap >& log.bootstrap         # in csh

The "make bootstrap" checks that the bytecode programs compiled with
the new compiler are identical to the bytecode programs compiled with
the old compiler. If this is the case, you can be pretty sure the
system has been correctly compiled. Otherwise, this does not
necessarily mean something went wrong. The best thing to do is to try
a second bootstrapping phase: just do "make bootstrap" again.  It will
either crash almost immediately, or re-re-compile everything correctly
and reach the fixpoint.

4- If your platform is supported by the native-code compiler (as
reported during the autoconfiguration), you can now build the
native-code compiler. From the top directory, do:

        make opt
or:
        make opt > log.opt 2>&1     # in sh
        make opt >& log.opt         # in csh

5- You can now install the Objective Caml system. This will create the
following commands (in the binary directory selected during autoconfiguration):

        ocamlc           the batch bytecode compiler
        ocamlopt         the batch native-code compiler (if supported)
        ocamlrun         the runtime system for the bytecode compiler
        ocamlyacc        the parser generator
        ocamllex         the lexer generator
        ocaml            the interactive, toplevel-based system
        ocamlmktop       a tool to make toplevel systems that integrate
                         user-defined C primitives and Caml code
        ocamldebug       the source-level replay debugger
        ocamldep         output "make" dependencies for Caml sources
        ocamlprof        execution count profiler
        ocamlcp          the bytecode compiler in profiling mode

From the top directory, become superuser and do:

        umask 022       # make sure to give read & execute permission to all
        make install

6- Installation is complete. Time to clean up. From the toplevel
directory, do "make clean".

7- The emacs/ subdirectory contains Emacs-Lisp files for an Objective Caml
editing mode and an interface for the debugger.  To install these
files, change to the emacs/ subdirectory and do

        make DEST=<directory where to install the files> install
or
        make install

In the latter case, the destination directory defaults to the
"site-lisp" directory of your Emacs installation.


IF SOMETHING GOES WRONG:

Read the "common problems" and "machine-specific hints" section at the
end of this file.

Check the files m.h and s.h in config/. Wrong endianness or alignment
constraints in m.h will immediately crash the bytecode interpreter.

If you get a "segmentation violation" signal, check the limits on the
stack size and data segment size (type "limit" under csh or
"ulimit -a" under bash). Make sure the limit on the stack size is
at least 2M.

Try recompiling the runtime system with optimizations turned off
(change CFLAGS in byterun/Makefile and asmrun/Makefile).
The runtime system contains some complex, atypical pieces of C code
that can uncover bugs in optimizing compilers. Alternatively, try
another C compiler (e.g. gcc instead of the vendor-supplied cc).

You can also build a debug version of the runtime system. Go to the
byterun/ directory and do "make ocamlrund". Then, copy ocamlrund to
../boot/ocamlrun, and try again. This version of the runtime system
contains lots of assertions and sanity checks that could help you
pinpoint the problem.


COMMON PROBLEMS:

* The Makefiles use the "include" directive, which is not supported by
all versions of make. Use GNU make if this is a problem.

* The Makefiles assume that make execute commands by calling /bin/sh. They
won't work if /bin/csh is called instead. You may have to unset the SHELL
environment variable, or set it to /bin/sh.

* gcc 2.7.2.1 generates incorrect code for the runtime system in -O mode,
at least on the Intel x86 architecture; other processors have not been
tested with gcc 2.7.2.1. The solution is to downgrade to 2.7.2, or
upgrade to 2.7.2.2; both work all right.

* gcc 2.6.0 has been reported to generate incorrect code for the
runtime system in -O mode. Upgrade to a newer version.

MACHINE-SPECIFIC HINTS:

* On HP 9000/700 machines under HP/UX 9.  Some versions of cc are
unable to compile correctly the runtime system (wrong code is
generated for (x - y) where x is a pointer and y an integer).
Fix: use gcc.