2 open Ocamlbuild_plugin
;;
4 let mkcamlp4 prod deps
=
5 let mode = match Pathname.get_extension
(Pathname.mk prod
) with
8 | _
-> failwith
"mkcamlp4 can build only .byte and .native targets"
10 let ocaml = match mode with `Byte
-> !Options.ocamlc
| `Native
-> !Options.ocamlopt
in
11 let cm name
= A
(name ^
match mode with `Byte
-> ".cmo" | `Native
-> ".cmx") in
13 rule
(sprintf
"mkcamlp4 %s" prod
) ~deps ~prod
begin fun _ _
->
17 T
(tags_of_pathname prod
++"link");
18 cm "Camlp4Parsers/Camlp4OCamlRevisedParser";
19 cm "Camlp4Parsers/Camlp4OCamlParser";
20 cm "Camlp4Printers/Camlp4AutoPrinter";
21 Command.atomize_paths deps
;
27 let _ = dispatch
begin function
29 flag
["pp"; "camlp4of"] & S
[A
"-loc"; A
"loc"];
30 flag
["pp"; "camlp4orf"] & S
[A
"-loc"; A
"loc"];
31 flag
["ocaml";"pp";"pa_deriving"] (P
"pa_deriving.cma");
32 dep
["pa_deriving"] ["pa_deriving.cma"];
36 mkcamlp4 "deriving.byte" ["pa_deriving.cma"];
37 mkcamlp4 "deriving.native" ["pa_deriving.cmxa"];