[ocaml-platform] Problem with the lib directory in opam's directory hierarchy

Kim Nguyễn kim at nguyen.vg
Wed Apr 22 16:20:17 BST 2015


It is my understanding that for compiler "foo", opam creates a
standard directory hierarchy under ~/.opam/foo/, with the usual
directories such as bin, etc, lib, share, doc.

The problem lies with the lib directory. It seems that lib is used
both as the usual lib directory (i.e. the opam equivalent of
$PREFIX/lib) and as the base directory for ocamlfind packages. Usually
(e.g. in debian or by installing from sources) the META file and
runtime support for the ocaml package 'bar' would go in `ocamlc
-where`/bar/, while the binary files used by the package go into

Under opam, both sets of files end-up in the same directory, which
breaks the "usual" make uninstall rule:

       ... stuff ...
       rm -rf "$PREFIX"/lib/bar/
       ocamlfind remove bar

In that case, ocamlfind will not find its files and complain when
uninstalling. If we switch the two lines, ocamlfind complains with a
warning if there are directories within bar/ (since the ocamlfind
hierarchy is supposed to be flat for a given package).

The way that would work in both opam and non opam setups would be:

rm -rf "$PREFIX"/lib/bar/...all the files that are installed...
ocamlfind remove bar
rm -rf "$PREFIX"/lib/bar/

(The last line is to not leave a dangling empty bar directory in the
normal case where the two dirs are distincts. In the opam case, the
directory is removed by ocamlfind remove).

Is there a better way to do this ? (I'm not asking to change the opam
directory structure, I just want to understand the best way to be
compatible with both distrib packagers and opam packagers).
Also, is it considered good practice to put in an ocamlfind package
directory files or subdirectory that were not installed via ocamlfind
install ?


More information about the Platform mailing list