const char *outflag = DEFAULT_OUTPUT_EXE_FLAG;
const char *configurator_cc = NULL;
const char *orig_cc;
+ const char *varfile = NULL;
if (argc > 0)
progname = argv[0];
while (argc > 1) {
if (strcmp(argv[1], "--help") == 0) {
- printf("Usage: configurator [-v] [-O<outflag>] [--configurator-cc=<compiler-for-tests>] [<compiler> <flags>...]\n"
+ printf("Usage: configurator [-v] [--var-file=<filename>] [-O<outflag>] [--configurator-cc=<compiler-for-tests>] [<compiler> <flags>...]\n"
" <compiler> <flags> will have \"<outflag> <outfile> <infile.c>\" appended\n"
"Default: %s %s %s\n",
DEFAULT_COMPILER, DEFAULT_FLAGS,
configurator_cc = argv[1] + 18;
argc--;
argv++;
+ } else if (strncmp(argv[1], "--var-file=", 11) == 0) {
+ varfile = argv[1] + 11;
+ argc--;
+ argv++;
} else {
break;
}
remove(OUTPUT_FILE);
remove(INPUT_FILE);
+ if (varfile) {
+ FILE *vars;
+
+ if (strcmp(varfile, "-") == 0)
+ vars = stdout;
+ else {
+ vars = fopen(varfile, "a");
+ if (!vars)
+ c12r_err(2, "Could not open %s", varfile);
+ }
+ for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
+ fprintf(vars, "%s=%u\n", tests[i].name, tests[i].answer);
+ if (vars != stdout) {
+ if (fclose(vars) != 0)
+ c12r_err(2, "Closing %s", varfile);
+ }
+ }
+
printf("/* Generated by CCAN configurator */\n"
"#ifndef CCAN_CONFIG_H\n"
"#define CCAN_CONFIG_H\n");