Revision f76eae4f
Added by Pierre-Loïc Garoche over 7 years ago
src/backends/C/c_backend_makefile.ml | ||
---|---|---|
61 | 61 |
module Main = functor (Mod: MODIFIERS_MKF) -> |
62 | 62 |
struct |
63 | 63 |
|
64 |
(* TODO: BEWARE OF THE BUG !! in case of very long nodename or maybe even |
|
65 |
basename, the string basename_nodename exceed a limit length for files on linux |
|
66 |
and prevent gcc to generate the binary of that name. |
|
67 |
|
|
68 |
To be solved (later) with |
|
69 |
- either the default name if it short |
|
70 |
- a shorter version if it is long (md5?) |
|
71 |
- a provided name given when calling the makefile so the user can control the |
|
72 |
expected name of the binary |
|
73 |
|
|
74 |
*) |
|
64 | 75 |
|
65 | 76 |
let print_makefile basename nodename (dependencies: dep_t list) fmt = |
66 | 77 |
fprintf fmt "GCC=gcc -O0@."; |
... | ... | |
70 | 81 |
fprintf fmt "@."; |
71 | 82 |
|
72 | 83 |
(* Main binary *) |
73 |
fprintf fmt "%s_%s: %s.c %s_main.c@." basename nodename basename basename;
|
|
84 |
fprintf fmt "%s_%s: %s.c %s_main.c@." basename "run"(*nodename*) basename basename;
|
|
74 | 85 |
fprintf fmt "\t${GCC} -I${INC} -I. -c %s.c@." basename; |
75 | 86 |
fprintf fmt "\t${GCC} -I${INC} -I. -c %s_main.c@." basename; |
76 | 87 |
fprintf_dependencies fmt dependencies; |
77 |
fprintf fmt "\t${GCC} -o %s_%s io_frontend.o %a %s.o %s_main.o %a@." basename nodename
|
|
88 |
fprintf fmt "\t${GCC} -o %s_%s io_frontend.o %a %s.o %s_main.o %a@." basename "run"(*nodename *)
|
|
78 | 89 |
(Utils.fprintf_list ~sep:" " (fun fmt (Dep (_, s, _, _)) -> Format.fprintf fmt "%s.o" s)) |
79 | 90 |
(compiled_dependencies dependencies) |
80 | 91 |
basename (* library .o *) |
... | ... | |
83 | 94 |
; |
84 | 95 |
fprintf fmt "@."; |
85 | 96 |
fprintf fmt "clean:@."; |
86 |
fprintf fmt "\t\\rm -f *.o %s_%s@." basename nodename;
|
|
97 |
fprintf fmt "\t\\rm -f *.o %s_%s@." basename "run"(*nodename*);
|
|
87 | 98 |
fprintf fmt "@."; |
88 |
fprintf fmt ".PHONY: %s_%s@." basename nodename;
|
|
99 |
fprintf fmt ".PHONY: %s_%s@." basename "run" (*nodename*);
|
|
89 | 100 |
fprintf fmt "@."; |
90 | 101 |
Mod.other_targets fmt basename nodename dependencies; |
91 | 102 |
fprintf fmt "@."; |
Also available in: Unified diff
first solution to address very large identifiers in node names, logs, and generated binaries