summaryrefslogtreecommitdiff
path: root/m4/compiler_options.m4
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-08-11 10:56:59 +0200
committerThomas Haller <thaller@redhat.com>2022-08-11 19:49:41 +0200
commit119d30145e74ff3df503bcacc079ff96d14c3207 (patch)
tree99a6e22acac8d810eabf3729400bf56b36a3d331 /m4/compiler_options.m4
parent3117198f157835506eb1819937b01d68c9e36038 (diff)
downloadNetworkManager-119d30145e74ff3df503bcacc079ff96d14c3207.tar.gz
m4: add NM_COMPILER_WARNING_FLAG() macro
We used COMPILER_FLAG(LIBSYSTEMD_NM_CFLAGS, "-Wno-gnu-variable-sized-type-not-at-end") to detect whether the flag is supported. However, that does not work with GCC since version 4.4 due to https://gcc.gnu.org/wiki/FAQ#wnowarning. Note that we already had NM_COMPILER_WARNING(), but that again does something rather different.
Diffstat (limited to 'm4/compiler_options.m4')
-rw-r--r--m4/compiler_options.m49
1 files changed, 9 insertions, 0 deletions
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'"])