OCaml Packages
This section describes how to prepare packages which contain
applications written in OCaml, OCaml modules and OCaml language
itself.
Naming conventions
OCaml libraries should have names prefixed with
ocaml- (examples: ocaml-camlp4,
ocaml-odbc). Similarly tools that are only usable
during OCaml development (like ocaml-otags or
ocaml-mlglade) also should be prefixed with
ocaml-.
However programs, that have same general use outside OCaml
development shouldn't. For example there is hevea
package, not ocaml-hevea.
Rationale: it should be easy to identify tools usable during
ocaml development just by looking at their name. Also we don't want
to clutter global package namespace (think about
postgres package). However information
that hevea is written in ocaml is of little importance to the
end user.
Package name should be all in lowercase. There is no
HeVeA or any other WEirD-StUFF.
Same goes for directory it is installed in. For example for
ocaml-lablgl it is
%{_libdir}/lablgl, not
%{_libdir}/lablGL. Also findlib package names
should be all in lowercase.
Rationale: it is hard to remember capitalization of name, when it
needs to be used in compiler flags.
What is distributed?
When you create package with OCaml module, following files should
be included in package:
All *.cmi files.
All *.cmx files. They contain small
inline functions and therefore are needed during compilation.
*.cma and *.cmxa
archives. They are often called foo.cma
and foo.cmxa*.a archives for corresponding
*.cmxa (foo.a for
foo.cmxa).
*.a archives with compiled C parts
of library (this is often libfoo.a).
dll*.so dynamic link library for
runtime system (dllfoo.so). If package
contains parts written in C and doesn't produce
dll*.so, you should fix it. See
ocaml-odbc.spec for an example.
Any examples. They are often very helpful. If there is just one,
or two files, you can gzip them and put as
%doc. Otherwise copy them to
%{_examplesdir}.
Following files should NOT be distributed:
*.cmo object files. There is however
one exception -- if file is needed for link (like
gtkInit.cmo in lablgtk or
std_exit.cmo in OCaml itself),
then it should be of course included.
*.o for corresponding
*.cmx. They are included in
*.a anyway. Exception -- as above.
*.ml sources.
*.mli interface sources. However, if
package lacks any documentation (which is unfortunately often
the case), you can include *.mli, but
it should be gziped and placed in package as
%doc.
OCaml Language
Package with OCaml itself is split into several subpackages:
ocaml-runtimeocamlrun and base
dll*.so.
ocaml
Bytecode and native compilers, standard library,
debugger and other tools.
ocaml-camlp4
Pre Processor Pretty Printer. Provides:
camlp4.
ocaml-x11graphics
Just dllgraphics.so. Not in
ocaml-runtime since it requires
XFree86-libs to run.
ocaml-x11graphics-devel
Development parts of Graphics
module. Similar split holds for
ocaml-labltk and
ocaml-labltk-devel subpackages.
ocaml-devel*.cm[iox] files resulting
from compilation of OCaml compiler itself. It is needed
by some programs.
Standard OCaml library path is %{_libdir}/ocaml.
%{_libdir}/ocaml/ld.conf contains just this
directory (see below for details).
OCaml C includes are placed in %{_includedir}/caml,
but compatibility symlink %{_libdir}/ocaml/caml
is provided.
ocamlc and ocamlcopt are symlinked
to ocamlc.opt and ocamlcopt.opt
respectively. However ocamlc.byte and
ocamlcopt.byte are also provided in case there
are some problems with .opt compilers.
OCaml Modules
If package has dll*.so stuff, it should be split
into two parts -- base package with just dll*.so
and -devel subpackage with rest. If there is
no dll*.so we produce just
-devel subpackage. For example is library
foo is written all in OCaml, so there is no
dll*.so, you should make
ocaml-foo.spec with no %files
section for main package, just for ocaml-foo-devel.
While having just -devel might seem odd, but:
It is consistent.
If OCaml will ever support dynamic loading (of either bytecode
libraries or native code libraries (this can be done even
now, but needs to be further investigated)), we won't have to
change package names.
Package named foo should be installed in
%{_libdir}/ocaml/foo. Also
dll*.so should go there, but there should be
symlinks to them in %{_libdir}/ocaml.
Therefore there is no need to modify
%{_libdir}/ocaml/ld.conf.
%{_libdir}/ocaml/foo should be owned by
ocaml-foo, not by ocaml-foo-devel.
Base package should use rpm macro
%require_eq ocaml-runtime, while -devel package
%require_eq ocaml, so they won't be installed with
possibly incompatible OCaml version.
findlib
findlib is package management tool for OCaml libraries. Information
about packages is stored in META files.
Even if package use findlib to install itself, it should be placed
in %{_libdir}/ocaml/foo, not in
%{_libdir}/ocaml/site-lib/foo (this is to be
consistent with packages not using findlib). However
META file should be installed in
%{_libdir}/ocaml/site-lib/foo/META.
If there is no META file for package, you
should consider creating one.
Flags for compilation.c files should be compiled with
%{__cc} (not gcc,
cc nor ocamlc).
During compilation standard %{rpmcflags}
should be used (this is the same as with other packages in PLD).
.ml should not be compiled with
ocamlc option. If bundled
Makefile does so, you should fix it.
Toplevel systems
As OCaml can now handle dynamic loading interactive systems are
not of much use (one can always do #load
"foobar.cma"). However if you feel interactive system
linked with some library might be needed, separate it into
-toplevel subpackage.