From b12e634bb87266a49bbb9aab74209c925d89a3c3 Mon Sep 17 00:00:00 2001 From: Mike Lin Date: Fri, 3 Sep 2010 17:47:19 -0400 Subject: [PATCH] reorganize directories and clean up build infrastructure --- CamlPaml/Makefile | 33 ----- CamlPaml/_tags | 4 - Makefile | 10 +- PhyloCSF/Makefile | 11 -- PhyloCSF/_tags | 4 - {CamlPaml => lib/CamlPaml}/CamlPaml.ml | 0 {CamlPaml => lib/CamlPaml}/CamlPaml.mlpack | 0 {CamlPaml => lib/CamlPaml}/CamlPaml.odocl | 0 {CamlPaml => lib/CamlPaml}/Code.ml | 0 {CamlPaml => lib/CamlPaml}/Code.mli | 0 {CamlPaml => lib/CamlPaml}/Expr.ml | 0 {CamlPaml => lib/CamlPaml}/Expr.mli | 0 {CamlPaml => lib/CamlPaml}/Fit.ml | 0 {CamlPaml => lib/CamlPaml}/Fit.mli | 0 {CamlPaml => lib/CamlPaml}/Infer.ml | 0 {CamlPaml => lib/CamlPaml}/Infer.mli | 0 {CamlPaml => lib/CamlPaml}/META | 0 lib/CamlPaml/Makefile | 26 ++++ {CamlPaml => lib/CamlPaml}/Newick.ml | 0 {CamlPaml => lib/CamlPaml}/Newick.mli | 0 {CamlPaml => lib/CamlPaml}/NewickLexer.mll | 0 {CamlPaml => lib/CamlPaml}/NewickParser.mly | 0 {CamlPaml => lib/CamlPaml}/P.ml | 0 {CamlPaml => lib/CamlPaml}/P.mli | 0 {CamlPaml => lib/CamlPaml}/Parsimony.ml | 0 {CamlPaml => lib/CamlPaml}/Parsimony.mli | 0 {CamlPaml => lib/CamlPaml}/PhyloEM.ml | 0 {CamlPaml => lib/CamlPaml}/PhyloEM.mli | 0 {CamlPaml => lib/CamlPaml}/PhyloModel.ml | 0 {CamlPaml => lib/CamlPaml}/PhyloModel.mli | 0 {CamlPaml => lib/CamlPaml}/Q.ml | 0 {CamlPaml => lib/CamlPaml}/Q.mli | 0 {CamlPaml => lib/CamlPaml}/T.ml | 0 {CamlPaml => lib/CamlPaml}/T.mli | 0 {CamlPaml => lib/CamlPaml}/Tools.ml | 0 lib/CamlPaml/_tags | 5 + lib/CamlPaml/myocamlbuild.ml | 185 ++++++++++++++++++++++++++++ {CamlPaml => lib/CamlPaml}/test.ml | 0 {PhyloCSF => src}/ECM.ml | 0 src/Makefile | 6 + {PhyloCSF => src}/PhyloCSF.ml | 0 {PhyloCSF => src}/PhyloCSFModel.ml | 0 {PhyloCSF => src}/PhyloCSFTest.ml | 0 src/_tags | 3 + {PhyloCSF => src}/all.itarget | 0 src/myocamlbuild.ml | 185 ++++++++++++++++++++++++++++ 46 files changed, 415 insertions(+), 57 deletions(-) delete mode 100644 CamlPaml/Makefile delete mode 100644 CamlPaml/_tags delete mode 100644 PhyloCSF/Makefile delete mode 100644 PhyloCSF/_tags rename {CamlPaml => lib/CamlPaml}/CamlPaml.ml (100%) rename {CamlPaml => lib/CamlPaml}/CamlPaml.mlpack (100%) rename {CamlPaml => lib/CamlPaml}/CamlPaml.odocl (100%) rename {CamlPaml => lib/CamlPaml}/Code.ml (100%) rename {CamlPaml => lib/CamlPaml}/Code.mli (100%) rename {CamlPaml => lib/CamlPaml}/Expr.ml (100%) rename {CamlPaml => lib/CamlPaml}/Expr.mli (100%) rename {CamlPaml => lib/CamlPaml}/Fit.ml (100%) rename {CamlPaml => lib/CamlPaml}/Fit.mli (100%) rename {CamlPaml => lib/CamlPaml}/Infer.ml (100%) rename {CamlPaml => lib/CamlPaml}/Infer.mli (100%) rename {CamlPaml => lib/CamlPaml}/META (100%) create mode 100644 lib/CamlPaml/Makefile rename {CamlPaml => lib/CamlPaml}/Newick.ml (100%) rename {CamlPaml => lib/CamlPaml}/Newick.mli (100%) rename {CamlPaml => lib/CamlPaml}/NewickLexer.mll (100%) rename {CamlPaml => lib/CamlPaml}/NewickParser.mly (100%) rename {CamlPaml => lib/CamlPaml}/P.ml (100%) rename {CamlPaml => lib/CamlPaml}/P.mli (100%) rename {CamlPaml => lib/CamlPaml}/Parsimony.ml (100%) rename {CamlPaml => lib/CamlPaml}/Parsimony.mli (100%) rename {CamlPaml => lib/CamlPaml}/PhyloEM.ml (100%) rename {CamlPaml => lib/CamlPaml}/PhyloEM.mli (100%) rename {CamlPaml => lib/CamlPaml}/PhyloModel.ml (100%) rename {CamlPaml => lib/CamlPaml}/PhyloModel.mli (100%) rename {CamlPaml => lib/CamlPaml}/Q.ml (100%) rename {CamlPaml => lib/CamlPaml}/Q.mli (100%) rename {CamlPaml => lib/CamlPaml}/T.ml (100%) rename {CamlPaml => lib/CamlPaml}/T.mli (100%) rename {CamlPaml => lib/CamlPaml}/Tools.ml (100%) create mode 100644 lib/CamlPaml/_tags create mode 100644 lib/CamlPaml/myocamlbuild.ml rename {CamlPaml => lib/CamlPaml}/test.ml (100%) rename {PhyloCSF => src}/ECM.ml (100%) create mode 100644 src/Makefile rename {PhyloCSF => src}/PhyloCSF.ml (100%) rename {PhyloCSF => src}/PhyloCSFModel.ml (100%) rename {PhyloCSF => src}/PhyloCSFTest.ml (100%) create mode 100644 src/_tags rename {PhyloCSF => src}/all.itarget (100%) create mode 100644 src/myocamlbuild.ml diff --git a/CamlPaml/Makefile b/CamlPaml/Makefile deleted file mode 100644 index eb67783..0000000 --- a/CamlPaml/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -PKGS = gsl - -lib: - ocamlbuild -cflags -for-pack,CamlPaml CamlPaml.cma CamlPaml.cmxa \ - -ocamlc "ocamlfind ocamlc -package ${PKGS}" \ - -ocamlopt "ocamlfind ocamlopt -package ${PKGS}" \ - -ocamldep "ocamlfind ocamldep -package ${PKGS}" - -TESTPKGS = ${PKGS},oUnit -test: - ocamlbuild test.native \ - -ocamlc "ocamlfind ocamlc -package ${TESTPKGS} -linkpkg" \ - -ocamlopt "ocamlfind ocamlopt -package ${TESTPKGS} -linkpkg" \ - -ocamldep "ocamlfind ocamldep -package ${TESTPKGS}" - _build/test.native -verbose - - -install: lib - ocamlfind install CamlPaml META _build/CamlPaml.cmi _build/CamlPaml.cma _build/CamlPaml.cmxa _build/CamlPaml.a - -uninstall: - ocamlfind remove CamlPaml - -reinstall: - make uninstall - make install - -clean: - rm -f *~ - ocamlbuild -clean - -doc: - ocamlbuild CamlPaml.docdir/index.html diff --git a/CamlPaml/_tags b/CamlPaml/_tags deleted file mode 100644 index 86598ad..0000000 --- a/CamlPaml/_tags +++ /dev/null @@ -1,4 +0,0 @@ -<**/*.ml> or <**/*.mli>: ocaml, pp(ocaml+twt), debug -<**/NewickLexer.*>: ocaml, debug, -pp(ocaml+twt) -<**/NewickParser.*>: ocaml, debug, -pp(ocaml+twt) -: ocaml, native, library, debug diff --git a/Makefile b/Makefile index 98c4e45..fc26041 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,13 @@ ARCH := `uname`.`uname -p` export ARCH PhyloCSF: CamlPaml - cd PhyloCSF; $(MAKE) clean; $(MAKE) $(MFLAGS) - cp PhyloCSF/_build/PhyloCSF.native PhyloCSF.$(ARCH) + cd src; $(MAKE) clean; $(MAKE) $(MFLAGS) + cp src/_build/PhyloCSF.native PhyloCSF.$(ARCH) CamlPaml: - cd CamlPaml; $(MAKE) $(MFLAGS) reinstall + cd lib/CamlPaml; $(MAKE) $(MFLAGS) reinstall clean: - cd CamlPaml; $(MAKE) clean - cd PhyloCSF; $(MAKE) clean + cd lib/CamlPaml; $(MAKE) clean + cd src; $(MAKE) clean rm -f PhyloCSF.* diff --git a/PhyloCSF/Makefile b/PhyloCSF/Makefile deleted file mode 100644 index fb96856..0000000 --- a/PhyloCSF/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -PKGS = batteries,CamlPaml - -all: - ocamlbuild all.otarget \ - -ocamlc "ocamlfind ocamlc -package ${PKGS} -linkpkg" \ - -ocamlopt "ocamlfind ocamlopt -package ${PKGS} -linkpkg" \ - -ocamldep "ocamlfind ocamldep -package ${PKGS}" - -clean: - rm -f *~ - ocamlbuild -clean diff --git a/PhyloCSF/_tags b/PhyloCSF/_tags deleted file mode 100644 index 798b195..0000000 --- a/PhyloCSF/_tags +++ /dev/null @@ -1,4 +0,0 @@ -<**/*.ml> or <**/*.mli>: ocaml, pp(ocaml+twt) -: ocaml, native -true: debug - diff --git a/CamlPaml/CamlPaml.ml b/lib/CamlPaml/CamlPaml.ml similarity index 100% rename from CamlPaml/CamlPaml.ml rename to lib/CamlPaml/CamlPaml.ml diff --git a/CamlPaml/CamlPaml.mlpack b/lib/CamlPaml/CamlPaml.mlpack similarity index 100% rename from CamlPaml/CamlPaml.mlpack rename to lib/CamlPaml/CamlPaml.mlpack diff --git a/CamlPaml/CamlPaml.odocl b/lib/CamlPaml/CamlPaml.odocl similarity index 100% rename from CamlPaml/CamlPaml.odocl rename to lib/CamlPaml/CamlPaml.odocl diff --git a/CamlPaml/Code.ml b/lib/CamlPaml/Code.ml similarity index 100% rename from CamlPaml/Code.ml rename to lib/CamlPaml/Code.ml diff --git a/CamlPaml/Code.mli b/lib/CamlPaml/Code.mli similarity index 100% rename from CamlPaml/Code.mli rename to lib/CamlPaml/Code.mli diff --git a/CamlPaml/Expr.ml b/lib/CamlPaml/Expr.ml similarity index 100% rename from CamlPaml/Expr.ml rename to lib/CamlPaml/Expr.ml diff --git a/CamlPaml/Expr.mli b/lib/CamlPaml/Expr.mli similarity index 100% rename from CamlPaml/Expr.mli rename to lib/CamlPaml/Expr.mli diff --git a/CamlPaml/Fit.ml b/lib/CamlPaml/Fit.ml similarity index 100% rename from CamlPaml/Fit.ml rename to lib/CamlPaml/Fit.ml diff --git a/CamlPaml/Fit.mli b/lib/CamlPaml/Fit.mli similarity index 100% rename from CamlPaml/Fit.mli rename to lib/CamlPaml/Fit.mli diff --git a/CamlPaml/Infer.ml b/lib/CamlPaml/Infer.ml similarity index 100% rename from CamlPaml/Infer.ml rename to lib/CamlPaml/Infer.ml diff --git a/CamlPaml/Infer.mli b/lib/CamlPaml/Infer.mli similarity index 100% rename from CamlPaml/Infer.mli rename to lib/CamlPaml/Infer.mli diff --git a/CamlPaml/META b/lib/CamlPaml/META similarity index 100% rename from CamlPaml/META rename to lib/CamlPaml/META diff --git a/lib/CamlPaml/Makefile b/lib/CamlPaml/Makefile new file mode 100644 index 0000000..d46e3c1 --- /dev/null +++ b/lib/CamlPaml/Makefile @@ -0,0 +1,26 @@ +LIBNAME = CamlPaml + +lib: + ocamlbuild ${LIBNAME}.cma ${LIBNAME}.cmxa + +test: + ocamlbuild test.native + _build/test.native -verbose + + +install: lib + ocamlfind install ${LIBNAME} META _build/${LIBNAME}.cmi _build/${LIBNAME}.cma _build/${LIBNAME}.cmxa _build/${LIBNAME}.a + +uninstall: + ocamlfind remove ${LIBNAME} + +reinstall: + make uninstall + make install + +clean: + rm -f *~ + ocamlbuild -clean + +doc: + ocamlbuild ${LIBNAME}.docdir/index.html diff --git a/CamlPaml/Newick.ml b/lib/CamlPaml/Newick.ml similarity index 100% rename from CamlPaml/Newick.ml rename to lib/CamlPaml/Newick.ml diff --git a/CamlPaml/Newick.mli b/lib/CamlPaml/Newick.mli similarity index 100% rename from CamlPaml/Newick.mli rename to lib/CamlPaml/Newick.mli diff --git a/CamlPaml/NewickLexer.mll b/lib/CamlPaml/NewickLexer.mll similarity index 100% rename from CamlPaml/NewickLexer.mll rename to lib/CamlPaml/NewickLexer.mll diff --git a/CamlPaml/NewickParser.mly b/lib/CamlPaml/NewickParser.mly similarity index 100% rename from CamlPaml/NewickParser.mly rename to lib/CamlPaml/NewickParser.mly diff --git a/CamlPaml/P.ml b/lib/CamlPaml/P.ml similarity index 100% rename from CamlPaml/P.ml rename to lib/CamlPaml/P.ml diff --git a/CamlPaml/P.mli b/lib/CamlPaml/P.mli similarity index 100% rename from CamlPaml/P.mli rename to lib/CamlPaml/P.mli diff --git a/CamlPaml/Parsimony.ml b/lib/CamlPaml/Parsimony.ml similarity index 100% rename from CamlPaml/Parsimony.ml rename to lib/CamlPaml/Parsimony.ml diff --git a/CamlPaml/Parsimony.mli b/lib/CamlPaml/Parsimony.mli similarity index 100% rename from CamlPaml/Parsimony.mli rename to lib/CamlPaml/Parsimony.mli diff --git a/CamlPaml/PhyloEM.ml b/lib/CamlPaml/PhyloEM.ml similarity index 100% rename from CamlPaml/PhyloEM.ml rename to lib/CamlPaml/PhyloEM.ml diff --git a/CamlPaml/PhyloEM.mli b/lib/CamlPaml/PhyloEM.mli similarity index 100% rename from CamlPaml/PhyloEM.mli rename to lib/CamlPaml/PhyloEM.mli diff --git a/CamlPaml/PhyloModel.ml b/lib/CamlPaml/PhyloModel.ml similarity index 100% rename from CamlPaml/PhyloModel.ml rename to lib/CamlPaml/PhyloModel.ml diff --git a/CamlPaml/PhyloModel.mli b/lib/CamlPaml/PhyloModel.mli similarity index 100% rename from CamlPaml/PhyloModel.mli rename to lib/CamlPaml/PhyloModel.mli diff --git a/CamlPaml/Q.ml b/lib/CamlPaml/Q.ml similarity index 100% rename from CamlPaml/Q.ml rename to lib/CamlPaml/Q.ml diff --git a/CamlPaml/Q.mli b/lib/CamlPaml/Q.mli similarity index 100% rename from CamlPaml/Q.mli rename to lib/CamlPaml/Q.mli diff --git a/CamlPaml/T.ml b/lib/CamlPaml/T.ml similarity index 100% rename from CamlPaml/T.ml rename to lib/CamlPaml/T.ml diff --git a/CamlPaml/T.mli b/lib/CamlPaml/T.mli similarity index 100% rename from CamlPaml/T.mli rename to lib/CamlPaml/T.mli diff --git a/CamlPaml/Tools.ml b/lib/CamlPaml/Tools.ml similarity index 100% rename from CamlPaml/Tools.ml rename to lib/CamlPaml/Tools.ml diff --git a/lib/CamlPaml/_tags b/lib/CamlPaml/_tags new file mode 100644 index 0000000..bd495c9 --- /dev/null +++ b/lib/CamlPaml/_tags @@ -0,0 +1,5 @@ +<**/*.ml> or <**/*.mli>: ocaml, debug, pkg_gsl, for-pack(CamlPaml), pp(ocaml+twt) +<**/NewickLexer.*>: -pp(ocaml+twt) +<**/NewickParser.*>: -pp(ocaml+twt) +: pkg_oUnit +: pkg_gsl, pkg_oUnit diff --git a/lib/CamlPaml/myocamlbuild.ml b/lib/CamlPaml/myocamlbuild.ml new file mode 100644 index 0000000..5ffd91e --- /dev/null +++ b/lib/CamlPaml/myocamlbuild.ml @@ -0,0 +1,185 @@ +open Ocamlbuild_plugin +open Command (* no longer needed for OCaml >= 3.10.2 *) + +(** + Overview of tags: + - [pkg_batteries] to use Batteries as a library, without syntax extensions + - [use_batteries] and [use_batteries_r] to use both Batteries and all the non-destructive syntax extensions + - [pkg_sexplib.syntax] with [syntax_camlp4o] or [syntax_camlp4r] for sexplib +*) + + +(** + {1 OCamlFind} +*) + +let run_and_read = Ocamlbuild_pack.My_unix.run_and_read + +let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings + +module OCamlFind = +struct + (* this lists all supported packages *) + let find_packages () = + blank_sep_strings & + Lexing.from_string & + run_and_read "ocamlfind list | cut -d' ' -f1" + + (* this is supposed to list available syntaxes, but I don't know how to do it. *) + let find_syntaxes () = ["camlp4o"; "camlp4r"] + + (* ocamlfind command *) + let ocamlfind x = S[A"ocamlfind"; x] + + let before_options () = + (* by using Before_options one let command line options have an higher priority *) + (* on the contrary using After_options will guarantee to have the higher priority *) + + (* override default commands by ocamlfind ones *) + Options.ocamlc := ocamlfind & A"ocamlc"; + Options.ocamlopt := ocamlfind & A"ocamlopt"; + Options.ocamldep := ocamlfind & A"ocamldep"; + Options.ocamldoc := ocamlfind & A"ocamldoc"; + Options.ocamlmktop := ocamlfind & A"ocamlmktop" + + let get_ocamldoc_directory () = + let ocamldoc_directory = run_and_read "ocamlfind ocamldoc -customdir" in + let length = String.length ocamldoc_directory in + assert (length != 0); + let char = ocamldoc_directory.[length - 1] in + if (char = '\n') || (char = '\r') then String.sub ocamldoc_directory 0 (length - 1) + else ocamldoc_directory + + let after_rules () = + (* When one link an OCaml library/binary/package, one should use -linkpkg *) + flag ["ocaml"; "byte"; "link"; "program"] & A"-linkpkg"; + flag ["ocaml"; "native"; "link"; "program"] & A"-linkpkg"; + + + (* For each ocamlfind package one inject the -package option when + * compiling, computing dependencies, generating documentation and + * linking. *) + List.iter begin fun pkg -> + flag ["ocaml"; "compile"; "pkg_"^pkg] & S[A"-package"; A pkg]; + flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S[A"-package"; A pkg]; + flag ["ocaml"; "doc"; "pkg_"^pkg] & S[A"-package"; A pkg]; + flag ["ocaml"; "link"; "pkg_"^pkg] & S[A"-package"; A pkg]; + end (find_packages ()); + + (* Like -package but for extensions syntax. Morover -syntax is useless + * when linking. *) + List.iter begin fun syntax -> + flag ["ocaml"; "compile"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; + flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; + flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; + end (find_syntaxes ()); + + (* The default "thread" tag is not compatible with ocamlfind. + Indeed, the default rules add the "threads.cma" or "threads.cmxa" + options when using this tag. When using the "-linkpkg" option with + ocamlfind, this module will then be added twice on the command line. + + To solve this, one approach is to add the "-thread" option when using + the "threads" package using the previous plugin. + *) + flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]); + flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]); +end + +(** + {1 OCaml Batteries Included} +*) + +module Batteries = +struct + let before_options () = () + + let after_rules () = + flag ["ocaml"; "link"; "byte"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"; A "odoc_info.cma"]); + flag ["ocaml"; "link"; "native"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"(*; A "odoc_info.cmxa"*)]); + flag ["ocaml"; "docfile"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"]); + flag ["ocaml"; "docdir"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"]); + flag ["ocaml"; "doc"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"]); + + (*The command-line for [use_batteries] and [use_batteries_r]*) + + let cl_use_boilerplate = [A"-package"; A "batteries.pa_type_conv.syntax,batteries,sexplib.syntax"] + and cl_use_batteries = [A"-package"; A "batteries.pa_openin.syntax,batteries.pa_where.syntax,batteries.pa_batteries.syntax"; A "-package"; A "batteries"] + and cl_use_batteries_o = [] + (*[cl_use_batteries_o]: extensions which only make sense in original syntax*) + and cl_camlp4o = [A"-syntax"; A "camlp4o"] + and cl_camlp4r = [A"-syntax"; A "camlp4r"] in + + let cl_boilerplate_original = cl_use_boilerplate @ cl_camlp4o + and cl_boilerplate_revised = cl_use_boilerplate @ cl_camlp4r + and cl_batteries_original = cl_use_batteries @ cl_use_batteries_o @ cl_camlp4o + and cl_batteries_revised = cl_use_batteries @ cl_camlp4r in + + (** Tag [use_boilerplate] provides boilerplate syntax extensions, + in original syntax*) + + flag ["ocaml"; "compile"; "use_boilerplate"] & S cl_boilerplate_original ; + flag ["ocaml"; "ocamldep"; "use_boilerplate"] & S cl_boilerplate_original ; + flag ["ocaml"; "doc"; "use_boilerplate"] & S cl_boilerplate_original ; + flag ["ocaml"; "link"; "use_boilerplate"] & S cl_boilerplate_original ; + + (** Tag [use_boilerplate_r] provides boilerplate syntax extensions, + in original syntax*) + + flag ["ocaml"; "compile"; "use_boilerplate_r"] & S cl_boilerplate_revised ; + flag ["ocaml"; "ocamldep"; "use_boilerplate_r"] & S cl_boilerplate_revised ; + flag ["ocaml"; "doc"; "use_boilerplate_r"] & S cl_boilerplate_revised ; + flag ["ocaml"; "link"; "use_boilerplate_r"] & S cl_boilerplate_revised ; + + (** Tag [use_batteries] provides both package [batteries] + and all syntax extensions, in original syntax. *) + + flag ["ocaml"; "compile"; "use_batteries"] & S cl_batteries_original ; + flag ["ocaml"; "ocamldep"; "use_batteries"] & S cl_batteries_original ; + flag ["ocaml"; "doc"; "use_batteries"] & S cl_batteries_original ; + flag ["ocaml"; "link"; "use_batteries"] & S cl_batteries_original ; + + (** Tag [use_batteries_r] provides both package [batteries] + and all syntax extensions, in revised syntax. *) + + flag ["ocaml"; "compile"; "use_batteries_r"] & S cl_batteries_revised; + flag ["ocaml"; "ocamldep"; "use_batteries_r"] & S cl_batteries_revised; + flag ["ocaml"; "doc"; "use_batteries_r"] & S cl_batteries_revised; + flag ["ocaml"; "link"; "use_batteries_r"] & S cl_batteries_revised + + +(* flag ["ocaml"; "compile"; "use_batteries"] & S[A "-verbose"; + A"-package"; A "batteries.syntax.full"; + A"-syntax"; A "batteries.syntax.full"]; + flag ["ocaml"; "ocamldep"; "use_batteries"] & S[A "-verbose"; + A"-package"; A "batteries.syntax.full"; + A"-syntax"; A "batteries.syntax.full"]; + flag ["ocaml"; "doc"; "use_batteries"] & S[A "-verbose"; + A"-package"; A "batteries.syntax.full"; + A"-syntax"; A "batteries.syntax.full"]; + flag ["ocaml"; "link"; "use_batteries"] & S[A "-verbose"; + A"-package"; A "batteries.syntax.full"; + A"-syntax"; A "batteries.syntax.full"];*) + + +end + +let _ = dispatch begin function + | Before_options -> + OCamlFind.before_options (); + Batteries.before_options () + | After_rules -> + OCamlFind.after_rules (); + Batteries.after_rules () + + + | _ -> () +end + + + +(** + which ocamlrun -> header + + print_backtrace -> ajouter "-b" après le header +**) diff --git a/CamlPaml/test.ml b/lib/CamlPaml/test.ml similarity index 100% rename from CamlPaml/test.ml rename to lib/CamlPaml/test.ml diff --git a/PhyloCSF/ECM.ml b/src/ECM.ml similarity index 100% rename from PhyloCSF/ECM.ml rename to src/ECM.ml diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..6fefdf7 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,6 @@ +all: + ocamlbuild all.otarget + +clean: + rm -f *~ + ocamlbuild -clean diff --git a/PhyloCSF/PhyloCSF.ml b/src/PhyloCSF.ml similarity index 100% rename from PhyloCSF/PhyloCSF.ml rename to src/PhyloCSF.ml diff --git a/PhyloCSF/PhyloCSFModel.ml b/src/PhyloCSFModel.ml similarity index 100% rename from PhyloCSF/PhyloCSFModel.ml rename to src/PhyloCSFModel.ml diff --git a/PhyloCSF/PhyloCSFTest.ml b/src/PhyloCSFTest.ml similarity index 100% rename from PhyloCSF/PhyloCSFTest.ml rename to src/PhyloCSFTest.ml diff --git a/src/_tags b/src/_tags new file mode 100644 index 0000000..ea5007d --- /dev/null +++ b/src/_tags @@ -0,0 +1,3 @@ +<**/*.ml> or <**/*.mli>: pp(ocaml+twt) +true: debug, pkg_batteries, pkg_CamlPaml + diff --git a/PhyloCSF/all.itarget b/src/all.itarget similarity index 100% rename from PhyloCSF/all.itarget rename to src/all.itarget diff --git a/src/myocamlbuild.ml b/src/myocamlbuild.ml new file mode 100644 index 0000000..5ffd91e --- /dev/null +++ b/src/myocamlbuild.ml @@ -0,0 +1,185 @@ +open Ocamlbuild_plugin +open Command (* no longer needed for OCaml >= 3.10.2 *) + +(** + Overview of tags: + - [pkg_batteries] to use Batteries as a library, without syntax extensions + - [use_batteries] and [use_batteries_r] to use both Batteries and all the non-destructive syntax extensions + - [pkg_sexplib.syntax] with [syntax_camlp4o] or [syntax_camlp4r] for sexplib +*) + + +(** + {1 OCamlFind} +*) + +let run_and_read = Ocamlbuild_pack.My_unix.run_and_read + +let blank_sep_strings = Ocamlbuild_pack.Lexers.blank_sep_strings + +module OCamlFind = +struct + (* this lists all supported packages *) + let find_packages () = + blank_sep_strings & + Lexing.from_string & + run_and_read "ocamlfind list | cut -d' ' -f1" + + (* this is supposed to list available syntaxes, but I don't know how to do it. *) + let find_syntaxes () = ["camlp4o"; "camlp4r"] + + (* ocamlfind command *) + let ocamlfind x = S[A"ocamlfind"; x] + + let before_options () = + (* by using Before_options one let command line options have an higher priority *) + (* on the contrary using After_options will guarantee to have the higher priority *) + + (* override default commands by ocamlfind ones *) + Options.ocamlc := ocamlfind & A"ocamlc"; + Options.ocamlopt := ocamlfind & A"ocamlopt"; + Options.ocamldep := ocamlfind & A"ocamldep"; + Options.ocamldoc := ocamlfind & A"ocamldoc"; + Options.ocamlmktop := ocamlfind & A"ocamlmktop" + + let get_ocamldoc_directory () = + let ocamldoc_directory = run_and_read "ocamlfind ocamldoc -customdir" in + let length = String.length ocamldoc_directory in + assert (length != 0); + let char = ocamldoc_directory.[length - 1] in + if (char = '\n') || (char = '\r') then String.sub ocamldoc_directory 0 (length - 1) + else ocamldoc_directory + + let after_rules () = + (* When one link an OCaml library/binary/package, one should use -linkpkg *) + flag ["ocaml"; "byte"; "link"; "program"] & A"-linkpkg"; + flag ["ocaml"; "native"; "link"; "program"] & A"-linkpkg"; + + + (* For each ocamlfind package one inject the -package option when + * compiling, computing dependencies, generating documentation and + * linking. *) + List.iter begin fun pkg -> + flag ["ocaml"; "compile"; "pkg_"^pkg] & S[A"-package"; A pkg]; + flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S[A"-package"; A pkg]; + flag ["ocaml"; "doc"; "pkg_"^pkg] & S[A"-package"; A pkg]; + flag ["ocaml"; "link"; "pkg_"^pkg] & S[A"-package"; A pkg]; + end (find_packages ()); + + (* Like -package but for extensions syntax. Morover -syntax is useless + * when linking. *) + List.iter begin fun syntax -> + flag ["ocaml"; "compile"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; + flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; + flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; + end (find_syntaxes ()); + + (* The default "thread" tag is not compatible with ocamlfind. + Indeed, the default rules add the "threads.cma" or "threads.cmxa" + options when using this tag. When using the "-linkpkg" option with + ocamlfind, this module will then be added twice on the command line. + + To solve this, one approach is to add the "-thread" option when using + the "threads" package using the previous plugin. + *) + flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]); + flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]); +end + +(** + {1 OCaml Batteries Included} +*) + +module Batteries = +struct + let before_options () = () + + let after_rules () = + flag ["ocaml"; "link"; "byte"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"; A "odoc_info.cma"]); + flag ["ocaml"; "link"; "native"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"(*; A "odoc_info.cmxa"*)]); + flag ["ocaml"; "docfile"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"]); + flag ["ocaml"; "docdir"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"]); + flag ["ocaml"; "doc"; "use_ocamldoc_info"] (S[A "-I"; A "+ocamldoc"]); + + (*The command-line for [use_batteries] and [use_batteries_r]*) + + let cl_use_boilerplate = [A"-package"; A "batteries.pa_type_conv.syntax,batteries,sexplib.syntax"] + and cl_use_batteries = [A"-package"; A "batteries.pa_openin.syntax,batteries.pa_where.syntax,batteries.pa_batteries.syntax"; A "-package"; A "batteries"] + and cl_use_batteries_o = [] + (*[cl_use_batteries_o]: extensions which only make sense in original syntax*) + and cl_camlp4o = [A"-syntax"; A "camlp4o"] + and cl_camlp4r = [A"-syntax"; A "camlp4r"] in + + let cl_boilerplate_original = cl_use_boilerplate @ cl_camlp4o + and cl_boilerplate_revised = cl_use_boilerplate @ cl_camlp4r + and cl_batteries_original = cl_use_batteries @ cl_use_batteries_o @ cl_camlp4o + and cl_batteries_revised = cl_use_batteries @ cl_camlp4r in + + (** Tag [use_boilerplate] provides boilerplate syntax extensions, + in original syntax*) + + flag ["ocaml"; "compile"; "use_boilerplate"] & S cl_boilerplate_original ; + flag ["ocaml"; "ocamldep"; "use_boilerplate"] & S cl_boilerplate_original ; + flag ["ocaml"; "doc"; "use_boilerplate"] & S cl_boilerplate_original ; + flag ["ocaml"; "link"; "use_boilerplate"] & S cl_boilerplate_original ; + + (** Tag [use_boilerplate_r] provides boilerplate syntax extensions, + in original syntax*) + + flag ["ocaml"; "compile"; "use_boilerplate_r"] & S cl_boilerplate_revised ; + flag ["ocaml"; "ocamldep"; "use_boilerplate_r"] & S cl_boilerplate_revised ; + flag ["ocaml"; "doc"; "use_boilerplate_r"] & S cl_boilerplate_revised ; + flag ["ocaml"; "link"; "use_boilerplate_r"] & S cl_boilerplate_revised ; + + (** Tag [use_batteries] provides both package [batteries] + and all syntax extensions, in original syntax. *) + + flag ["ocaml"; "compile"; "use_batteries"] & S cl_batteries_original ; + flag ["ocaml"; "ocamldep"; "use_batteries"] & S cl_batteries_original ; + flag ["ocaml"; "doc"; "use_batteries"] & S cl_batteries_original ; + flag ["ocaml"; "link"; "use_batteries"] & S cl_batteries_original ; + + (** Tag [use_batteries_r] provides both package [batteries] + and all syntax extensions, in revised syntax. *) + + flag ["ocaml"; "compile"; "use_batteries_r"] & S cl_batteries_revised; + flag ["ocaml"; "ocamldep"; "use_batteries_r"] & S cl_batteries_revised; + flag ["ocaml"; "doc"; "use_batteries_r"] & S cl_batteries_revised; + flag ["ocaml"; "link"; "use_batteries_r"] & S cl_batteries_revised + + +(* flag ["ocaml"; "compile"; "use_batteries"] & S[A "-verbose"; + A"-package"; A "batteries.syntax.full"; + A"-syntax"; A "batteries.syntax.full"]; + flag ["ocaml"; "ocamldep"; "use_batteries"] & S[A "-verbose"; + A"-package"; A "batteries.syntax.full"; + A"-syntax"; A "batteries.syntax.full"]; + flag ["ocaml"; "doc"; "use_batteries"] & S[A "-verbose"; + A"-package"; A "batteries.syntax.full"; + A"-syntax"; A "batteries.syntax.full"]; + flag ["ocaml"; "link"; "use_batteries"] & S[A "-verbose"; + A"-package"; A "batteries.syntax.full"; + A"-syntax"; A "batteries.syntax.full"];*) + + +end + +let _ = dispatch begin function + | Before_options -> + OCamlFind.before_options (); + Batteries.before_options () + | After_rules -> + OCamlFind.after_rules (); + Batteries.after_rules () + + + | _ -> () +end + + + +(** + which ocamlrun -> header + + print_backtrace -> ajouter "-b" après le header +**)