Use ocamlbuild's built-in support for ocamlfind (requires ocaml 3.12.1)
[tatoo.git] / myocamlbuild.ml
1 open Ocamlbuild_plugin
2 open Command
3
4 let includes = Hashtbl.create 17
5 let register_include dir =
6   if not (Hashtbl.mem includes dir) then begin
7     Hashtbl.add includes dir ();
8     dep [ "extension:ml" ]
9       (List.map (fun s -> dir ^ "/" ^ s )
10          (Array.to_list (Pathname.readdir dir)))
11   end
12
13 let macro_flags = [
14   "macro_include",
15   (fun s -> register_include s; S [A"-ppopt"; A "-I"; A"-ppopt"; A s]);
16   "macro_define", (fun s -> S [A"-ppopt"; A ("-D"^s)]);
17 ]
18
19 let () = dispatch begin
20   function
21     | Before_rules ->
22         List.iter (fun s ->
23           List.iter (fun (fl, fu) ->
24             pflag s fl fu) macro_flags
25         )
26           [["ocaml";"compile"];
27            ["ocaml";"ocamldep"] ]
28 ;
29     | _ -> ()
30 end