diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4 index b4b5e78dcc..b2e9d80e0d 100644 --- a/m4/compiler_options.m4 +++ b/m4/compiler_options.m4 @@ -29,8 +29,17 @@ AC_DEFUN([NM_COMPILER_FLAG], [ ], [$4]) ]) +dnl Check whether a particular warning is supported. If yes, the flag +dnl is appended to [ENV-VAR]. +dnl NM_COMPILER_WARNING_FLAG([ENV-VAR], [WARNING]) +AC_DEFUN([NM_COMPILER_WARNING_FLAG], [ + dnl "-Wno-*" requires special handling, see https://gcc.gnu.org/wiki/FAQ#wnowarning. + _NM_COMPILER_FLAG([-Wall $(printf '%s' "$2" | sed -e 's/^-W\(no-\|no-error=\)/-W/')], [], [eval "AS_TR_SH([$1])='$$1 $2'"], []) +]) + dnl Check whether a particular warning is not emitted with code provided, dnl append an option to disable the warning to a specified variable if the check fails. +dnl Note that this always either adds -W$2 or -Wno-$2, depending on whether it's supported. dnl NM_COMPILER_WARNING([ENV-VAR], [WARNING], [C-SNIPPET]) AC_DEFUN([NM_COMPILER_WARNING], [ _NM_COMPILER_FLAG([-W$2], [$3], [eval "AS_TR_SH([$1])='$$1 -W$2'"], [eval "AS_TR_SH([$1])='$$1 -Wno-$2'"])