3

I'm using ocamlbuild to compile an OCaml library via a mylib.mllib file that lists the modules comprising the library. Afterwards I want to install the library files using ocamlfind. Unlike binary files built with ocamlbuild, all the library files are in the _build directory. Is the correct way to install them using something like

ocamlfind install META _build/a.cma _build/a.cmxa ...

or is there some better integration between ocamlbuild and ocamlfind? In particular, I noticed the -install-lib-dir flag of ocamlbuild but can't find documentation about its purpose.

I'm aware of oasis but right now would like to solve the problem within a Makefile and an install target. All of this is in the context of using the opam library manager but it should not matter for the discussion.

Christian Lindig
  • 1,216
  • 1
  • 9
  • 24
  • 1
    You are probably aware that opam provides a mechanism to install files, I just wanted to mention it just in case. – didierc Jan 04 '15 at 23:28
  • 1
    The option you mention overrides the default directory where the ocamlbuild libraries are located (usually `/usr/lib/ocaml/ocamlbuild/`). Try `ocamlbuild -where`, then try again with that option and a dummy path to check its effect. – didierc Jan 04 '15 at 23:41
  • 2
    There's no particular integration between ocamlbuild and ocamlfind install-wise. Ocamlfind support has been added to ocamlbuild long time after its first release, and initially ocamlbuild was not meant to use ocamlfind. Since the project has been taken over by its new maintainer, ocamlbuild started supporting ocamlfind for its package management features, but installation is not among ocamlbuild duties, which is the reason why oasis and opam got started. – didierc Jan 10 '15 at 12:52
  • Ocamlfind provides both compilation support and install support, but in both cases you need some scripting around it to handle the whole process (ie. it is meant to be used with other tools like make). – didierc Jan 10 '15 at 12:58
  • My build process is driven by Make and I'm fine with this. I was a little surprised that some build targets are symlinked by ocamlbuild into `_build/` while others, library files in particular, are not. Hence my question about the best practice to install those. I have no problem referencing them in `_build/` if this is what it takes. – Christian Lindig Jan 10 '15 at 13:02
  • And that's what opam does. I think oasis does it too when it comes to ocamlbuild built files. – didierc Jan 10 '15 at 13:46

1 Answers1

1

No, there is no specific integration. ocamlbuild is agnostic of pre-build (configuration) and post-build (installation) tools, and ocamlfind is similarly agnostic of build tools.

You are correct that ocamlbuild is not very good at reliably simlinking targets from _build/. This is a known glitch, but you should feel free to report specific cases where this is an issue to you. In any case, I think it is better to refer to the file in _build/ directly.

There is a feature request by Daniel Bünzli to have ocamlbuild help produce OPAM's .install files rather than writing them by hand (or makefile scripting). I personally haven't had time to work on such features, but I would warmly welcome any ocamlbuild contribution along this front.

gasche
  • 31,259
  • 3
  • 78
  • 100