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