(file) Return to driver.ml CVS log (file) (dir) Up to [venge] / src / mkc

 1 graydon 1.1 open Shell
 2             
 3             let compile makefile outfile homedir =
 4 graydon 1.3   let runfile = Filename.temp_file "mkc" ".exe" in
 5 graydon 1.1   let cfile = Filename.temp_file "mkc" ".c" in
 6               let tidyup _ = 
 7                 begin
 8                   (try Unix.unlink runfile with _ -> ());
 9                   (try Unix.unlink cfile with _ -> ())
10                 end
11               in
12 graydon 1.5   let frontend = "./mkc-fe -impl" in
13 graydon 1.1     try
14                   tidyup ();
15                   call [cmd "ocamlc" ["-pp"; frontend; "-o"; runfile; "-I"; homedir;
16 graydon 1.5 			  "-I"; "frontc"; "frontc.cma"; "be.cmo"; "-impl"; makefile ]];
17 graydon 1.1       Unix.chmod runfile 0o700;
18                   call ~stdout:(to_file cfile) [cmd runfile []];
19                   call [cmd "gcc" ["-o"; outfile; cfile]];
20                   Unix.chmod outfile 0o755;
21                   tidyup ()
22                 with
23             	_ -> tidyup ()
24 graydon 1.4 
25             let output_file = ref "a.out";;
26             
27             let args = [
28             
29               ("-o", 
30                Arg.String (fun x -> output_file := x),  
31                "set output file");
32             
33               ("-version", 
34 graydon 1.5    Arg.Unit (fun _ -> Printf.printf "mkc version $Id: driver.ml,v 1.4 2002/04/28 05:07:52 graydon Exp $\n"),  
35 graydon 1.4    "display version")
36             ]
37             ;;
38             
39 graydon 1.1 let _ = 
40 graydon 1.4   Arg.parse args (fun x -> compile x !output_file ".") 
41                   (Printf.sprintf "usage: %s [options] <input.mk>\n%s\n" 
42             	 Sys.argv.(0) "where options is one of:")
43             	 
44             
45 graydon 1.1 
46             

graydon hoare
Powered by
ViewCVS 0.9.2