8
6
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
9
<META name="GENERATOR" content="hevea 1.08">
7
<META name="GENERATOR" content="hevea 1.09">
10
8
<LINK rel="stylesheet" type="text/css" href="manual.css">
12
Dependency generator (ocamldep)
9
<TITLE>Dependency generator (ocamldep)</TITLE>
16
<A HREF="manual026.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
17
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
18
<A HREF="manual028.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
12
<A HREF="manual026.html"><IMG SRC="previous_motif.gif" ALT="Previous"></A>
13
<A HREF="index.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
14
<A HREF="manual028.html"><IMG SRC="next_motif.gif" ALT="Next"></A>
21
<H1 CLASS="chapter"><A NAME="htoc146">Chapter 13</A> Dependency generator (ocamldep)</H1> <A NAME="c:camldep"></A>
23
The <TT>ocamldep</TT> command scans a set of Objective Caml source files
16
<H1 CLASS="chapter"><A NAME="htoc146">Chapter�13</A>��Dependency generator (ocamldep)</H1><P> <A NAME="c:camldep"></A>
17
</P><P>The <TT>ocamldep</TT> command scans a set of Objective Caml source files
24
18
(<TT>.ml</TT> and <TT>.mli</TT> files) for references to external compilation units,
25
19
and outputs dependency lines in a format suitable for the <TT>make</TT>
26
20
utility. This ensures that <TT>make</TT> will compile the source files in the
27
21
correct order, and recompile those files that need to when a source
22
file is modified.</P><P>The typical usage is:
32
24
ocamldep <I>options</I> *.mli *.ml > .depend
34
26
where <TT>*.mli *.ml</TT> expands to all source files in the current
35
27
directory and <TT>.depend</TT> is the file that should contain the
36
dependencies. (See below for a typical <TT>Makefile</TT>.)<BR>
38
Dependencies are generated both for compiling with the bytecode
39
compiler <TT>ocamlc</TT> and with the native-code compiler <TT>ocamlopt</TT>.<BR>
42
<H2 CLASS="section"><A NAME="htoc147">13.1</A> Options</H2>
43
The following command-line option is recognized by <TT>ocamldep</TT>.
44
<DL CLASS="description" COMPACT=compact><DT CLASS="dt-description"><B><TT>-I</TT> <I>directory</I></B><DD CLASS="dd-description">
28
dependencies. (See below for a typical <TT>Makefile</TT>.)</P><P>Dependencies are generated both for compiling with the bytecode
29
compiler <TT>ocamlc</TT> and with the native-code compiler <TT>ocamlopt</TT>.</P><H2 CLASS="section"><A NAME="htoc147">13.1</A>��Options</H2><P>The following command-line option is recognized by <TT>ocamldep</TT>.</P><DL CLASS="description"><DT CLASS="dt-description"><B><TT>-I</TT> <I>directory</I></B></DT><DD CLASS="dd-description">
45
30
Add the given directory to the list of directories searched for
46
31
source files. If a source file <TT>foo.ml</TT> mentions an external
47
32
compilation unit <TT>Bar</TT>, a dependency on that unit's interface
50
35
Otherwise, <TT>Bar</TT> is assumed to be a module from the standard library,
51
36
and no dependencies are generated. For programs that span multiple
52
37
directories, it is recommended to pass <TT>ocamldep</TT> the same <TT>-I</TT> options
53
that are passed to the compiler.<BR>
55
<DT CLASS="dt-description"><TT><B>-native</B></TT><DD CLASS="dd-description">
38
that are passed to the compiler.</DD><DT CLASS="dt-description"><TT><B>-native</B></TT></DT><DD CLASS="dd-description">
56
39
Generate dependencies for a pure native-code program (no bytecode
57
40
version). When an implementation file (<TT>.ml</TT> file) has no explicit
58
41
interface file (<TT>.mli</TT> file), <TT>ocamldep</TT> generates dependencies on the
61
44
are compiled to native-code only. The flag <TT>-native</TT> causes
62
45
dependencies on native compiled files (<TT>.cmx</TT>) to be generated instead
63
46
of on <TT>.cmo</TT> files. (This flag makes no difference if all source files
64
have explicit <TT>.mli</TT> interface files.)<BR>
66
<DT CLASS="dt-description" style="background-color:yellow; color:red"><TT><B>-version</B></TT><DD CLASS="dd-description" style="background-color:yellow; color:red">
67
Print version and exit.</DL>
69
<H2 CLASS="section"><A NAME="htoc148">13.2</A> A typical Makefile</H2>
70
Here is a template <TT>Makefile</TT> for a Objective Caml program.
71
<PRE CLASS="verbatim">
47
have explicit <TT>.mli</TT> interface files.)</DD><DT CLASS="dt-description"><TT><B>-version</B></TT></DT><DD CLASS="dd-description">
48
Print version and exit.</DD></DL><H2 CLASS="section"><A NAME="htoc148">13.2</A>��A typical Makefile</H2><P>Here is a template <TT>Makefile</TT> for a Objective Caml program.</P><PRE CLASS="verbatim">OCAMLC=ocamlc
75
51
INCLUDES= # all relevant -I options here
116
92
$(OCAMLDEP) $(INCLUDES) *.mli *.ml > .depend
123
<A HREF="manual026.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
124
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
125
<A HREF="manual028.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
96
<A HREF="manual026.html"><IMG SRC="previous_motif.gif" ALT="Previous"></A>
97
<A HREF="index.html"><IMG SRC="contents_motif.gif" ALT="Up"></A>
98
<A HREF="manual028.html"><IMG SRC="next_motif.gif" ALT="Next"></A>