Project

General

Profile

Revision 6a078e8a src/backends/C/c_backend_makefile.ml

View differences:

src/backends/C/c_backend_makefile.ml
73 73

  
74 74
*)
75 75

  
76
let print_makefile basename nodename (dependencies:  dep_t list) fmt =
77
  fprintf fmt "GCC=gcc -O0@.";
78
  fprintf fmt "LUSTREC=%s@." Sys.executable_name;
79
  fprintf fmt "LUSTREC_BASE=%s@." (Filename.dirname (Filename.dirname Sys.executable_name));
80
  fprintf fmt "INC=${LUSTREC_BASE}/include/lustrec@.";
81
  fprintf fmt "@.";
76
  let print_makefile basename nodename (dependencies:  dep_t list) fmt =
77
    let binname =
78
      let s = basename ^ "_" ^ nodename in
79
      if String.length s > 100 (* seems that GCC fails from 144 characters and
80
				  on: File name too long collect2 ld error. *)
81
      then
82
	if String.length nodename > 100 then
83
	  basename ^ "_run" (* shorter version *)
84
	else
85
	  nodename ^ "run"
86
      else
87
	s
88
    in
89
    fprintf fmt "BINNAME?=%s@." binname;
90
    fprintf fmt "GCC=gcc -O0@.";
91
    fprintf fmt "LUSTREC=%s@." Sys.executable_name;
92
    fprintf fmt "LUSTREC_BASE=%s@." (Filename.dirname (Filename.dirname Sys.executable_name));
93
    fprintf fmt "INC=${LUSTREC_BASE}/include/lustrec@.";
94
    fprintf fmt "@.";
82 95

  
83
  (* Main binary *)
84
  fprintf fmt "%s_%s: %s.c %s_main.c@." basename "run"(*nodename*) basename basename;
85
  fprintf fmt "\t${GCC} -I${INC} -I. -c %s.c@." basename;  
86
  fprintf fmt "\t${GCC} -I${INC} -I. -c %s_main.c@." basename;   
87
  fprintf_dependencies fmt dependencies;    
88
  fprintf fmt "\t${GCC} -o %s_%s io_frontend.o %a %s.o %s_main.o %a@." basename "run"(*nodename *)
89
    (Utils.fprintf_list ~sep:" " (fun fmt (Dep (_, s, _, _)) -> Format.fprintf fmt "%s.o" s)) 
90
    (compiled_dependencies dependencies)
91
    basename (* library .o *)
92
    basename (* main function . o *) 
93
    (Utils.fprintf_list ~sep:" " (fun fmt lib -> fprintf fmt "-l%s" lib)) (lib_dependencies dependencies)
96
    (* Main binary *)
97
    fprintf fmt "%s_%s: %s.c %s_main.c@." basename "run"(*nodename*) basename basename;
98
    fprintf fmt "\t${GCC} -I${INC} -I. -c %s.c@." basename;  
99
    fprintf fmt "\t${GCC} -I${INC} -I. -c %s_main.c@." basename;   
100
    fprintf_dependencies fmt dependencies;    
101
    fprintf fmt "\t${GCC} -o ${BINNAME} io_frontend.o %a %s.o %s_main.o %a@." 
102
      (Utils.fprintf_list ~sep:" " (fun fmt (Dep (_, s, _, _)) -> Format.fprintf fmt "%s.o" s)) 
103
      (compiled_dependencies dependencies)
104
      basename (* library .o *)
105
      basename (* main function . o *) 
106
      (Utils.fprintf_list ~sep:" " (fun fmt lib -> fprintf fmt "-l%s" lib)) (lib_dependencies dependencies)
94 107
    ;
95
 fprintf fmt "@.";
96
 fprintf fmt "clean:@.";
97
 fprintf fmt "\t\\rm -f *.o %s_%s@." basename "run"(*nodename*);
98
 fprintf fmt "@.";
99
 fprintf fmt ".PHONY: %s_%s@." basename "run" (*nodename*);
100
 fprintf fmt "@.";
101
 Mod.other_targets fmt basename nodename dependencies;
102
 fprintf fmt "@.";
108
    fprintf fmt "@.";
109
    fprintf fmt "clean:@.";
110
    fprintf fmt "\t\\rm -f *.o ${BINNAME}@.";
111
    fprintf fmt "@.";
112
    Mod.other_targets fmt basename nodename dependencies;
113
    fprintf fmt "@.";
103 114

  
104 115
end
105 116

  

Also available in: Unified diff