2 #include <ccan/talloc/talloc.h>
5 bool compile_verbose = false;
7 /* Compile multiple object files into a single. Returns errmsg if fails. */
8 char *link_objects(const void *ctx, const char *objs, char **errmsg)
10 char *file = temp_file(ctx, ".o");
13 printf("Linking objects into %s\n", file);
15 *errmsg = run_command(ctx, NULL, "ld -r -o %s %s", file, objs);
23 /* Compile a single C file to an object file. Returns errmsg if fails. */
24 char *compile_object(const void *ctx, const char *cfile, const char *ccandir,
25 const char *extra_cflags,
29 printf("Compiling %s\n", outfile);
30 return run_command(ctx, NULL, "cc " CFLAGS " -I%s %s -c -o %s %s",
31 ccandir, extra_cflags, outfile, cfile);
34 /* Compile and link single C file, with object files.
35 * Returns error message or NULL on success. */
36 char *compile_and_link(const void *ctx, const char *cfile, const char *ccandir,
37 const char *objs, const char *extra_cflags,
38 const char *libs, const char *outfile)
41 printf("Compiling and linking %s\n", outfile);
42 return run_command(ctx, NULL, "cc " CFLAGS " -I%s %s -o %s %s %s %s",
43 ccandir, extra_cflags, outfile, cfile, objs, libs);