Re: How to get autoconf to respect CC="gcc -std=c89"?

Niels Möller <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.general,gmane.comp.sysutils.autoconf.patches
Message-ID <[email protected]>
Niels Möller <[email protected]> writes:

> "Zack Weinberg" <[email protected]> writes:
>
>> This is currently not possible, but you are not the only person who has
>> asked for it to be made possible, and it's on our near-future list.
>> However, none of the core Autoconf developers currently have time to work
>> on it.  Might you be willing to put some time into it? 
>
> I can have a look; I would hope it's not too difficult (I'm familiar
> with m4 and sh programming, but not with autoconf-specifics, like how
> AC_REQUIRE/AC_PROVIDE really works). I think this is the right piece of
> code that needs a bit of configurability, in lib/autoconf/c.m4:
>
>   AC_DEFUN([_AC_PROG_CC_STDC_EDITION],
>   [ac_prog_cc_stdc=no
>   m4_map([_AC_PROG_CC_STDC_EDITION_TRY], [[11], [99], [89]])])

Below is an initial patch, it seems to work with a little manual
testing, and it does the simplest thing I could come up with. No idea
how proper tests should be done. Cc:ing autoconf-patches, since
README-hacking says that's the right forum.

Is this on the right track?

Regards,
/Niels

diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 77ff1af8..83eb4bea 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -1561,6 +1561,14 @@ m4_define([_AC_C_C11_OPTIONS], [
     -std=gnu11
 ])
 
+AC_DEFUN([AC_C_STANDARD_VERSION], [
+  m4_ifdef([_AC_C_STANDARD_VERSION_LIST],
+    [m4_fatal([AC_PROG_C_STANDARD_VERSION should only be used once], 1)])
+  m4_define([_AC_C_STANDARD_VERSION_LIST],
+    m4_if([$1], [c89], 89, [$1], [c99], 99, [$1], [c11], 11,
+      [$1], [], [m4_fatal([C language revision not specified], 1)],
+      [m4_fatal([Unknown C language revision $1], 1)]))
+])
 
 # _AC_PROG_CC_STDC_EDITION_TRY(EDITION)
 # -------------------------------------
@@ -1623,7 +1631,9 @@ AS_IF([test "x$ac_cv_prog_cc_c$1" = xno],
 # variable ac_prog_cc_stdc to indicate the edition.
 AC_DEFUN([_AC_PROG_CC_STDC_EDITION],
 [ac_prog_cc_stdc=no
-m4_map([_AC_PROG_CC_STDC_EDITION_TRY], [[11], [99], [89]])])
+m4_ifndef([_AC_C_STANDARD_VERSION_LIST],
+  [m4_define([_AC_C_STANDARD_VERSION_LIST], [[11], [99], [89]])])
+m4_map([_AC_PROG_CC_STDC_EDITION_TRY], [_AC_C_STANDARD_VERSION_LIST])])
 
 
 # _AC_PROG_CC_C89(ACTION-IF-SUPPORTED, ACTION-IF-NOT-SUPPORTED)

-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.