open Ocamlbuild_plugin
-open Command
+let includes =
+ let open Pathname in
+ let d = Array.to_list (readdir "include") in
+ List.map (concat "include") d
-let ocamlfind_packages = "unix,ulex,expat,camlp4,camlp4.lib,camlp4.macro"
-let ocamlfind x = S[ T (Tags.singleton "ocamlfind");
- A "ocamlfind"; x ;
- A "-package";
- A ocamlfind_packages;
- A "-syntax";
- A "camlp4o";
- A "-ppopt"; A "-I"; A"-ppopt"; A"include"
- ]
-
-let () = dispatch begin
- function
- | Before_rules ->
- 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");
- dep [ "extension:ml" ]
- (List.map (fun s -> "include/" ^ s )
- (Array.to_list (Pathname.readdir "include")));
- flag [ "ocaml"; "link" ] (A"-linkpkg")
- | _ -> ()
-end
+let () =
+ dispatch (function
+ | After_rules ->
+ dep ["ocaml";"compile";] includes;
+ dep ["ocaml";"ocamldep"; ] includes;
+ pflag ["ocaml";"compile";] "ppopt" (fun s -> S [A"-ppopt"; A (s)]);
+ pflag ["ocaml";"ocamldep";] "ppopt" (fun s -> S [A"-ppopt"; A (s)]);
+ | _ -> ()
+ )