#!/usr/bin/env ocaml let target = ref [ "main.otarget" ] let debug = ref false let profile = ref false let verbose = ref false let dir = Sys.getcwd () let project_root = Filename.dirname Sys.argv.(0) let () = for i = 1 to Array.length Sys.argv - 1 do match Sys.argv.(i) with | "-d" -> debug := true | "-p" -> profile := true | "-v" -> verbose := true | x -> target := x :: !target done let oprofile = if !profile then " -tag profile " else "" let odebug = if !profile then " -tag debug " else "" let otarget = List.fold_left (fun acc t -> let t = if t = "clean" then "-clean" else t in t ^ " " ^ acc) "" !target let overbose = if !verbose then " -classic-display " else "" let () = Sys.chdir project_root; Printf.printf "Entering directory `%s'\n%!" project_root let cmd = Printf.sprintf "ocamlbuild -use-ocamlfind %s %s %s %s" overbose oprofile odebug otarget let i = Sys.command cmd let () = Sys.chdir dir; Printf.printf "Leaving directory `%s'\n%!" project_root let _ = exit i