5 #define CCAN_COMPILER DEFAULT_CCAN_COMPILER
8 #define CCAN_CFLAGS DEFAULT_CCAN_CFLAGS
10 const char *compiler = CCAN_COMPILER;
11 const char *cflags = CCAN_CFLAGS;
13 bool compile_verbose = false;
15 /* Compile multiple object files into a single. Returns NULL if fails. */
16 char *link_objects(const void *ctx, const char *basename,
17 const char *objs, char **errmsg)
19 char *file = temp_file(ctx, ".o", basename);
22 printf("Linking objects into %s\n", file);
24 if (run_command(ctx, NULL, errmsg, "ld -r -o %s %s", file, objs))
31 /* Compile a single C file to an object file. */
32 bool compile_object(const void *ctx, const char *cfile, const char *ccandir,
35 const char *outfile, char **output)
38 printf("Compiling %s\n", outfile);
39 return run_command(ctx, NULL, output,
40 "%s %s -I%s -c -o %s %s",
41 compiler, cflags, ccandir, outfile, cfile);
44 /* Compile and link single C file, with object files.
45 * Returns false on failure. */
46 bool compile_and_link(const void *ctx, const char *cfile, const char *ccandir,
47 const char *objs, const char *compiler,
49 const char *libs, const char *outfile, char **output)
52 printf("Compiling and linking %s\n", outfile);
53 return run_command(ctx, NULL, output,
54 "%s %s -I%s -o %s %s %s %s",
56 ccandir, outfile, cfile, objs, libs);