X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fconfigurator%2Fconfigurator.c;h=bbf7259e6b9306010b99113c98548621f33e2891;hb=8730b2e1bceff82fe9e8784ce1a671a9c12ef211;hp=eb4728462eab451a9785836b0cc7cb99b79de318;hpb=1ca32ce6d8031a30d648db54cbf0e007f0b9bca5;p=ccan diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c index eb472846..bbf7259e 100644 --- a/tools/configurator/configurator.c +++ b/tools/configurator/configurator.c @@ -146,6 +146,15 @@ static struct test tests[] = { { "HAVE_COMPOUND_LITERALS", INSIDE_MAIN, NULL, NULL, "int *foo = (int[]) { 1, 2, 3, 4 };\n" "return foo[0] ? 0 : 1;" }, + { "HAVE_FCHDIR", DEFINES_EVERYTHING|EXECUTE, NULL, NULL, + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "int main(void) {\n" + " int fd = open(\"..\", O_RDONLY);\n" + " return fchdir(fd) == 0 ? 0 : 1;\n" + "}\n" }, { "HAVE_ERR_H", DEFINES_FUNC, NULL, NULL, "#include \n" "static void func(int arg) {\n" @@ -331,7 +340,8 @@ static char *connect_args(const char *argv[], const char *extra) for (i = 1; argv[i]; i++) { strcpy(ret + len, argv[i]); len += strlen(argv[i]); - ret[len++] = ' '; + if (argv[i+1]) + ret[len++] = ' '; } strcpy(ret + len, extra); return ret; @@ -497,14 +507,13 @@ int main(int argc, const char *argv[]) if (argc == 1) argv = default_args; - cmd = connect_args(argv, "-o " OUTPUT_FILE " " INPUT_FILE); + cmd = connect_args(argv, " -o " OUTPUT_FILE " " INPUT_FILE); for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) run_test(cmd, &tests[i]); unlink(OUTPUT_FILE); unlink(INPUT_FILE); - cmd[strlen(cmd) - strlen(" -o " OUTPUT_FILE " " INPUT_FILE)] = '\0'; printf("/* Generated by CCAN configurator */\n" "#ifndef CCAN_CONFIG_H\n" "#define CCAN_CONFIG_H\n"); @@ -512,7 +521,7 @@ int main(int argc, const char *argv[]) printf("#define _GNU_SOURCE /* Always use GNU extensions. */\n"); printf("#endif\n"); printf("#define CCAN_COMPILER \"%s\"\n", argv[1]); - printf("#define CCAN_CFLAGS \"%s\"\n\n", cmd + strlen(argv[1]) + 1); + printf("#define CCAN_CFLAGS \"%s\"\n\n", connect_args(argv+1, "")); /* This one implies "#include