1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Caml Special Light *)
|
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1995 Institut National de Recherche en Informatique et *)
|
|
|
|
(* Automatique. Distributed only by permission. *)
|
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
1995-07-02 09:51:07 -07:00
|
|
|
open Clflags
|
|
|
|
|
|
|
|
let process_file name =
|
1995-10-24 08:37:23 -07:00
|
|
|
if Filename.check_suffix name ".ml"
|
|
|
|
or Filename.check_suffix name ".mlt" then begin
|
1995-07-02 09:51:07 -07:00
|
|
|
Optcompile.implementation name;
|
1995-10-24 08:37:23 -07:00
|
|
|
objfiles := (Filename.chop_extension name ^ ".cmx") :: !objfiles
|
1995-07-02 09:51:07 -07:00
|
|
|
end
|
|
|
|
else if Filename.check_suffix name ".mli" then
|
|
|
|
Optcompile.interface name
|
|
|
|
else if Filename.check_suffix name ".cmx"
|
|
|
|
or Filename.check_suffix name ".cmxa" then
|
|
|
|
objfiles := name :: !objfiles
|
|
|
|
else if Filename.check_suffix name ".o"
|
|
|
|
or Filename.check_suffix name ".a" then
|
|
|
|
ccobjs := name :: !ccobjs
|
|
|
|
else if Filename.check_suffix name ".c" then begin
|
|
|
|
Optcompile.c_file name;
|
|
|
|
ccobjs := (Filename.chop_suffix (Filename.basename name) ".c" ^ ".o")
|
|
|
|
:: !ccobjs
|
|
|
|
end
|
|
|
|
else
|
|
|
|
raise(Arg.Bad("don't know what to do with " ^ name))
|
|
|
|
|
|
|
|
let print_version_number () =
|
|
|
|
print_string "The Caml Special Light native-code compiler, version ";
|
|
|
|
print_string Config.version;
|
|
|
|
print_newline()
|
|
|
|
|
|
|
|
let main () =
|
|
|
|
try
|
|
|
|
Arg.parse
|
|
|
|
["-I", Arg.String(fun dir -> include_dirs := dir :: !include_dirs);
|
1995-09-05 05:30:26 -07:00
|
|
|
"-c", Arg.Set compile_only;
|
|
|
|
"-S", Arg.Set keep_asm_file;
|
1995-07-02 09:51:07 -07:00
|
|
|
"-o", Arg.String(fun s -> exec_name := s; archive_name := s);
|
1995-09-05 05:30:26 -07:00
|
|
|
"-i", Arg.Set print_types;
|
|
|
|
"-a", Arg.Set make_archive;
|
|
|
|
"-unsafe", Arg.Set fast;
|
|
|
|
"-compact", Arg.Clear optimize_for_speed;
|
|
|
|
"-nopervasives", Arg.Set nopervasives;
|
1995-07-02 09:51:07 -07:00
|
|
|
"-ccopt", Arg.String(fun s -> ccopts := s :: !ccopts);
|
1995-09-28 10:12:42 -07:00
|
|
|
"-cclib", Arg.String(fun s -> ccobjs := s :: !ccobjs);
|
1995-09-05 05:30:26 -07:00
|
|
|
"-dlambda", Arg.Set dump_lambda;
|
|
|
|
"-dcmm", Arg.Set dump_cmm;
|
|
|
|
"-dsel", Arg.Set dump_selection;
|
1995-07-13 10:17:20 -07:00
|
|
|
"-dlive", Arg.Unit(fun () -> dump_live := true;
|
1995-07-02 09:51:07 -07:00
|
|
|
Printmach.print_live := true);
|
1995-09-05 05:30:26 -07:00
|
|
|
"-dspill", Arg.Set dump_spill;
|
|
|
|
"-dsplit", Arg.Set dump_split;
|
|
|
|
"-dinterf", Arg.Set dump_interf;
|
|
|
|
"-dprefer", Arg.Set dump_prefer;
|
|
|
|
"-dalloc", Arg.Set dump_regalloc;
|
|
|
|
"-dreload", Arg.Set dump_reload;
|
|
|
|
"-dscheduling", Arg.Set dump_scheduling;
|
|
|
|
"-dlinear", Arg.Set dump_linear;
|
|
|
|
"-dstartup", Arg.Set keep_startup_file;
|
1995-07-02 09:51:07 -07:00
|
|
|
"-v", Arg.Unit print_version_number;
|
|
|
|
"-", Arg.String process_file]
|
|
|
|
process_file;
|
|
|
|
if !make_archive then begin
|
|
|
|
Optcompile.init_path();
|
1995-07-11 11:07:53 -07:00
|
|
|
Asmlibrarian.create_archive (List.rev !objfiles) !archive_name
|
1995-07-02 09:51:07 -07:00
|
|
|
end
|
1995-07-11 11:07:53 -07:00
|
|
|
else if not !compile_only & !objfiles <> [] then begin
|
1995-07-02 09:51:07 -07:00
|
|
|
Optcompile.init_path();
|
|
|
|
Asmlink.link (List.rev !objfiles)
|
|
|
|
end;
|
|
|
|
exit 0
|
|
|
|
with x ->
|
|
|
|
Format.set_formatter_output stderr;
|
|
|
|
Opterrors.report_error x;
|
|
|
|
exit 2
|
|
|
|
|
|
|
|
let _ = Printexc.catch main ()
|