• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revisão4209 (tree)
Hora2022-10-01 21:31:43
Autormagicant

Mensagem de Log

configure: add -std=c99 conditionally (#45739)

Many users seem to try to override the default CC and/or CFLAGS without
knowing the effect of what they are doing. Our build configuration needs
a confirming C99 compiler, which may require a specific option to select
the language version. This commit adds a dynamic test that makes sure
the compiler is invoked with appropriate options.

Mudança Sumário

Diff

--- yash/trunk/configure (revision 4208)
+++ yash/trunk/configure (revision 4209)
@@ -395,7 +395,7 @@
395395 # define options for debugging
396396 if ${debug}
397397 then
398- cc="${CC-gcc -std=c99}"
398+ cc="${CC-gcc}"
399399 cflags="${CFLAGS--pedantic -MMD -Wall -Wextra -O1 -fno-inline -ggdb}"
400400 else
401401 defconfigh "NDEBUG"
@@ -413,12 +413,12 @@
413413 checked "yes"
414414 elif
415415 [ x"${cc}" = x"c99" ] && [ x"${CC+set}" != x"set" ] && (
416- cc='gcc -std=c99'
416+ cc='gcc'
417417 trymake && tryexec
418418 )
419419 then
420- checked "yes (using gcc -std=c99)"
421- cc='gcc -std=c99'
420+ checked "yes (using gcc)"
421+ cc='gcc'
422422 else
423423 checked "no"
424424 printf 'Compiler "%s" not found or not working.\n' "${CC-${cc}}" >&2
@@ -447,6 +447,36 @@
447447 unset savecflags
448448 fi
449449
450+# find compiler option for C99 support
451+checking 'additional option to compile C99 code'
452+cat >"${tempsrc}" <<END
453+int main(int argc, char **argv) {
454+if (argc == 0) return 0;
455+int vla[argc];
456+vla[0] = 42;
457+// one-line comment
458+struct s { int v; } i = { .v = argv[0][0] };
459+return vla[0] + i.v;
460+}
461+END
462+if
463+ trycompile
464+then
465+ checked "none needed"
466+elif
467+ [ x"${CFLAGS+set}" != x"set" ] &&
468+ cflags="${cflags} -std=c99" &&
469+ trycompile
470+then
471+ checked "with -std=c99"
472+else
473+ checked "failed"
474+ printf 'Compiler "%s" does not seem to support C99.\n' "${CC-${cc}}" >&2
475+ printf 'The compiler was tested with these options: %s\n' \
476+ "${CFLAGS-${cflags}} ${CADDS-${null}}" >&2
477+ fail
478+fi
479+
450480 # check if make supports include statements
451481 checking 'whether make supports include statements'
452482 if
Show on old repository browser