5 #define CCAN_COMPILER DEFAULT_CCAN_COMPILER
8 #define CCAN_CFLAGS DEFAULT_CCAN_CFLAGS
10 #ifndef CCAN_OUTPUT_EXE_CFLAG
11 #define CCAN_OUTPUT_EXE_CFLAG DEFAULT_CCAN_OUTPUT_EXE_CFLAG
13 const char *compiler = CCAN_COMPILER;
14 const char *cflags = CCAN_CFLAGS;
15 const char *outexecflag = CCAN_OUTPUT_EXE_CFLAG;
17 bool compile_verbose = false;
19 /* Compile multiple object files into a single. Returns NULL if fails. */
20 char *link_objects(const void *ctx, const char *basename,
21 const char *objs, char **errmsg)
23 char *file = temp_file(ctx, ".o", basename);
26 printf("Linking objects into %s\n", file);
28 if (run_command(ctx, NULL, errmsg, "ld -r -o %s %s", file, objs))
35 /* Compile a single C file to an object file. */
36 bool compile_object(const void *ctx, const char *cfile, const char *ccandir,
39 const char *outfile, char **output)
42 printf("Compiling %s\n", outfile);
43 return run_command(ctx, NULL, output,
44 "%s %s -I%s -c %s%s %s",
45 compiler, cflags, ccandir,
46 outexecflag, outfile, cfile);
49 /* Compile and link single C file, with object files.
50 * Returns false on failure. */
51 bool compile_and_link(const void *ctx, const char *cfile, const char *ccandir,
52 const char *objs, const char *compiler,
54 const char *libs, const char *outfile, char **output)
57 printf("Compiling and linking %s\n", outfile);
58 return run_command(ctx, NULL, output,
59 "%s %s -I%s %s%s %s %s %s",
60 compiler, cflags, ccandir,
61 outexecflag, outfile, cfile, objs, libs);