-
Notifications
You must be signed in to change notification settings - Fork 7
/
myocamlbuild.ml
42 lines (34 loc) · 1.08 KB
/
myocamlbuild.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
open Ocamlbuild_plugin;;
open Command;;
let libasmrun = !*Ocamlbuild_pack.Ocaml_utils.stdlib_dir/"libasmrun.a";;
Printf.printf "%s\n" libasmrun;;
let ar = A"ar";;
let headers = ["hunpos.h"]
;;
dispatch begin function
| After_rules ->
rule "output C obj"
~dep:"%.ml"
~prod:"%caml.o"
begin fun env _ ->
let caml_o = env "%caml.o" and ml = env "%.ml" in
Cmd(S[!Options.ocamlopt; A"-output-obj"; P ml; A"-o"; Px caml_o])
end;
rule "build C lib"
~deps:["%wrap.o"; "%caml.o"]
~prod:"lib%.a"
begin fun env _ ->
let wrap_o = env "%wrap.o" and caml_o = env "%caml.o"
and lib_a = env "lib%.a" in
Seq[cp libasmrun lib_a;
Cmd(S[ar; A"r"; Px lib_a; P caml_o; P wrap_o])]
end;
flag ["use_cc" ]
(S[A"-output-obj"; A"-cc"; A"g++"; A"-cclib" ; A"-custom"; ]);
(* As an approximation all our C files use the headers.
Note: This will import headers in the build directory. *)
dep ["compile"; "c"] headers;
()
| _ -> ()
end;;
(* A"-output-obj"; A"-ccopt"; *)