0002-configure-fix-build-with-old-compilers.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. From 98e9faa4d39cd5b6aaab882877e19ae394ba3810 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Mon, 20 Nov 2017 23:10:38 +0100
  4. Subject: [PATCH] configure: fix build with old compilers
  5. Old gcc versions (gcc 4.7) do not support all warnings flags currently
  6. hard-coded by configure.ac. In order to fix this, we import the
  7. AX_CHECK_COMPILE_FLAG() macro from the autoconf-archive, and use it in
  8. the configure.ac to only use warning flags when the compiler supports
  9. them.
  10. Submitted-upstream: https://github.com/latchset/jose/pull/51
  11. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  12. ---
  13. configure.ac | 46 +++++++++++++++-------------
  14. m4/ax_check_compile_flag.m4 | 74 +++++++++++++++++++++++++++++++++++++++++++++
  15. 3 files changed, 105 insertions(+), 22 deletions(-)
  16. create mode 100644 m4/ax_check_compile_flag.m4
  17. diff --git a/configure.ac b/configure.ac
  18. index cf8c9a6..6fe4ded 100644
  19. --- a/configure.ac
  20. +++ b/configure.ac
  21. @@ -1,5 +1,6 @@
  22. AC_PREREQ(2.62)
  23. AC_INIT(jose, 10)
  24. +AC_CONFIG_MACRO_DIRS([m4])
  25. AC_CANONICAL_SYSTEM
  26. AC_PROG_CC_C99
  27. @@ -18,27 +19,30 @@ PKG_CHECK_MODULES([libcrypto], [libcrypto >= 1.0.2])
  28. AC_OPENMP
  29. AC_SUBST([OPENMP_CFLAGS])
  30. -JOSE_CFLAGS="\
  31. --Wall \
  32. --Wextra \
  33. --Werror \
  34. --Wstrict-aliasing \
  35. --Wchar-subscripts \
  36. --Wformat-security \
  37. --Wmissing-declarations \
  38. --Wmissing-prototypes \
  39. --Wnested-externs \
  40. --Wpointer-arith \
  41. --Wshadow \
  42. --Wsign-compare \
  43. --Wstrict-prototypes \
  44. --Wtype-limits \
  45. --Wunused-function \
  46. --Wno-missing-field-initializers \
  47. --Wno-unused-command-line-argument \
  48. --Wno-unused-parameter \
  49. --Wno-unknown-pragmas \
  50. -"
  51. +for flag in \
  52. + -Wall \
  53. + -Wextra \
  54. + -Werror \
  55. + -Wstrict-aliasing \
  56. + -Wchar-subscripts \
  57. + -Wformat-security \
  58. + -Wmissing-declarations \
  59. + -Wmissing-prototypes \
  60. + -Wnested-externs \
  61. + -Wpointer-arith \
  62. + -Wshadow \
  63. + -Wsign-compare \
  64. + -Wstrict-prototypes \
  65. + -Wtype-limits \
  66. + -Wunused-function \
  67. + -Wno-missing-field-initializers \
  68. + -Wno-unused-command-line-argument \
  69. + -Wno-unused-parameter \
  70. + -Wno-unknown-pragmas ; do
  71. + AX_CHECK_COMPILE_FLAG([${flag}],
  72. + [JOSE_CFLAGS="${JOSE_CFLAGS} ${flag}"])
  73. +done
  74. +
  75. AC_SUBST([JOSE_CFLAGS])
  76. AC_MSG_CHECKING([for linker script support])
  77. diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4
  78. new file mode 100644
  79. index 0000000..dcabb92
  80. --- /dev/null
  81. +++ b/m4/ax_check_compile_flag.m4
  82. @@ -0,0 +1,74 @@
  83. +# ===========================================================================
  84. +# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
  85. +# ===========================================================================
  86. +#
  87. +# SYNOPSIS
  88. +#
  89. +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
  90. +#
  91. +# DESCRIPTION
  92. +#
  93. +# Check whether the given FLAG works with the current language's compiler
  94. +# or gives an error. (Warnings, however, are ignored)
  95. +#
  96. +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
  97. +# success/failure.
  98. +#
  99. +# If EXTRA-FLAGS is defined, it is added to the current language's default
  100. +# flags (e.g. CFLAGS) when the check is done. The check is thus made with
  101. +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
  102. +# force the compiler to issue an error when a bad flag is given.
  103. +#
  104. +# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
  105. +#
  106. +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
  107. +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
  108. +#
  109. +# LICENSE
  110. +#
  111. +# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
  112. +# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
  113. +#
  114. +# This program is free software: you can redistribute it and/or modify it
  115. +# under the terms of the GNU General Public License as published by the
  116. +# Free Software Foundation, either version 3 of the License, or (at your
  117. +# option) any later version.
  118. +#
  119. +# This program is distributed in the hope that it will be useful, but
  120. +# WITHOUT ANY WARRANTY; without even the implied warranty of
  121. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  122. +# Public License for more details.
  123. +#
  124. +# You should have received a copy of the GNU General Public License along
  125. +# with this program. If not, see <https://www.gnu.org/licenses/>.
  126. +#
  127. +# As a special exception, the respective Autoconf Macro's copyright owner
  128. +# gives unlimited permission to copy, distribute and modify the configure
  129. +# scripts that are the output of Autoconf when processing the Macro. You
  130. +# need not follow the terms of the GNU General Public License when using
  131. +# or distributing such scripts, even though portions of the text of the
  132. +# Macro appear in them. The GNU General Public License (GPL) does govern
  133. +# all other use of the material that constitutes the Autoconf Macro.
  134. +#
  135. +# This special exception to the GPL applies to versions of the Autoconf
  136. +# Macro released by the Autoconf Archive. When you make and distribute a
  137. +# modified version of the Autoconf Macro, you may extend this special
  138. +# exception to the GPL to apply to your modified version as well.
  139. +
  140. +#serial 5
  141. +
  142. +AC_DEFUN([AX_CHECK_COMPILE_FLAG],
  143. +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
  144. +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
  145. +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
  146. + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
  147. + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
  148. + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
  149. + [AS_VAR_SET(CACHEVAR,[yes])],
  150. + [AS_VAR_SET(CACHEVAR,[no])])
  151. + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
  152. +AS_VAR_IF(CACHEVAR,yes,
  153. + [m4_default([$2], :)],
  154. + [m4_default([$3], :)])
  155. +AS_VAR_POPDEF([CACHEVAR])dnl
  156. +])dnl AX_CHECK_COMPILE_FLAGS
  157. --
  158. 2.13.6