let buildir =
(* Detect a location where we can store semi-temporary data:
- it must survive a compilation
- it must be removed with 'make clean'
*)
let pwd = Sys.getcwd () in
let dir_exists fn = Sys.file_exists fn && Sys.is_directory fn in
let concat, dirname = Filename.concat, Filename.dirname in
List.find
dir_exists
[
concat pwd "_build";
concat (dirname pwd) "_build";
concat (dirname (dirname pwd)) "_build";
pwd
]