1 /* Simple tool to create config.h.
2 * Would be much easier with ccan modules, but deliberately standalone.
4 * Copyright 2011 Rusty Russell <rusty@rustcorp.com.au>. MIT license.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 #define _POSIX_C_SOURCE 200809L /* For pclose, popen, strdup */
34 #define pclose _pclose
37 #define DEFAULT_COMPILER "cc"
38 #define DEFAULT_FLAGS "-g3 -ggdb -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition"
40 #define OUTPUT_FILE "configurator.out"
41 #define INPUT_FILE "configuratortest.c"
55 DEFINES_EVERYTHING = 0x8,
56 MAY_NOT_COMPILE = 0x10,
62 enum test_style style;
67 const char *overrides; /* On success, force this to '1' */
72 static struct test tests[] = {
73 { "HAVE_32BIT_OFF_T", DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE, NULL, NULL,
74 "#include <sys/types.h>\n"
76 " return sizeof(off_t) == 4 ? 0 : 1;\n"
78 { "HAVE_ALIGNOF", INSIDE_MAIN, NULL, NULL,
79 "return __alignof__(double) > 0 ? 0 : 1;" },
80 { "HAVE_ASPRINTF", DEFINES_FUNC, NULL, NULL,
81 "#ifndef _GNU_SOURCE\n"
82 "#define _GNU_SOURCE\n"
84 "#include <stdio.h>\n"
85 "static char *func(int x) {"
87 " if (asprintf(&p, \"%u\", x) == -1) p = NULL;"
90 { "HAVE_ATTRIBUTE_COLD", DEFINES_FUNC, NULL, NULL,
91 "static int __attribute__((cold)) func(int x) { return x; }" },
92 { "HAVE_ATTRIBUTE_CONST", DEFINES_FUNC, NULL, NULL,
93 "static int __attribute__((const)) func(int x) { return x; }" },
94 { "HAVE_ATTRIBUTE_PURE", DEFINES_FUNC, NULL, NULL,
95 "static int __attribute__((pure)) func(int x) { return x; }" },
96 { "HAVE_ATTRIBUTE_MAY_ALIAS", OUTSIDE_MAIN, NULL, NULL,
97 "typedef short __attribute__((__may_alias__)) short_a;" },
98 { "HAVE_ATTRIBUTE_NORETURN", DEFINES_FUNC, NULL, NULL,
99 "#include <stdlib.h>\n"
100 "static void __attribute__((noreturn)) func(int x) { exit(x); }" },
101 { "HAVE_ATTRIBUTE_PRINTF", DEFINES_FUNC, NULL, NULL,
102 "static void __attribute__((format(__printf__, 1, 2))) func(const char *fmt, ...) { (void)fmt; }" },
103 { "HAVE_ATTRIBUTE_UNUSED", OUTSIDE_MAIN, NULL, NULL,
104 "static int __attribute__((unused)) func(int x) { return x; }" },
105 { "HAVE_ATTRIBUTE_USED", OUTSIDE_MAIN, NULL, NULL,
106 "static int __attribute__((used)) func(int x) { return x; }" },
107 { "HAVE_BACKTRACE", DEFINES_FUNC, NULL, NULL,
108 "#include <execinfo.h>\n"
109 "static int func(int x) {"
111 " return backtrace(bt, 10) < x;\n"
113 { "HAVE_BIG_ENDIAN", INSIDE_MAIN|EXECUTE, NULL, NULL,
114 "union { int i; char c[sizeof(int)]; } u;\n"
115 "u.i = 0x01020304;\n"
116 "return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;" },
117 { "HAVE_BSWAP_64", DEFINES_FUNC, "HAVE_BYTESWAP_H", NULL,
118 "#include <byteswap.h>\n"
119 "static int func(int x) { return bswap_64(x); }" },
120 { "HAVE_BUILTIN_CHOOSE_EXPR", INSIDE_MAIN, NULL, NULL,
121 "return __builtin_choose_expr(1, 0, \"garbage\");" },
122 { "HAVE_BUILTIN_CLZ", INSIDE_MAIN, NULL, NULL,
123 "return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;" },
124 { "HAVE_BUILTIN_CLZL", INSIDE_MAIN, NULL, NULL,
125 "return __builtin_clzl(1) == (sizeof(long)*8 - 1) ? 0 : 1;" },
126 { "HAVE_BUILTIN_CLZLL", INSIDE_MAIN, NULL, NULL,
127 "return __builtin_clzll(1) == (sizeof(long long)*8 - 1) ? 0 : 1;" },
128 { "HAVE_BUILTIN_CTZ", INSIDE_MAIN, NULL, NULL,
129 "return __builtin_ctz(1 << (sizeof(int)*8 - 1)) == (sizeof(int)*8 - 1) ? 0 : 1;" },
130 { "HAVE_BUILTIN_CTZL", INSIDE_MAIN, NULL, NULL,
131 "return __builtin_ctzl(1UL << (sizeof(long)*8 - 1)) == (sizeof(long)*8 - 1) ? 0 : 1;" },
132 { "HAVE_BUILTIN_CTZLL", INSIDE_MAIN, NULL, NULL,
133 "return __builtin_ctzll(1ULL << (sizeof(long long)*8 - 1)) == (sizeof(long long)*8 - 1) ? 0 : 1;" },
134 { "HAVE_BUILTIN_CONSTANT_P", INSIDE_MAIN, NULL, NULL,
135 "return __builtin_constant_p(1) ? 0 : 1;" },
136 { "HAVE_BUILTIN_EXPECT", INSIDE_MAIN, NULL, NULL,
137 "return __builtin_expect(argc == 1, 1) ? 0 : 1;" },
138 { "HAVE_BUILTIN_FFS", INSIDE_MAIN, NULL, NULL,
139 "return __builtin_ffs(0) == 0 ? 0 : 1;" },
140 { "HAVE_BUILTIN_FFSL", INSIDE_MAIN, NULL, NULL,
141 "return __builtin_ffsl(0L) == 0 ? 0 : 1;" },
142 { "HAVE_BUILTIN_FFSLL", INSIDE_MAIN, NULL, NULL,
143 "return __builtin_ffsll(0LL) == 0 ? 0 : 1;" },
144 { "HAVE_BUILTIN_POPCOUNTL", INSIDE_MAIN, NULL, NULL,
145 "return __builtin_popcountl(255L) == 8 ? 0 : 1;" },
146 { "HAVE_BUILTIN_TYPES_COMPATIBLE_P", INSIDE_MAIN, NULL, NULL,
147 "return __builtin_types_compatible_p(char *, int) ? 1 : 0;" },
148 { "HAVE_ICCARM_INTRINSICS", DEFINES_FUNC, NULL, NULL,
149 "#include <intrinsics.h>\n"
150 "int func(int v) {\n"
151 " return __CLZ(__RBIT(v));\n"
153 { "HAVE_BYTESWAP_H", OUTSIDE_MAIN, NULL, NULL,
154 "#include <byteswap.h>\n" },
155 { "HAVE_CLOCK_GETTIME",
156 DEFINES_FUNC, "HAVE_STRUCT_TIMESPEC", NULL,
157 "#include <time.h>\n"
158 "static struct timespec func(void) {\n"
159 " struct timespec ts;\n"
160 " clock_gettime(CLOCK_REALTIME, &ts);\n"
163 { "HAVE_CLOCK_GETTIME_IN_LIBRT",
165 "HAVE_STRUCT_TIMESPEC !HAVE_CLOCK_GETTIME",
167 "#include <time.h>\n"
168 "static struct timespec func(void) {\n"
169 " struct timespec ts;\n"
170 " clock_gettime(CLOCK_REALTIME, &ts);\n"
173 /* This means HAVE_CLOCK_GETTIME, too */
174 "HAVE_CLOCK_GETTIME" },
175 { "HAVE_COMPOUND_LITERALS", INSIDE_MAIN, NULL, NULL,
176 "int *foo = (int[]) { 1, 2, 3, 4 };\n"
177 "return foo[0] ? 0 : 1;" },
178 { "HAVE_FCHDIR", DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE, NULL, NULL,
179 "#include <sys/types.h>\n"
180 "#include <sys/stat.h>\n"
181 "#include <fcntl.h>\n"
182 "#include <unistd.h>\n"
184 " int fd = open(\"..\", O_RDONLY);\n"
185 " return fchdir(fd) == 0 ? 0 : 1;\n"
187 { "HAVE_ERR_H", DEFINES_FUNC, NULL, NULL,
189 "static void func(int arg) {\n"
191 " err(1, \"err %u\", arg);\n"
193 " errx(1, \"err %u\", arg);\n"
195 " warn(\"warn %u\", arg);\n"
197 " warnx(\"warn %u\", arg);\n"
199 { "HAVE_FILE_OFFSET_BITS", DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE,
200 "HAVE_32BIT_OFF_T", NULL,
201 "#define _FILE_OFFSET_BITS 64\n"
202 "#include <sys/types.h>\n"
204 " return sizeof(off_t) == 8 ? 0 : 1;\n"
206 { "HAVE_FOR_LOOP_DECLARATION", INSIDE_MAIN, NULL, NULL,
208 "for (int i = 0; i < argc; i++) { ret = 0; };\n"
210 { "HAVE_FLEXIBLE_ARRAY_MEMBER", OUTSIDE_MAIN, NULL, NULL,
211 "struct foo { unsigned int x; int arr[]; };" },
212 { "HAVE_GETPAGESIZE", DEFINES_FUNC, NULL, NULL,
213 "#include <unistd.h>\n"
214 "static int func(void) { return getpagesize(); }" },
215 { "HAVE_ISBLANK", DEFINES_FUNC, NULL, NULL,
216 "#ifndef _GNU_SOURCE\n"
217 "#define _GNU_SOURCE\n"
219 "#include <ctype.h>\n"
220 "static int func(void) { return isblank(' '); }" },
221 { "HAVE_LITTLE_ENDIAN", INSIDE_MAIN|EXECUTE, NULL, NULL,
222 "union { int i; char c[sizeof(int)]; } u;\n"
223 "u.i = 0x01020304;\n"
224 "return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;" },
225 { "HAVE_MEMMEM", DEFINES_FUNC, NULL, NULL,
226 "#ifndef _GNU_SOURCE\n"
227 "#define _GNU_SOURCE\n"
229 "#include <string.h>\n"
230 "static void *func(void *h, size_t hl, void *n, size_t nl) {\n"
231 "return memmem(h, hl, n, nl);"
233 { "HAVE_MEMRCHR", DEFINES_FUNC, NULL, NULL,
234 "#ifndef _GNU_SOURCE\n"
235 "#define _GNU_SOURCE\n"
237 "#include <string.h>\n"
238 "static void *func(void *s, int c, size_t n) {\n"
239 "return memrchr(s, c, n);"
241 { "HAVE_MMAP", DEFINES_FUNC, NULL, NULL,
242 "#include <sys/mman.h>\n"
243 "static void *func(int fd) {\n"
244 " return mmap(0, 65536, PROT_READ, MAP_SHARED, fd, 0);\n"
246 { "HAVE_PROC_SELF_MAPS", DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE, NULL, NULL,
247 "#include <sys/types.h>\n"
248 "#include <sys/stat.h>\n"
249 "#include <fcntl.h>\n"
251 " return open(\"/proc/self/maps\", O_RDONLY) != -1 ? 0 : 1;\n"
253 { "HAVE_QSORT_R_PRIVATE_LAST",
254 DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE, NULL, NULL,
255 "#ifndef _GNU_SOURCE\n"
256 "#define _GNU_SOURCE\n"
258 "#include <stdlib.h>\n"
259 "static int cmp(const void *lp, const void *rp, void *priv) {\n"
260 " *(unsigned int *)priv = 1;\n"
261 " return *(const int *)lp - *(const int *)rp; }\n"
263 " int array[] = { 9, 2, 5 };\n"
264 " unsigned int called = 0;\n"
265 " qsort_r(array, 3, sizeof(int), cmp, &called);\n"
266 " return called && array[0] == 2 && array[1] == 5 && array[2] == 9 ? 0 : 1;\n"
268 { "HAVE_STRUCT_TIMESPEC",
269 DEFINES_FUNC, NULL, NULL,
270 "#include <time.h>\n"
271 "static void func(void) {\n"
272 " struct timespec ts;\n"
273 " ts.tv_sec = ts.tv_nsec = 1;\n"
275 { "HAVE_SECTION_START_STOP",
276 DEFINES_FUNC, NULL, NULL,
277 "static void *__attribute__((__section__(\"mysec\"))) p = &p;\n"
278 "static int func(void) {\n"
279 " extern void *__start_mysec[], *__stop_mysec[];\n"
280 " return __stop_mysec - __start_mysec;\n"
282 { "HAVE_STACK_GROWS_UPWARDS", DEFINES_EVERYTHING|EXECUTE, NULL, NULL,
283 "#include <stddef.h>\n"
284 "static ptrdiff_t nest(const void *base, unsigned int i)\n"
287 " return (const char *)&i - (const char *)base;\n"
288 " return nest(base, i-1);\n"
290 "int main(int argc, char *argv[]) {\n"
292 " return (nest(&argc, argc) > 0) ? 0 : 1;\n"
294 { "HAVE_STATEMENT_EXPR", INSIDE_MAIN, NULL, NULL,
295 "return ({ int x = argc; x == argc ? 0 : 1; });" },
296 { "HAVE_SYS_FILIO_H", OUTSIDE_MAIN, NULL, NULL, /* Solaris needs this for FIONREAD */
297 "#include <sys/filio.h>\n" },
298 { "HAVE_SYS_TERMIOS_H", OUTSIDE_MAIN, NULL, NULL,
299 "#include <sys/termios.h>\n" },
300 { "HAVE_TYPEOF", INSIDE_MAIN, NULL, NULL,
301 "__typeof__(argc) i; i = argc; return i == argc ? 0 : 1;" },
302 { "HAVE_UNALIGNED_ACCESS", DEFINES_EVERYTHING|EXECUTE, NULL, NULL,
303 "#include <string.h>\n"
304 "int main(int argc, char *argv[]) {\n"
306 " char pad[sizeof(int *) * 1];\n"
307 " strncpy(pad, argv[0], sizeof(pad));\n"
308 " int *x = (int *)pad, *y = (int *)(pad + 1);\n"
309 " return *x == *y;\n"
311 { "HAVE_UTIME", DEFINES_FUNC, NULL, NULL,
312 "#include <sys/types.h>\n"
313 "#include <utime.h>\n"
314 "static int func(const char *filename) {\n"
315 " struct utimbuf times = { 0 };\n"
316 " return utime(filename, ×);\n"
318 { "HAVE_WARN_UNUSED_RESULT", DEFINES_FUNC, NULL, NULL,
319 "#include <sys/types.h>\n"
320 "#include <utime.h>\n"
321 "static __attribute__((warn_unused_result)) int func(int i) {\n"
324 { "HAVE_OPENMP", INSIDE_MAIN, NULL, NULL,
326 "#pragma omp parallel for\n"
327 "for(i = 0; i < 0; i++) {};\n"
329 "-Werror -fopenmp" },
330 { "HAVE_VALGRIND_MEMCHECK_H", OUTSIDE_MAIN, NULL, NULL,
331 "#include <valgrind/memcheck.h>\n" },
332 { "HAVE_UCONTEXT", DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE,
334 "#include <ucontext.h>\n"
335 "static int x = 0;\n"
336 "static char stack[2048];\n"
337 "static ucontext_t a, b;\n"
338 "static void fn(void) {\n"
346 " a.uc_stack.ss_sp = stack;\n"
347 " a.uc_stack.ss_size = sizeof(stack);\n"
348 " makecontext(&a, fn, 0);\n"
349 " swapcontext(&b, &a);\n"
350 " return (x == 3) ? 0 : 1;\n"
353 { "HAVE_POINTER_SAFE_MAKECONTEXT", DEFINES_EVERYTHING|EXECUTE|MAY_NOT_COMPILE,
354 "HAVE_UCONTEXT", NULL,
355 "#include <stddef.h>\n"
356 "#include <ucontext.h>\n"
357 "static int worked = 0;\n"
358 "static char stack[1024];\n"
359 "static ucontext_t a, b;\n"
360 "static void fn(void *p, void *q) {\n"
361 " void *cp = &worked;\n"
362 " void *cq = (void *)(~((ptrdiff_t)cp));\n"
363 " if ((p == cp) && (q == cq))\n"
368 " void *ap = &worked;\n"
369 " void *aq = (void *)(~((ptrdiff_t)ap));\n"
371 " a.uc_stack.ss_sp = stack;\n"
372 " a.uc_stack.ss_size = sizeof(stack);\n"
373 " makecontext(&a, (void (*)(void))fn, 2, ap, aq);\n"
374 " swapcontext(&b, &a);\n"
375 " return worked ? 0 : 1;\n"
380 static char *grab_stream(FILE *file)
382 size_t max, ret, size = 0;
386 buffer = malloc(max);
387 while ((ret = fread(buffer+size, 1, max - size, file)) == max - size) {
389 buffer = realloc(buffer, max *= 2);
393 err(1, "reading from command");
398 static char *run(const char *cmd, int *exitstatus)
400 static const char redir[] = " 2>&1";
406 cmdlen = strlen(cmd);
407 cmdredir = malloc(cmdlen + sizeof(redir));
408 memcpy(cmdredir, cmd, cmdlen);
409 memcpy(cmdredir + cmdlen, redir, sizeof(redir));
411 cmdout = popen(cmdredir, "r");
413 err(1, "popen \"%s\"", cmdredir);
417 ret = grab_stream(cmdout);
418 *exitstatus = pclose(cmdout);
422 static char *connect_args(const char *argv[], const char *extra)
424 unsigned int i, len = strlen(extra) + 1;
427 for (i = 1; argv[i]; i++)
428 len += 1 + strlen(argv[i]);
432 for (i = 1; argv[i]; i++) {
433 strcpy(ret + len, argv[i]);
434 len += strlen(argv[i]);
438 strcpy(ret + len, extra);
442 static struct test *find_test(const char *name)
446 for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
447 if (strcmp(tests[i].name, name) == 0)
453 #define PRE_BOILERPLATE "/* Test program generated by configurator. */\n"
454 #define MAIN_START_BOILERPLATE \
455 "int main(int argc, char *argv[]) {\n" \
458 #define USE_FUNC_BOILERPLATE "(void)func;\n"
459 #define MAIN_BODY_BOILERPLATE "return 0;\n"
460 #define MAIN_END_BOILERPLATE "}\n"
462 static bool run_test(const char *cmd, struct test *test)
464 char *output, *newcmd;
473 const char *deps = test->depends;
476 /* Space-separated dependencies, could be ! for inverse. */
477 while ((len = strcspn(deps, " ")) != 0) {
478 bool positive = true;
490 if (run_test(cmd, find_test(dep)) != positive) {
491 test->answer = false;
499 deps += strspn(deps, " ");
503 outf = fopen(INPUT_FILE, "w");
505 err(1, "creating %s", INPUT_FILE);
507 fprintf(outf, "%s", PRE_BOILERPLATE);
508 switch (test->style & ~(EXECUTE|MAY_NOT_COMPILE)) {
510 fprintf(outf, "%s", MAIN_START_BOILERPLATE);
511 fprintf(outf, "%s", test->fragment);
512 fprintf(outf, "%s", MAIN_END_BOILERPLATE);
515 fprintf(outf, "%s", test->fragment);
516 fprintf(outf, "%s", MAIN_START_BOILERPLATE);
517 fprintf(outf, "%s", MAIN_BODY_BOILERPLATE);
518 fprintf(outf, "%s", MAIN_END_BOILERPLATE);
521 fprintf(outf, "%s", test->fragment);
522 fprintf(outf, "%s", MAIN_START_BOILERPLATE);
523 fprintf(outf, "%s", USE_FUNC_BOILERPLATE);
524 fprintf(outf, "%s", MAIN_BODY_BOILERPLATE);
525 fprintf(outf, "%s", MAIN_END_BOILERPLATE);
527 case DEFINES_EVERYTHING:
528 fprintf(outf, "%s", test->fragment);
537 if (system("cat " INPUT_FILE) == -1)
540 newcmd = strdup(cmd);
543 newcmd = realloc(newcmd, strlen(newcmd) + strlen(" ")
544 + strlen(test->flags) + 1);
546 strcat(newcmd, test->flags);
548 printf("Extra flags line: %s", newcmd);
552 newcmd = realloc(newcmd, strlen(newcmd) + strlen(" ")
553 + strlen(test->link) + 1);
555 strcat(newcmd, test->link);
557 printf("Extra link line: %s", newcmd);
560 output = run(newcmd, &status);
564 if (status != 0 || strstr(output, "warning")) {
566 printf("Compile %s for %s, status %i: %s\n",
567 status ? "fail" : "warning",
568 test->name, status, output);
569 if ((test->style & EXECUTE) && !(test->style & MAY_NOT_COMPILE))
570 errx(1, "Test for %s did not compile:\n%s",
572 test->answer = false;
575 /* Compile succeeded. */
577 /* We run INSIDE_MAIN tests for sanity checking. */
578 if ((test->style & EXECUTE) || (test->style & INSIDE_MAIN)) {
579 output = run("." DIR_SEP OUTPUT_FILE, &status);
580 if (!(test->style & EXECUTE) && status != 0)
581 errx(1, "Test for %s failed with %i:\n%s",
582 test->name, status, output);
583 if (verbose && status)
584 printf("%s exited %i\n", test->name, status);
587 test->answer = (status == 0);
591 if (test->answer && test->overrides) {
592 struct test *override = find_test(test->overrides);
593 override->done = true;
594 override->answer = true;
599 int main(int argc, const char *argv[])
603 const char *default_args[]
604 = { "", DEFAULT_COMPILER, DEFAULT_FLAGS, NULL };
607 if (strcmp(argv[1], "--help") == 0) {
608 printf("Usage: configurator [-v] [<compiler> <flags>...]\n"
609 " <compiler> <flags> will have \"-o <outfile> <infile.c>\" appended\n"
611 DEFAULT_COMPILER, DEFAULT_FLAGS);
614 if (strcmp(argv[1], "-v") == 0) {
618 } else if (strcmp(argv[1], "-vv") == 0) {
628 cmd = connect_args(argv, " -o " OUTPUT_FILE " " INPUT_FILE);
629 for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
630 run_test(cmd, &tests[i]);
636 printf("/* Generated by CCAN configurator */\n"
637 "#ifndef CCAN_CONFIG_H\n"
638 "#define CCAN_CONFIG_H\n");
639 printf("#ifndef _GNU_SOURCE\n");
640 printf("#define _GNU_SOURCE /* Always use GNU extensions. */\n");
642 printf("#define CCAN_COMPILER \"%s\"\n", argv[1]);
643 cmd = connect_args(argv+1, "");
644 printf("#define CCAN_CFLAGS \"%s\"\n\n", cmd);
646 /* This one implies "#include <ccan/..." works, eg. for tdb2.h */
647 printf("#define HAVE_CCAN 1\n");
648 for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++)
649 printf("#define %s %u\n", tests[i].name, tests[i].answer);
650 printf("#endif /* CCAN_CONFIG_H */\n");