File: myocamlbuild.ml

package info (click to toggle)
ocaml-doc 3.10-1
  • links: PTS, VCS
  • area: non-free
  • in suites: lenny
  • size: 7,476 kB
  • ctags: 2,644
  • sloc: ml: 325; sh: 64; makefile: 34; ansic: 15
file content (35 lines) | stat: -rw-r--r-- 892 bytes parent folder | download
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
open Ocamlbuild_plugin;;
open Command;;

let cc = A"cc";;
let ar = A"ar";;

dispatch begin function
| After_rules ->
    let libasmrun = !*Ocamlbuild_pack.Ocaml_utils.stdlib_dir/"libasmrun.a" in

    flag ["ocaml"; "link"; "output_obj"] (A"-output-obj");

    rule "output C obj"
      ~deps:["%.cmx"; "%.o"]
      ~prod:"%caml.o"
      (Ocamlbuild_pack.Ocaml_compiler.native_link "%.cmx" "%caml.o");

    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;
    rule "build main"
      ~deps:["libfib.a"; "main.o"]
      ~prod:"main"
      begin fun _ _ ->
        Cmd(S[cc; P"main.o"; P"libfib.a"; A"-o"; Px"main"])
      end;
| _ -> ()
end