X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=inline;f=tools%2Fconfigurator%2Fconfigurator.c;h=dae15446e67417ef8f02d3d07b259dbe33925963;hb=1239aa28828e86658f003ce4ef5a5fa023c42711;hp=7b2adbaa94c45f76f4eca35c71f6ab51c00100aa;hpb=5cd7a0eacf97f9e8d112223e5908dab25d7a6faa;p=ccan diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c index 7b2adbaa..dae15446 100644 --- a/tools/configurator/configurator.c +++ b/tools/configurator/configurator.c @@ -703,6 +703,8 @@ int main(int argc, const char *argv[]) const char *configurator_cc = NULL; const char *orig_cc; const char *varfile = NULL; + const char *headerfile = NULL; + FILE *outf; if (argc > 0) progname = argv[0]; @@ -746,6 +748,10 @@ int main(int argc, const char *argv[]) like_a_libtool = true; argc--; argv++; + } else if (strncmp(argv[1], "--header-file=", 14) == 0) { + headerfile = argv[1] + 14; + argc--; + argv++; } else { break; } @@ -791,21 +797,36 @@ int main(int argc, const char *argv[]) } } - printf("/* Generated by CCAN configurator */\n" + if (headerfile) { + start_test("Writing header to ", headerfile); + outf = fopen(headerfile, "w"); + if (!outf) + c12r_err(2, "Could not open %s", headerfile); + } else + outf = stdout; + + fprintf(outf, "/* Generated by CCAN configurator */\n" "#ifndef CCAN_CONFIG_H\n" "#define CCAN_CONFIG_H\n"); - printf("#ifndef _GNU_SOURCE\n"); - printf("#define _GNU_SOURCE /* Always use GNU extensions. */\n"); - printf("#endif\n"); - printf("#define CCAN_COMPILER \"%s\"\n", orig_cc); + fprintf(outf, "#ifndef _GNU_SOURCE\n"); + fprintf(outf, "#define _GNU_SOURCE /* Always use GNU extensions. */\n"); + fprintf(outf, "#endif\n"); + fprintf(outf, "#define CCAN_COMPILER \"%s\"\n", orig_cc); cmd = connect_args(argv + 1, "", ""); - printf("#define CCAN_CFLAGS \"%s\"\n", cmd); + fprintf(outf, "#define CCAN_CFLAGS \"%s\"\n", cmd); free(cmd); - printf("#define CCAN_OUTPUT_EXE_CFLAG \"%s\"\n\n", outflag); + fprintf(outf, "#define CCAN_OUTPUT_EXE_CFLAG \"%s\"\n\n", outflag); /* This one implies "#include