4 require (built "program" ["main.c"; "utils.c"])
6 (* Goal: build the final program from source files. *)
7 and built program sources =
8 target (more_recent [program] sources);
9 List.iter (fun s -> require (compiled s)) sources;
11 let objects = List.map (change_file_extension "o") sources in
12 sh "cc %s -o %s" (String.concat " " objects) program
14 (* Goal: Make sure a C file is compiled (to an object file). *)
16 let o_file = change_file_extension "o" c_file in
17 target (more_recent [o_file] [c_file]);
18 require (file_exists c_file);
19 sh "cc -c %s -o %s" c_file o_file
25 | Goal_result (Goal_failed msg) ->
26 prerr_endline ("error: " ^ msg);
29 prerr_endline (Printexc.to_string exn);