From: Rusty Russell Date: Mon, 26 Feb 2018 02:26:18 +0000 (+1030) Subject: tools/configurator: allow overriding of which cc we will run. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=8502a66a5ba8916758c67ea5b0b404386c34da24 tools/configurator: allow overriding of which cc we will run. This is for cross-configuring, where we might want to run `qemu-user-... gcc` or even more exotic things. Signed-off-by: Rusty Russell --- diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c index 52c0243b..ff9f6490 100644 --- a/tools/configurator/configurator.c +++ b/tools/configurator/configurator.c @@ -670,13 +670,15 @@ int main(int argc, const char *argv[]) const char *default_args[] = { "", DEFAULT_COMPILER, DEFAULT_FLAGS, NULL }; const char *outflag = DEFAULT_OUTPUT_EXE_FLAG; + const char *configurator_cc = NULL; + const char *orig_cc; if (argc > 0) progname = argv[0]; while (argc > 1) { if (strcmp(argv[1], "--help") == 0) { - printf("Usage: configurator [-v] [-O] [ ...]\n" + printf("Usage: configurator [-v] [-O] [--configurator-cc=] [ ...]\n" " will have \" \" appended\n" "Default: %s %s %s\n", DEFAULT_COMPILER, DEFAULT_FLAGS, @@ -701,6 +703,10 @@ int main(int argc, const char *argv[]) argc--; argv++; verbose += 2; + } else if (strncmp(argv[1], "--configurator-cc=", 18) == 0) { + configurator_cc = argv[1] + 18; + argc--; + argv++; } else { break; } @@ -709,6 +715,10 @@ int main(int argc, const char *argv[]) if (argc == 1) argv = default_args; + orig_cc = argv[1]; + if (configurator_cc) + argv[1] = configurator_cc; + cmd = connect_args(argv, outflag, OUTPUT_FILE " " INPUT_FILE); for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) run_test(cmd, &tests[i]); @@ -723,7 +733,7 @@ int main(int argc, const char *argv[]) printf("#ifndef _GNU_SOURCE\n"); printf("#define _GNU_SOURCE /* Always use GNU extensions. */\n"); printf("#endif\n"); - printf("#define CCAN_COMPILER \"%s\"\n", argv[1]); + printf("#define CCAN_COMPILER \"%s\"\n", orig_cc); cmd = connect_args(argv + 1, "", ""); printf("#define CCAN_CFLAGS \"%s\"\n", cmd); free(cmd);