d5eb3a558fe1345e9a71fdf47ef0488f7aebe69d
[tatoo.git] / build
1 #!/usr/bin/env ocaml
2
3 let target = ref [ "main.otarget" ]
4 let debug = ref false
5 let profile = ref false
6 let verbose = ref false
7
8 let dir = Sys.getcwd ()
9 let project_root = Filename.dirname Sys.argv.(0)
10
11 let () =
12   for i = 1 to Array.length Sys.argv - 1 do
13     match Sys.argv.(i) with
14     | "-d" -> debug := true
15     | "-p" -> profile := true
16     | "-v" -> verbose := true
17     | x -> target := x :: !target
18   done
19
20 let oprofile = if !profile then " -tag profile " else ""
21 let odebug = if !profile then " -tag debug " else ""
22 let otarget = List.fold_left (fun acc t ->
23   let t = if t = "clean" then "-clean" else t in
24   t ^ " " ^ acc) "" !target
25 let overbose = if !verbose then " -classic-display " else ""
26 let () =
27   Sys.chdir project_root;
28   Printf.printf "Entering directory `%s'\n%!" project_root
29
30 let cmd = Printf.sprintf "ocamlbuild -use-ocamlfind %s %s %s %s"
31   overbose  oprofile  odebug otarget
32 let i = Sys.command cmd
33 let () = Sys.chdir dir;
34   Printf.printf "Leaving directory `%s'\n%!" project_root
35 let _ = exit i
36