[ovs-dev] [PATCH v2 02/16] acinclude: Add OVS_FIND_PARAM_IFELSE.
Jarno Rajahalme
jarno at ovn.org
Tue Jun 14 22:25:23 UTC 2016
OVS_FIND_PARAM_IFELSE is more robust macro for checking function
parameters, as it does not require the parameter to be on the same
line as the function name like the OVS_GREP_IFELSE does.
Use this to fix the check for struct conntrack_zone parameter, which
is on a different line on Linux 4.3 and higher.
Signed-off-by: Jarno Rajahalme <jarno at ovn.org>
---
acinclude.m4 | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index b651f2f..6871ba6 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -323,6 +323,39 @@ AC_DEFUN([OVS_FIND_FIELD_IFELSE], [
fi
])
+dnl OVS_FIND_PARAM_IFELSE(FILE, FUNCTION, REGEX, [IF-MATCH], [IF-NO-MATCH])
+dnl
+dnl Looks for FUNCTION in FILE. If it is found, greps for REGEX within
+dnl the function signature starting from the line matching FUNCTION
+dnl and ending with the line containing the closing parenthesis. If
+dnl this is successful, runs IF-MATCH, otherwise IF_NO_MATCH. If
+dnl IF-MATCH is empty then it defines to
+dnl OVS_DEFINE(HAVE_<FUNCTION>_WITH_<REGEX>), with <FUNCTION> and
+dnl <REGEX> translated to uppercase.
+AC_DEFUN([OVS_FIND_PARAM_IFELSE], [
+ AC_MSG_CHECKING([whether $2 has parameter $3 in $1])
+ if test -f $1; then
+ awk '/$2[[ \t\n]]*\(/,/\)/' $1 2>/dev/null | grep '$3' >/dev/null
+ status=$?
+ case $status in
+ 0)
+ AC_MSG_RESULT([yes])
+ m4_if([$4], [], [OVS_DEFINE([HAVE_]m4_toupper([$2])[_WITH_]m4_toupper([$3]))], [$4])
+ ;;
+ 1)
+ AC_MSG_RESULT([no])
+ $5
+ ;;
+ *)
+ AC_MSG_ERROR([grep exited with status $status])
+ ;;
+ esac
+ else
+ AC_MSG_RESULT([file not found])
+ $5
+ fi
+])
+
dnl OVS_DEFINE(NAME)
dnl
dnl Defines NAME to 1 in kcompat.h.
@@ -425,11 +458,11 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netfilter_ipv6.h], [nf_ipv6_ops],
[fragment.*sock], [OVS_DEFINE([HAVE_NF_IPV6_OPS_FRAGMENT])])
- OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
- [tmpl_alloc.*conntrack_zone],
+ OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
+ [nf_ct_tmpl_alloc], [nf_conntrack_zone],
[OVS_DEFINE([HAVE_NF_CT_TMPL_ALLOC_TAKES_STRUCT_ZONE])])
- OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
- [l3num.*struct.net],
+ OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
+ [nf_ct_get_tuplepr], [struct.net],
[OVS_DEFINE([HAVE_NF_CT_GET_TUPLEPR_TAKES_STRUCT_NET])])
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_zones.h],
[nf_ct_zone_init])
--
2.1.4
More information about the dev
mailing list