10.1 Introduction
OCamlmake-o-matic (omom) is a set of two tools to easily generate Makefiles.
Makefiles are generated from a omom file containing templates.
Omom files can be edited through a graphical user interface.
Omom comes with a cameleon plugin for better integration and easier use.
10.2 Overview
An omom file contains templates. A template is a set of variables, i.e.
identifiers with their corresponding values. Each template is associated
to a file which contains a skeleton of the future Makefile.
When generating the Makefile, all occurences of idenfitiers (more
precisely of !(identifier)) in the chosen template will be remplaced
by their values.
Omom files and templates can be edited with
omom-edit this way:
$ omom-edit omom_file.cm
The tool to generate Makefile is omom-gen.
$ omom-gen omom_file.cm my_template > Makefile
where my_template is the name of the template contained in
omom_file.cm you want to use.
There are at least two templates in each omom file: ocaml and common.
Those two templates are special. They are not associated with a file (so they
cannot be used as a a template name passed through the command line
to omom-gen) and they cannot be edited as others templates.
In a way, they are part of all other templates since the variables they contain
are included in each template. The ocaml templates defines variables
which are directly related to ocaml (such as OCAMLC and OCAMLOPT). You can modify the values of its variables but you can't
add new variables. The common templates purpose is to share variables
between templates. Some variable are predefined but you can add your
own variables.
A variable can be activated or not. If it's not, the variable value
will be set as its name as all other unknown identifiers.
The last thing to know about variables is that they can be of two
types: string or list of strings. The type really matters because of the
associated action. An action is a kind of filter which is applied to the value of a
variable before the substitution in the skeleton file. An action
can do different things depending on the type. At the moment, the only
provided action is include which adds -I to each element of a
list.
10.3 First step
First, we are going to edit a omom file:
$ omom-edit my_omom_file.cm
Figure 10.1: omom-edit
The window of figure 10.1 appears. Each tab of the window
represents a template. You can inspect the two special templates.
To generate a Makefile, you must add at least another template.
Click on the Templates/New template menu. Enter
my_template as the template name and my_template.cmt as
the associated file.
A new tab appears. Now, let's add a variable to our template.
Select the new tab. Click on the Template/Add field menu.
Choose VERSION as your variable name. Click on the check box to
active the just created variable and enter 0.1 in
the corresponding field as in figure 10.2
Figure 10.2: omom-edit
Now quit. When omom-edit ask you to save, answer yes.
We are now going to write our associated skeleton file:
$ cat > my_template.cmt
version:
@echo VERSION: !(VERSION)
^D
where space before @echo is a tabulation.
Now, it's time to generate our makefile:
$ omom-gen my_omom_file.cm my_template
version:
@echo VERSION: 0.1
$ omom-gen my_omom_file.cm my_template > Makefile
and to test it:
$ make version
VERSION: 0.1
10.4 First step with cameleon
You can use the omom plug-in in Cameleon, which gives
access to the omom editor and the omom generator from within
cameleon. See section 11.19.1 for more detail.
Launch cameleon and select a CVS working directory. Add a file of type
OCamlmake-o-matic spefication. The filename must end with
.cm (it is the default pattern for omom files).
Cameleon launches mom-edit. Two additionals templates are
provided: configure.in and Makefile.in. Select
configure.in. The field (AC_INIT must be initialized with
the name of a .ml file of your project. Then select Makefile.in.
EXE is the name of your binary. CMO_FILES is the name of
your .cmo files and LIBS is the name of the libraries you
use. Save and quit.
To generate your makefile, you must now launch the omom cameleon
command. The easiest way is to click on List of internal
commands in the Display menu and then double-click on omom.
First generate configure.in. Choose the configure.in
template and enter configure.in as the target. Do the same for
Makefile.in. Now generate the configure script, launching
autoconf in your working directory.