Make the build script compatible with emacs compile mode.
[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 (*  if Filename.is_relative build_path
11   then Filename.concat dir build_path
12   else build_path *)
13
14 let () =
15   for i = 1 to Array.length Sys.argv - 1 do
16     match Sys.argv.(i) with
17     | "-d" -> debug := true
18     | "-p" -> profile := true
19     | "-v" -> verbose := true
20     | x -> target := x
21   done
22
23 let oprofile = if !profile then " -tag profile " else ""
24 let odebug = if !profile then " -tag debug " else ""
25 let otarget = if !target = "clean" then " -clean " else !target
26 let overbose = if !verbose then " -classic-display " else ""
27 let () =
28   Sys.chdir project_root;
29   Printf.printf "Entering directory `%s'\n%!" project_root
30
31 let cmd = Printf.sprintf "ocamlbuild -use-ocamlfind %s %s %s %s"
32   overbose  oprofile  odebug otarget
33 let i = Sys.command cmd
34 let () = Sys.chdir dir;
35   Printf.printf "Leaving directory `%s'\n%!" project_root
36 let _ = exit i
37