diff --git a/Makefile b/Makefile index e16e956cc6f6..3f5f333dabb9 100644 --- a/Makefile +++ b/Makefile @@ -163,6 +163,9 @@ CWARNFLAGS := -Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-declarations CDEBUGFLAGS := -std=gnu11 -g -fstack-protector CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) +# We can get configurator to run a different compile cmd to cross-configure. +CONFIGURATOR_CC := $(CC) + LDFLAGS = $(PIE_LDFLAGS) LDLIBS = -L/usr/local/lib -lm -lgmp -lsqlite3 $(COVFLAGS) @@ -263,8 +266,8 @@ ALL_PROGRAMS += ccan/ccan/cdump/tools/cdump-enumstr # Can't add to ALL_OBJS, as that makes a circular dep. ccan/ccan/cdump/tools/cdump-enumstr.o: $(CCAN_HEADERS) Makefile -ccan/config.h: ccan/tools/configurator/configurator - if $< $(CC) -static > $@.new; then mv $@.new $@; else rm $@.new; exit 1; fi +ccan/config.h: ccan/tools/configurator/configurator Makefile + if $< --configurator-cc="$(CONFIGURATOR_CC)" $(CC) $(CFLAGS) > $@.new; then mv $@.new $@; else rm $@.new; exit 1; fi gen_version.h: FORCE @(echo "#define VERSION \"`git describe --always --dirty`\"" && echo "#define VERSION_NAME \"$(NAME)\"" && echo "#define BUILD_FEATURES \"$(FEATURES)\"") > $@.new diff --git a/ccan/README b/ccan/README index 91800fde4f2b..7fa333ec8774 100644 --- a/ccan/README +++ b/ccan/README @@ -1,3 +1,3 @@ CCAN imported from http://ccodearchive.net. -CCAN version: init-2402-gec1f7161 +CCAN version: init-2403-g8502a66a diff --git a/ccan/tools/configurator/configurator.c b/ccan/tools/configurator/configurator.c index 52c0243b4b99..ff9f64904bb0 100644 --- a/ccan/tools/configurator/configurator.c +++ b/ccan/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);