1From c2668f7f2ea82a61115b7cae56ed081b41ff5153 Mon Sep 17 00:00:00 2001 2From: Khem Raj <raj.khem@gmail.com> 3Date: Sat, 22 Apr 2017 12:34:37 -0700 4Subject: [PATCH] configure: Disable format-overflow if supported by gcc 5 6Signed-off-by: Khem Raj <raj.khem@gmail.com> 7 8--- 9Upstream-Status: Pending 10 11 Makefile.am | 6 +-- 12 configure.ac | 2 + 13 m4/ax_check_compile_flag.m4 | 74 +++++++++++++++++++++++++++++++++++++ 14 3 files changed, 79 insertions(+), 3 deletions(-) 15 create mode 100644 m4/ax_check_compile_flag.m4 16 17diff --git a/Makefile.am b/Makefile.am 18index b3d6553..5607fc2 100644 19--- a/Makefile.am 20+++ b/Makefile.am 21@@ -52,10 +52,10 @@ AM_CPPFLAGS = \ 22 -pthread \ 23 -D_GNU_SOURCE -DINTERNAL_VERSION_ID='"@INTERNAL_VERSION_ID@"' \ 24 $(CORE_INCLUDES) \ 25- $(all_includes) 26+ $(all_includes) @NOWARNINGS@ 27 28-AM_CFLAGS = -pipe -std=gnu11 @OSAF_HARDEN_FLAGS@ -Wall -Wformat=2 -Werror 29-AM_CXXFLAGS = -pipe -std=gnu++11 @OSAF_HARDEN_FLAGS@ -Wall -Wformat=2 -Werror 30+AM_CFLAGS = -pipe -std=gnu11 @OSAF_HARDEN_FLAGS@ -Wall -Wformat=2 -Werror @NOWARNINGS@ 31+AM_CXXFLAGS = -pipe -std=gnu++11 @OSAF_HARDEN_FLAGS@ -Wall -Wformat=2 -Werror @NOWARNINGS@ 32 33 if ENABLE_GCOV 34 AM_CFLAGS += --coverage 35diff --git a/configure.ac b/configure.ac 36index 5b86730..47d1002 100644 37--- a/configure.ac 38+++ b/configure.ac 39@@ -600,6 +600,8 @@ if test -z "$OSAF_HARDEN_FLAGS"; then 40 fi 41 AC_SUBST(OSAF_HARDEN_FLAGS) 42 43+AX_CHECK_COMPILE_FLAG([-Werror=format-overflow],[NOWARNINGS=-Wno-error=format-overflow]) 44+AC_SUBST(NOWARNINGS) 45 ############################################# 46 # List the output Makefiles 47 ############################################# 48diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 49new file mode 100644 50index 0000000..dcabb92 51--- /dev/null 52+++ b/m4/ax_check_compile_flag.m4 53@@ -0,0 +1,74 @@ 54+# =========================================================================== 55+# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html 56+# =========================================================================== 57+# 58+# SYNOPSIS 59+# 60+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) 61+# 62+# DESCRIPTION 63+# 64+# Check whether the given FLAG works with the current language's compiler 65+# or gives an error. (Warnings, however, are ignored) 66+# 67+# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 68+# success/failure. 69+# 70+# If EXTRA-FLAGS is defined, it is added to the current language's default 71+# flags (e.g. CFLAGS) when the check is done. The check is thus made with 72+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to 73+# force the compiler to issue an error when a bad flag is given. 74+# 75+# INPUT gives an alternative input source to AC_COMPILE_IFELSE. 76+# 77+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 78+# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. 79+# 80+# LICENSE 81+# 82+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> 83+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> 84+# 85+# This program is free software: you can redistribute it and/or modify it 86+# under the terms of the GNU General Public License as published by the 87+# Free Software Foundation, either version 3 of the License, or (at your 88+# option) any later version. 89+# 90+# This program is distributed in the hope that it will be useful, but 91+# WITHOUT ANY WARRANTY; without even the implied warranty of 92+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 93+# Public License for more details. 94+# 95+# You should have received a copy of the GNU General Public License along 96+# with this program. If not, see <https://www.gnu.org/licenses/>. 97+# 98+# As a special exception, the respective Autoconf Macro's copyright owner 99+# gives unlimited permission to copy, distribute and modify the configure 100+# scripts that are the output of Autoconf when processing the Macro. You 101+# need not follow the terms of the GNU General Public License when using 102+# or distributing such scripts, even though portions of the text of the 103+# Macro appear in them. The GNU General Public License (GPL) does govern 104+# all other use of the material that constitutes the Autoconf Macro. 105+# 106+# This special exception to the GPL applies to versions of the Autoconf 107+# Macro released by the Autoconf Archive. When you make and distribute a 108+# modified version of the Autoconf Macro, you may extend this special 109+# exception to the GPL to apply to your modified version as well. 110+ 111+#serial 5 112+ 113+AC_DEFUN([AX_CHECK_COMPILE_FLAG], 114+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF 115+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl 116+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ 117+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS 118+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" 119+ AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], 120+ [AS_VAR_SET(CACHEVAR,[yes])], 121+ [AS_VAR_SET(CACHEVAR,[no])]) 122+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) 123+AS_VAR_IF(CACHEVAR,yes, 124+ [m4_default([$2], :)], 125+ [m4_default([$3], :)]) 126+AS_VAR_POPDEF([CACHEVAR])dnl 127+])dnl AX_CHECK_COMPILE_FLAGS 128