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