{"thread":{"id":"29858","subject":"[PATCH] configure.ac: Add --with-gcc-warnings configure option","startedAt":"2012-03-06T14:33:05Z","lastAt":"2012-03-06T16:12:57Z","messageCount":4,"participants":["Elia Pinto","Stefano Lattarini"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"186215","messageId":"1331044385-14796-1-git-send-email-gitter.spiros@gmail.com","threadId":"29858","inReplyTo":null,"subject":"[PATCH] configure.ac: Add --with-gcc-warnings configure option","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2012-03-06T14:33:05Z","receivedAt":"2012-03-06T14:33:05Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"Introduce a new --with-gcc-warnings configure option\nusing a new autoconf macro that check if the compiler\nknow the option passed or not in a portable way, as\nit not depends from the gcc version or from the\nother compiler used.\n\nSigned-off-by: Elia Pinto <gitter.spiros@gmail.com>\n---\nThis is the version 2 of the patch, in which i have\nslightly changed the commit message for\nclarify the purpose. To activate the\npatch is of course necessary to do a autoreconf -vfi after\napplying the patch.\n\n\n Makefile      |    2 +-\n config.mak.in |    1 +\n configure.ac  |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 120 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex be1957a..d0aef0f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -310,7 +310,7 @@ endif\n \n CFLAGS = -g -O2 -Wall\n LDFLAGS =\n-ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)\n+ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) $(AM_CFLAGS)\n ALL_LDFLAGS = $(LDFLAGS)\n STRIP ?= strip\n \ndiff --git a/config.mak.in b/config.mak.in\nindex b2ba710..5b7dbfd 100644\n--- a/config.mak.in\n+++ b/config.mak.in\n@@ -2,6 +2,7 @@\n # @configure_input@\n \n CC = @CC@\n+AM_CFLAGS = @GIT_CFLAGS@\n CFLAGS = @CFLAGS@\n CPPFLAGS = @CPPFLAGS@\n LDFLAGS = @LDFLAGS@\ndiff --git a/configure.ac b/configure.ac\nindex 8bb0f44..dba42a9 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -14,6 +14,34 @@ echo \"# ${config_append}.  Generated by configure.\" > \"${config_append}\"\n \n \n ## Definitions of macros\n+# git_AS_VAR_APPEND(VAR, VALUE)\n+# ----------------------------\n+# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.\n+m4_ifdef([AS_VAR_APPEND],\n+[m4_copy([AS_VAR_APPEND], [git_AS_VAR_APPEND])],\n+[m4_define([git_AS_VAR_APPEND],\n+[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])\n+\n+# GIT_CFLAGS_ADD(PARAMETER, [VARIABLE = GIT_CFLAGS])\n+# ------------------------------------------------\n+# Adds parameter to GIT_CFLAGS if the compiler supports it.  For example,\n+# GIT_CFLAGS_ADD([-Wall],[GIT_CFLAGS]).\n+AC_DEFUN([GIT_CFLAGS_ADD],\n+[AS_VAR_PUSHDEF([git_my_cflags], [git_cv_warn_$1])dnl\n+AC_CACHE_CHECK([whether compiler handles $1], [git_my_cflags], [\n+  save_CFLAGS=\"$CFLAGS\"\n+  CFLAGS=\"${CFLAGS} $1\"\n+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],\n+                    [AS_VAR_SET([git_my_cflags], [yes])],\n+                    [AS_VAR_SET([git_my_cflags], [no])])\n+  CFLAGS=\"$save_CFLAGS\"\n+])\n+AS_VAR_PUSHDEF([git_cflags], m4_if([$2], [], [[GIT_CFLAGS]], [[$2]]))dnl\n+AS_VAR_IF([git_my_cflags], [yes], [git_AS_VAR_APPEND([git_cflags], [\" $1\"])])\n+AS_VAR_POPDEF([git_cflags])dnl\n+AS_VAR_POPDEF([git_my_cflags])dnl\n+m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl\n+])\n # GIT_CONF_APPEND_LINE(LINE)\n # --------------------------\n # Append LINE to file ${config_append}\n@@ -158,6 +186,96 @@ if test -z \"$lib\"; then\n    lib=lib\n fi\n \n+# Turn gcc warning\n+\n+AC_ARG_ENABLE([gcc-warnings],\n+  [AS_HELP_STRING([--enable-gcc-warnings],\n+                  [turn on GCC warnings (for developers)@<:@default=no@:>@])],\n+  [case $enableval in\n+     yes|no) ;;\n+     *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;\n+   esac\n+   git_gcc_warnings=$enableval],\n+  [git_gcc_warnings=no]\n+)\n+\n+AS_IF([test \"x$git_gcc_warnings\" = xyes],\n+  [ # Add/Delete as needed\n+  MAX_STACK_SIZE=32768\n+  GIT_CFLAGS_ADD([-Wall], [GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-pedantic], [GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wextra], [GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wformat-y2k], [GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-fdiagnostics-show-option],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-funit-at-a-time],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-fstrict-aliasing],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wstrict-overflow],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-fstrict-overflow],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wpointer-arith],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wundef],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wformat-security],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Winit-self],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wmissing-include-dirs],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wunused],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wunknown-pragmas],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wstrict-aliasing],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wshadow],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wbad-function-cast],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wcast-align],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wwrite-strings],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wlogical-op],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Waggregate-return],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wstrict-prototypes],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wold-style-definition],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wmissing-prototypes],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wmissing-declarations],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wmissing-noreturn],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wmissing-format-attribute],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wredundant-decls],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wnested-externs],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Winline],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Winvalid-pch],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wvolatile-register-var],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wdisabled-optimization],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wbuiltin-macro-redefined],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wmudflap],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wpacked-bitfield-compat],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wsync-nand],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wattributes],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wcoverage-mismatch],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wmultichar],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wcpp],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wdeprecated-declarations],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wdiv-by-zero],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wdouble-promotion],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wendif-labels],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wformat-contains-nul],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wformat-extra-args],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wformat-zero-length],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wformat=2],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wmultichar],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wnormalized=nfc],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Woverflow],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wpointer-to-int-cast],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wpragmas],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wsuggest-attribute=const],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wsuggest-attribute=noreturn],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wsuggest-attribute=pure],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wtrampolines],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wno-missing-field-initializers],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wno-sign-compare],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wjump-misses-init],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wno-format-nonliteral],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wframe-larger-than=$MAX_STACK_SIZE],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-fstack-protector-all],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-fasynchronous-unwind-tables],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-fdiagnostics-show-option],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-funit-at-a-time],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-fipa-pure-const],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wno-aggregate-return],[GIT_CFLAGS])\n+  GIT_CFLAGS_ADD([-Wno-redundant-decls],[GIT_CFLAGS])\n+  AC_SUBST([GIT_CFLAGS])\n+  ])\n AC_ARG_ENABLE([pthreads],\n  [AS_HELP_STRING([--enable-pthreads=FLAGS],\n   [FLAGS is the value to pass to the compiler to enable POSIX Threads.]\n-- \n1.7.8.rc3.31.g017d1\n"},{"id":"186220","messageId":"4F56329E.9050506@gmail.com","threadId":"29858","inReplyTo":"1331044385-14796-1-git-send-email-gitter.spiros@gmail.com","subject":"Re: [PATCH] configure.ac: Add --with-gcc-warnings configure option","fromName":"Stefano Lattarini","fromEmail":"stefano.lattarini@gmail.com","sentAt":"2012-03-06T15:51:58Z","receivedAt":"2012-03-06T15:51:58Z","isPatch":true,"sender":{"key":"stefano.lattarini@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1429199?v=4"},"body":"On 03/06/2012 03:33 PM, Elia Pinto wrote:\n> Introduce a new --with-gcc-warnings configure option\n> using a new autoconf macro that check if the compiler\n> know the option passed or not in a portable way, as\n> it not depends from the gcc version or from the\n> other compiler used.\n> \n> Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>\n> ---\n> This is the version 2 of the patch, in which i have\n> slightly changed the commit message for\n> clarify the purpose. To activate the\n> patch is of course necessary to do a autoreconf -vfi after\n> applying the patch.\n> \n> \n>  Makefile      |    2 +-\n>  config.mak.in |    1 +\n>  configure.ac  |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>  3 files changed, 120 insertions(+), 1 deletions(-)\n> \n> diff --git a/Makefile b/Makefile\n> index be1957a..d0aef0f 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -310,7 +310,7 @@ endif\n>  \n>  CFLAGS = -g -O2 -Wall\n>  LDFLAGS =\n> -ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)\n> +ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) $(AM_CFLAGS)\n>\nWouldn't it be better to use $(WARN_CFLAGS) here?  It makes the purpose\nof the variable clearer, and don't give the wrong impression that Automake\nis involved (as the 'AM_' prefix might suggest).\n\n>  ALL_LDFLAGS = $(LDFLAGS)\n>  STRIP ?= strip\n>  \n> diff --git a/config.mak.in b/config.mak.in\n> index b2ba710..5b7dbfd 100644\n> --- a/config.mak.in\n> +++ b/config.mak.in\n> @@ -2,6 +2,7 @@\n>  # @configure_input@\n>  \n>  CC = @CC@\n> +AM_CFLAGS = @GIT_CFLAGS@\n>\nAccordingly here: s/AM_CFLAGS/WARN_CFLAGS/ and s/GIT_CFLAGS/WARN_CFLAGS/.\n\n> +# GIT_CFLAGS_ADD(PARAMETER, [VARIABLE = GIT_CFLAGS])\n> +# ------------------------------------------------\n>\nAnd here as well: s/GIT_CFLAGS/WARN_CFLAGS/.  Ditto for the rest of the\nM4 file.\n\nRegards,\n  Stefano\n"},{"id":"186224","messageId":"CA+EOSBm6autG8MCe1fWC+8V=Kx6FkAuVdS-SLKUzkmxz-x-qiw@mail.gmail.com","threadId":"29858","inReplyTo":"4F56329E.9050506@gmail.com","subject":"Re: [PATCH] configure.ac: Add --with-gcc-warnings configure option","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2012-03-06T16:08:12Z","receivedAt":"2012-03-06T16:08:12Z","isPatch":true,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"2012/3/6 Stefano Lattarini <stefano.lattarini@gmail.com>:\n> On 03/06/2012 03:33 PM, Elia Pinto wrote:\n>> Introduce a new --with-gcc-warnings configure option\n>> using a new autoconf macro that check if the compiler\n>> know the option passed or not in a portable way, as\n>> it not depends from the gcc version or from the\n>> other compiler used.\n>>\n>> Signed-off-by: Elia Pinto <gitter.spiros@gmail.com>\n>> ---\n>> This is the version 2 of the patch, in which i have\n>> slightly changed the commit message for\n>> clarify the purpose. To activate the\n>> patch is of course necessary to do a autoreconf -vfi after\n>> applying the patch.\n>>\n>>\n>>  Makefile      |    2 +-\n>>  config.mak.in |    1 +\n>>  configure.ac  |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>>  3 files changed, 120 insertions(+), 1 deletions(-)\n>>\n>> diff --git a/Makefile b/Makefile\n>> index be1957a..d0aef0f 100644\n>> --- a/Makefile\n>> +++ b/Makefile\n>> @@ -310,7 +310,7 @@ endif\n>>\n>>  CFLAGS = -g -O2 -Wall\n>>  LDFLAGS =\n>> -ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)\n>> +ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS) $(AM_CFLAGS)\n>>\n> Wouldn't it be better to use $(WARN_CFLAGS) here?  It makes the purpose\n> of the variable clearer, and don't give the wrong impression that Automake\n> is involved (as the 'AM_' prefix might suggest).\nOk, this is derived from the similar patch in popt HEAD and in branch\n1.17, for which i use  the full autofu.\nNo problem to reroll with your suggestions.\n\nThanks a lot\n\nRegards\n\nElia\n"},{"id":"186226","messageId":"4F563789.9080807@gmail.com","threadId":"29858","inReplyTo":"CA+EOSBm6autG8MCe1fWC+8V=Kx6FkAuVdS-SLKUzkmxz-x-qiw@mail.gmail.com","subject":"Re: [PATCH] configure.ac: Add --with-gcc-warnings configure option","fromName":"Stefano Lattarini","fromEmail":"stefano.lattarini@gmail.com","sentAt":"2012-03-06T16:12:57Z","receivedAt":"2012-03-06T16:12:57Z","isPatch":true,"sender":{"key":"stefano.lattarini@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1429199?v=4"},"body":"On 03/06/2012 05:08 PM, Elia Pinto wrote:\n>\n> No problem to reroll with your suggestions.\n> \n> Thanks a lot\n> \nBefore doing so, consider that the git developers might disagree with\nme, and their opinion certainly holds more weight than mine ...  You\nmight want to hear what they think before re-rolling, to save yourself\nsome potentially useless work.\n\nBest regards,\n  Stefano\n"}]}