Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ClamAV: devel

[PATCH] Add CL_CFLAGS and CL_LDFLAGS macro

 

 

ClamAV devel RSS feed   Index | Next | Previous | View Threaded


gitter.spiros at gmail

Apr 16, 2012, 7:56 AM

Post #1 of 1 (379 views)
Permalink
[PATCH] Add CL_CFLAGS and CL_LDFLAGS macro

These autoconf macros permit to enable a particular
compiler option in a portable way, testing if
the particular compiler version support it and
ignoring the option if it is not supported.

These are derived from gnulib warnings.m4 macro,
but do the check in a little different way.

Signed-off-by: Elia Pinto <gitter.spiros [at] gmail>
---
configure.in | 13 ++++++++++++-
m4/acinclude.m4 | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 1 deletions(-)

diff --git a/configure.in b/configure.in
index 9ea805c..0cf03da 100644
--- a/configure.in
+++ b/configure.in
@@ -1568,9 +1568,20 @@ WERR_CFLAGS=
WERR_CFLAGS_MILTER=
if test "x$enable_distcheckwerror" = "xyes"; then
if test "$distcheck_enable_flags" = "1"; then
- WERR_COMMON="-Wno-pointer-sign -Werror-implicit-function-declaration -Werror -Wextra -Wall -Wno-error=bad-function-cast -Wbad-function-cast -Wcast-align -Wendif-labels -Wfloat-equal -Wformat=2 -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wno-error=missing-prototypes -Wnested-externs -Wno-error=nested-externs -Wpointer-arith -Wstrict-prototypes -Wno-error=strict-prototypes -Wno-switch -Wno-switch-enum -Wundef -Wstrict-overflow=1 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wdeclaration-after-statement -Waggregate-return -Wmissing-format-attribute -Wno-error=missing-format-attribute -Wno-error=type-limits -Wno-error=unused-but-set-variable -Wno-error=unused-function -Wno-error=unused-value -Wno-error=unused-variable -Wcast-qual -Wno-error=cast-qual -Wno-error=sign-compare -Wshadow -Wno-error=shadow -Wno-error=uninitialized -fdiagnostics-show-option -Wno-unused-parameter -Wno-error=unreachable-code -Winvalid-pch -Wno-error=invalid-pch -O2 -D_FORTIFY_
SOURCE=2 -fstack-protector-all -Wstack-protector -Wno-error=aggregate-return"
+ WERR_COMMON="-Wno-pointer-sign -Werror-implicit-function-declaration -Werror -Wextra -Wall -Wno-error=bad-function-cast -Wbad-function-cast -Wcast-align -Wendif-labels -Wfloat-equal -Wformat=2 -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wno-error=missing-prototypes -Wnested-externs -Wno-error=nested-externs -Wpointer-arith -Wstrict-prototypes -Wno-error=strict-prototypes -Wno-switch -Wno-switch-enum -Wundef -Wstrict-overflow=1 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing \
+-Wdeclaration-after-statement -Waggregate-return -Wmissing-format-attribute -Wno-error=missing-format-attribute -Wno-error=type-limits -Wno-error=unused-but-set-variable -Wno-error=unused-function -Wno-error=unused-value -Wno-error=unused-variable -Wcast-qual -Wno-error=cast-qual -Wno-error=sign-compare -Wshadow -Wno-error=shadow -Wno-error=uninitialized -fdiagnostics-show-option -Wno-unused-parameter -Wno-error=unreachable-code -Winvalid-pch -Wno-error=invalid-pch -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector -Wno-error=aggregate-return"
WERR_CFLAGS="$WERR_COMMON -Wwrite-strings"
+ for c in $WERR_CFLAGS
+ do
+ cl_CFLAGS_ADD([$c], [CL_CFLAGS])
+ done
WERR_CFLAGS_MILTER="$WERR_COMMON -Wno-error=format-nonliteral"
+ for c in $WERR_CFLAGS_MILTER
+ do
+ cl_CFLAGS_ADD([$c], [CL_CFLAGS_MILTER])
+ done
+ WERR_CFLAGS="$CL_CFLAGS"
+ WERR_CFLAGS_MILTER="$CL_CFLAGS_MILTER"
fi
fi
AC_SUBST([WERR_CFLAGS])
diff --git a/m4/acinclude.m4 b/m4/acinclude.m4
index 981c634..df08d3e 100644
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -886,3 +886,55 @@ AC_DEFUN([CL_MSG_STATUS],
[test "x$3" = "x"], [AS_ECHO(["$2"])],
[AS_ECHO(["$2 ($3)"])])
])
+
+
+
+# cl_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], [cl_AS_VAR_APPEND])],
+[m4_define([cl_AS_VAR_APPEND],
+[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
+
+# cl_CFLAGS_ADD(PARAMETER, [VARIABLE = CL_CFLAGS])
+# ------------------------------------------------
+# Adds parameter to CL_CFLAGS if the compiler supports it. For example,
+# cl_CFLAGS_ADD([-Wall],[CL_CFLAGS]).
+AC_DEFUN([cl_CFLAGS_ADD],
+[AS_VAR_PUSHDEF([cl_my_cflags], [cl_cv_warn_$1])dnl
+AC_CACHE_CHECK([whether compiler handles $1], [cl_my_cflags], [
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="${CFLAGS} $1"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+ [AS_VAR_SET([cl_my_cflags], [yes])],
+ [AS_VAR_SET([cl_my_cflags], [no])])
+ CFLAGS="$save_CFLAGS"
+])
+AS_VAR_PUSHDEF([cl_cflags], m4_if([$2], [], [[CL_CFLAGS]], [[$2]]))dnl
+AS_VAR_IF([cl_my_cflags], [yes], [cl_AS_VAR_APPEND([cl_cflags], [" $1"])])
+AS_VAR_POPDEF([cl_cflags])dnl
+AS_VAR_POPDEF([cl_my_cflags])dnl
+m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
+])
+
+# cl_LDFLAGS_ADD(PARAMETER, [VARIABLE = CL_LDFLAGS])
+# ------------------------------------------------
+# Adds parameter to CL_LDFLAGS if the compiler supports it. For example,
+# cl_LDFLAGS_ADD([-Wall],[CL_LDFLAGS]).
+AC_DEFUN([cl_LDFLAGS_ADD],
+[AS_VAR_PUSHDEF([cl_my_ldflags], [cl_cv_warn_$1])dnl
+AC_CACHE_CHECK([whether compiler handles $1], [cl_my_ldflags], [
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="${LDFLAGS} $1"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
+ [AS_VAR_SET([cl_my_ldflags], [yes])],
+ [AS_VAR_SET([cl_my_ldflags], [no])])
+ LDFLAGS="$save_LDFLAGS"
+])
+AS_VAR_PUSHDEF([cl_ldflags], m4_if([$2], [], [[CL_LDFLAGS]], [[$2]]))dnl
+AS_VAR_IF([cl_my_ldflags], [yes], [cl_AS_VAR_APPEND([cl_ldflags], [" $1"])])
+AS_VAR_POPDEF([cl_ldflags])dnl
+AS_VAR_POPDEF([cl_my_ldflags])dnl
+m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
+])
--
1.7.8.rc3.31.g017d1

_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net

ClamAV devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.