summaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
authorJarno Rajahalme <jarno@ovn.org>2016-06-20 18:51:06 -0700
committerJarno Rajahalme <jarno@ovn.org>2016-06-20 18:51:06 -0700
commit71ce9eddafef87952fcdfb65a3d998c67fcd7901 (patch)
treeb25679115dd604e28ff77e6a63c1f520eae224f9 /acinclude.m4
parent420c73b20bb4d70e1451417cebbca9eb672f5241 (diff)
downloadopenvswitch-71ce9eddafef87952fcdfb65a3d998c67fcd7901.tar.gz
acinclude: Add OVS_FIND_PARAM_IFELSE.
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@ovn.org> Acked-by: Jesse Gross <jesse@kernel.org>
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m441
1 files changed, 37 insertions, 4 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 3978980fb..eff981791 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])