[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: warning: module to simplify adding compiler warnings
From: |
Paolo Bonzini |
Subject: |
Re: warning: module to simplify adding compiler warnings |
Date: |
Tue, 11 Nov 2008 12:05:02 +0100 |
User-agent: |
Thunderbird 2.0.0.17 (Macintosh/20080914) |
>> I can do the change, or you can do it; as you prefer. In any case if
>> you pushdef you'd better popdef too. :-)
>
> Please apply your change and I'll test whether it works for me.
Here it is. I also added a second argument to choose the destination
variable instead of hardcoding it to WARN_CFLAGS.
Unfortunately some AS_* macros have to be redefined for backwards
compatibility. If it was not for that, the rewrite would have the same
number of lines as your version. :-)
By the way, I just noticed an (unused?) warning.m4 file. Ok to delete it?
Paolo
diff --git a/m4/warnings.m4 b/m4/warnings.m4
index 594ff97..634b183 100644
--- a/m4/warnings.m4
+++ b/m4/warnings.m4
@@ -13,22 +13,38 @@ AC_DEFUN([gl_WARN_INIT],
AC_ARG_VAR(WARN_CFLAGS, [C compiler warning flags])
])
-# gl_WARN_ADD([parameter]) adds parameter to WARN_CFLAGS if compiler
-# supports it. For example, use gl_WARN_ADD([-Werror]).
-AC_DEFUN([gl_WARN_ADD],
-[
- pushdef([param],[translit([$1],[ABCDEFGHIJKLMNOPQRSTUVWXYZ./-],
- [abcdefghijklmnopqrstuvwxyz___])])
+# gl_AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
+# ----------------------------------------------------
+# Provide the functionality of AS_VAR_IF if Autoconf does not have it.
+m4_ifdef([AS_VAR_IF],
+[m4_copy([AS_VAR_IF], [gl_AS_VAR_IF])],
+[m4_define([gl_AS_VAR_IF],
+[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
- AC_CACHE_CHECK([whether compiler handles $1], [gl_cv_warn[]param[]], [
- save_CFLAGS="$CFLAGS"
- CFLAGS="${CFLAGS} $1"
- AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
- gl_cv_warn[]param=yes, gl_cv_warn[]param=no)
- CFLAGS="$save_CFLAGS"
- ])
+# gl_AS_VAR_APPEND(VAR, VALUE)
+# ----------------------------
+# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
+m4_ifdef([AS_VAR_APPEND],
+[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
+[m4_define([gl_AS_VAR_APPEND],
+[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
- if test $gl_cv_warn[]param = "yes"; then
- WARN_CFLAGS="$WARN_CFLAGS $1"
- fi
+# gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
+# ------------------------------------------------
+# Adds parameter to WARN_CFLAGS if the compiler supports it. For example,
+# gl_WARN_ADD([-Wparentheses]).
+AC_DEFUN([gl_WARN_ADD],
+[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_$1])dnl
+AC_CACHE_CHECK([whether compiler handles $1], [gl_Warn], [
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="${CFLAGS} $1"
+ AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
+ [AS_VAR_SET([gl_Warn], [yes])],
+ [AS_VAR_SET([gl_Warn], [no])])
+ CFLAGS="$save_CFLAGS"
+])
+AS_VAR_PUSHDEF([gl_Flags], m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]))dnl
+gl_AS_VAR_IF([gl_Warn], [yes], [gl_AS_VAR_APPEND([gl_Flags], [" $1"])])
+AS_VAR_POPDEF([gl_Flags])dnl
+AS_VAR_POPDEF([gl_Warn])dnl
])
- warning: module to simplify adding compiler warnings, Simon Josefsson, 2008/11/10
- Re: warning: module to simplify adding compiler warnings, Paolo Bonzini, 2008/11/10
- Re: warning: module to simplify adding compiler warnings, Ralf Wildenhues, 2008/11/10
- Re: warning: module to simplify adding compiler warnings, Simon Josefsson, 2008/11/10
- Re: warning: module to simplify adding compiler warnings, Simon Josefsson, 2008/11/10
- Re: warning: module to simplify adding compiler warnings, Paolo Bonzini, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Simon Josefsson, 2008/11/11
- Re: warning: module to simplify adding compiler warnings,
Paolo Bonzini <=
- Re: warning: module to simplify adding compiler warnings, Bruno Haible, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Paolo Bonzini, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Simon Josefsson, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Paolo Bonzini, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Simon Josefsson, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Paolo Bonzini, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Simon Josefsson, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Paolo Bonzini, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Simon Josefsson, 2008/11/11
- Re: warning: module to simplify adding compiler warnings, Ralf Wildenhues, 2008/11/11