Building an OCaml package
The details relating to OCaml package construction are provided in the the OCaml System Release 4.00 documentation and users manual. Here's how I go about it. The key to building an OCaml package is to first compile the package modules with the
-for-pack
flag and then combine the compiled modules with the -pack
flag. The procedure can be nicely wrapped up in an OMake macro, presented in this OMakefile schematic. make_package(P, libname, S) = for_pack (P, f) = OCAMLFLAGS = -for-pack $(P) $(f).cmx $(f)$(EXT_OBJ): $(f).cmo: $(f).cmi: foreach (f, $(S)) for_pack ($(P), $(f)) section .DEFAULT: $(OCamlPackage $(P), $(S)) .DEFAULT: $(OCamlLibraryInstall _,$(BIN_DIR), $(libname), $(P)) S=$(rootname $(file $(basename $(glob *.ml)) )) make_package(Foo, foo, $(S))