2 #include <ccan/talloc/talloc.h>
5 bool compile_verbose = false;
7 /* Compile multiple object files into a single. Returns NULL if fails. */
8 char *link_objects(const void *ctx, const char *basename, bool in_pwd,
9 const char *objs, char **errmsg)
11 char *file = maybe_temp_file(ctx, ".o", in_pwd, basename);
14 printf("Linking objects into %s\n", file);
16 if (run_command(ctx, NULL, errmsg, "ld -r -o %s %s", file, objs))
23 /* Compile a single C file to an object file. */
24 bool compile_object(const void *ctx, const char *cfile, const char *ccandir,
25 const char *extra_cflags,
26 const char *outfile, char **output)
29 printf("Compiling %s\n", outfile);
30 return run_command(ctx, NULL, output, CCAN_COMPILER " " CCAN_CFLAGS
31 " -I%s %s -c -o %s %s",
32 ccandir, extra_cflags, outfile, cfile);
35 /* Compile and link single C file, with object files.
36 * Returns false on failure. */
37 bool compile_and_link(const void *ctx, const char *cfile, const char *ccandir,
38 const char *objs, const char *extra_cflags,
39 const char *libs, const char *outfile, char **output)
42 printf("Compiling and linking %s\n", outfile);
43 return run_command(ctx, NULL, output, CCAN_COMPILER " " CCAN_CFLAGS
44 " -I%s %s -o %s %s %s %s",
45 ccandir, extra_cflags, outfile, cfile, objs, libs);