Project

General

Profile

Revision 5c1184ad src/c_backend.ml

View differences:

src/c_backend.ml
432 432
(*                         Header Printing functions                                        *)
433 433
(********************************************************************************************)
434 434

  
435
(* Removed because of "open" constructs. No more extern functions *)
436
(*
435 437
let print_prototype fmt decl =
436 438
  match decl.top_decl_desc with
437 439
    | ImportedFun m -> (
......
455 457
      )
456 458
    )
457 459
    | _ -> () (* We don't do anything here *)
460
      *)
458 461

  
462
let print_prototype fmt decl =
463
  match decl.top_decl_desc with
464
  | Open m -> fprintf fmt "#include \"%s.h\"@," m
465
  | _ -> () (* We don't do anything here *)
466
    
459 467
let pp_registers_struct fmt m =
460 468
  if m.mmemory <> []
461 469
  then
......
762 770
	(pp_c_type_decl cpt_type var) def
763 771
    | _        -> ()) type_table
764 772

  
773
let print_makefile basename nodename fmt =
774
  fprintf fmt "GCC=gcc@.";
775
  fprintf fmt "INC=/usr/local/include/lustrec@.";
776
  fprintf fmt "@.";
777
  fprintf fmt "main:@.";
778
  fprintf fmt "\t${GCC} -I${INC} -I. -c %s.c@." basename;    
779
  fprintf fmt "\t${GCC} -I${INC} -c ${INC}/io_frontend.c@.";    
780
  fprintf fmt "\t${GCC} -I${INC} -c ${INC}/StdLibrary.c@.";
781
  fprintf fmt "\t${GCC} -o %s_%s io_frontend.o StdLibrary.o -lm %s.o@." basename nodename basename
782

  
765 783
(********************************************************************************************)
766 784
(*                         Translation function                                             *)
767 785
(********************************************************************************************)
768 786
    
769
let translate_to_c header_fmt source_fmt spec_fmt_opt basename prog machines =
787
let translate_to_c header_fmt source_fmt makefile_fmt spec_fmt_opt basename prog machines =
770 788
  (* Generating H file *)
771 789

  
772 790
  (* Include once: start *)
......
795 813
  (* Generating C file *)
796 814
  
797 815
  (* If a main node is identified, generate a main function for it *)
798
  let main_include, main_print =
816
  let main_include, main_print, main_makefile =
799 817
    match !Options.main_node with
800
      | "" -> (fun _ -> ()), (fun _ -> ())
818
      | "" -> (fun _ -> ()), (fun _ -> ()), (fun _ -> ())
801 819
      | main_node -> ( 
802 820
	let main_node_opt = 
803 821
	  List.fold_left 
......
808 826
	  None machines
809 827
      in 
810 828
      match main_node_opt with
811
	| None -> eprintf "Unable to find a main node named %s@.@?" main_node; (fun _ -> ()), (fun _ -> ())
812
	| Some m -> print_main_header, print_main_fun machines m
829
	| None -> eprintf "Unable to find a main node named %s@.@?" main_node; (fun _ -> ()), (fun _ -> ()), (fun _ -> ())
830
	| Some m -> print_main_header, print_main_fun machines m, print_makefile basename !Options.main_node
813 831
    )
814 832
  in
815 833
  main_include source_fmt;
......
829 847
  pp_print_newline source_fmt ();
830 848
  (* Print nodes one by one (in the previous order) *)
831 849
  List.iter (print_machine source_fmt) machines;
832
  main_print source_fmt
833
  
834

  
835

  
850
  main_print source_fmt;
836 851

  
852
  (* Generating Makefile *)
853
  main_makefile makefile_fmt    
837 854

  
838 855
(* Local Variables: *)
839 856
(* compile-command:"make -C .." *)

Also available in: Unified diff