2009-07-08 13:19:16 -07:00
# -*- autoconf -*-
2014-01-23 15:35:22 -08:00
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
2009-07-08 13:19:16 -07:00
#
2009-06-15 15:11:30 -07:00
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
2009-07-08 13:19:16 -07:00
#
2009-06-15 15:11:30 -07:00
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2009-07-08 13:19:16 -07:00
2011-04-12 11:43:11 -07:00
dnl OVS_ENABLE_WERROR
AC_DEFUN([OVS_ENABLE_WERROR],
[AC_ARG_ENABLE(
[Werror],
[AC_HELP_STRING([--enable-Werror], [Add -Werror to CFLAGS])],
[], [enable_Werror=no])
AC_CONFIG_COMMANDS_PRE(
[if test "X$enable_Werror" = Xyes; then
2014-09-11 21:34:21 +02:00
OVS_CFLAGS="$OVS_CFLAGS -Werror"
2011-04-12 11:43:11 -07:00
fi])])
2011-06-22 09:26:31 -07:00
dnl OVS_CHECK_LINUX
2009-07-08 13:19:16 -07:00
dnl
dnl Configure linux kernel source tree
2011-06-22 09:26:31 -07:00
AC_DEFUN([OVS_CHECK_LINUX], [
2011-06-22 11:07:33 -07:00
AC_ARG_WITH([linux],
[AC_HELP_STRING([--with-linux=/path/to/linux],
[Specify the Linux kernel build directory])])
AC_ARG_WITH([linux-source],
[AC_HELP_STRING([--with-linux-source=/path/to/linux-source],
[Specify the Linux kernel source directory
2014-05-09 13:28:49 +09:00
(usually figured out automatically from build
directory)])])
2011-06-22 11:07:33 -07:00
# Deprecated equivalents to --with-linux, --with-linux-source.
AC_ARG_WITH([l26])
AC_ARG_WITH([l26-source])
if test X"$with_linux" != X; then
KBUILD=$with_linux
elif test X"$with_l26" != X; then
KBUILD=$with_l26
AC_MSG_WARN([--with-l26 is deprecated, please use --with-linux instead])
else
KBUILD=
fi
if test X"$KBUILD" != X; then
if test X"$with_linux_source" != X; then
KSRC=$with_linux_source
elif test X"$with_l26_source" != X; then
KSRC=$with_l26_source
AC_MSG_WARN([--with-l26-source is deprecated, please use --with-linux-source instead])
2011-06-22 15:09:35 -07:00
else
KSRC=
2011-06-22 11:07:33 -07:00
fi
elif test X"$with_linux_source" != X || test X"$with_l26_source" != X; then
AC_MSG_ERROR([Linux source directory may not be specified without Linux build directory])
fi
2011-06-22 09:26:31 -07:00
if test -n "$KBUILD"; then
KBUILD=`eval echo "$KBUILD"`
case $KBUILD in
2010-04-13 15:08:37 -07:00
/*) ;;
2011-06-22 09:26:31 -07:00
*) KBUILD=`pwd`/$KBUILD ;;
2010-04-13 15:08:37 -07:00
esac
2009-07-08 13:19:16 -07:00
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
# The build directory is what the user provided.
# Make sure that it exists.
2011-06-22 11:07:33 -07:00
AC_MSG_CHECKING([for Linux build directory])
2011-06-22 09:26:31 -07:00
if test -d "$KBUILD"; then
2014-05-09 13:28:49 +09:00
AC_MSG_RESULT([$KBUILD])
AC_SUBST(KBUILD)
2009-07-08 13:19:16 -07:00
else
2014-05-09 13:28:49 +09:00
AC_MSG_RESULT([no])
AC_ERROR([source dir $KBUILD doesn't exist])
2009-07-08 13:19:16 -07:00
fi
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
# Debian breaks kernel headers into "source" header and "build" headers.
2011-06-22 09:26:31 -07:00
# We want the source headers, but $KBUILD gives us the "build" headers.
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
# Use heuristics to find the source headers.
2011-06-22 11:07:33 -07:00
AC_MSG_CHECKING([for Linux source directory])
2011-06-22 09:26:31 -07:00
if test -n "$KSRC"; then
KSRC=`eval echo "$KSRC"`
case $KSRC in
2010-07-02 10:10:04 -07:00
/*) ;;
2011-06-22 09:26:31 -07:00
*) KSRC=`pwd`/$KSRC ;;
2010-01-08 13:09:10 -08:00
esac
2011-06-22 09:26:31 -07:00
if test ! -e $KSRC/include/linux/kernel.h; then
2011-06-22 15:09:50 -07:00
AC_MSG_ERROR([$KSRC is not a kernel source directory])
2010-07-02 10:10:04 -07:00
fi
else
2011-06-22 09:26:31 -07:00
KSRC=$KBUILD
if test ! -e $KSRC/include/linux/kernel.h; then
2012-02-16 10:34:55 -08:00
# Debian kernel build Makefiles tend to include a line of the form:
# MAKEARGS := -C /usr/src/linux-headers-3.2.0-1-common O=/usr/src/linux-headers-3.2.0-1-486
# First try to extract the source directory from this line.
KSRC=`sed -n 's/.*-C \([[^ ]]*\).*/\1/p' "$KBUILD"/Makefile`
if test ! -e "$KSRC"/include/linux/kernel.h; then
# Didn't work. Fall back to name-based heuristics that used to work.
case `echo "$KBUILD" | sed 's,/*$,,'` in # (
*/build)
KSRC=`echo "$KBUILD" | sed 's,/build/*$,/source,'`
;; # (
*)
KSRC=`(cd $KBUILD && pwd -P) | sed 's,-[[^-]]*$,-common,'`
;;
esac
fi
2010-07-02 10:10:04 -07:00
fi
2012-02-16 10:34:55 -08:00
if test ! -e "$KSRC"/include/linux/kernel.h; then
2011-06-22 11:07:33 -07:00
AC_MSG_ERROR([cannot find source directory (please use --with-linux-source)])
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
fi
fi
2011-06-22 09:26:31 -07:00
AC_MSG_RESULT([$KSRC])
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
AC_MSG_CHECKING([for kernel version])
2011-06-22 10:15:23 -07:00
version=`sed -n 's/^VERSION = //p' "$KSRC/Makefile"`
2011-06-22 09:26:31 -07:00
patchlevel=`sed -n 's/^PATCHLEVEL = //p' "$KSRC/Makefile"`
sublevel=`sed -n 's/^SUBLEVEL = //p' "$KSRC/Makefile"`
2011-06-22 10:15:23 -07:00
if test X"$version" = X || test X"$patchlevel" = X; then
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
AC_ERROR([cannot determine kernel version])
2011-06-22 10:15:23 -07:00
elif test X"$sublevel" = X; then
kversion=$version.$patchlevel
else
kversion=$version.$patchlevel.$sublevel
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
fi
2011-06-22 10:15:23 -07:00
AC_MSG_RESULT([$kversion])
if test "$version" -ge 3; then
2015-02-06 21:10:44 +01:00
if test "$version" = 3 && test "$patchlevel" -le 19; then
2013-09-03 11:02:40 -07:00
: # Linux 3.x
else
2015-02-06 21:10:44 +01:00
AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version newer than 3.19.x is not supported (please refer to the FAQ for advice)])
2013-09-03 11:02:40 -07:00
fi
2011-06-22 10:15:23 -07:00
else
2013-09-03 11:02:40 -07:00
if test "$version" -le 1 || test "$patchlevel" -le 5 || test "$sublevel" -le 31; then
AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version 2.6.32 or later is required])
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
else
2013-09-03 11:02:40 -07:00
: # Linux 2.6.x
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
fi
2009-07-08 13:19:16 -07:00
fi
2012-12-07 12:37:02 +09:00
if (test ! -e "$KBUILD"/include/linux/version.h && \
test ! -e "$KBUILD"/include/generated/uapi/linux/version.h)|| \
2011-06-22 09:26:31 -07:00
(test ! -e "$KBUILD"/include/linux/autoconf.h && \
test ! -e "$KBUILD"/include/generated/autoconf.h); then
2014-05-09 13:28:49 +09:00
AC_MSG_ERROR([Linux kernel source in $KBUILD is not configured])
2009-07-08 13:19:16 -07:00
fi
2011-06-22 09:26:31 -07:00
OVS_CHECK_LINUX_COMPAT
2009-07-08 13:19:16 -07:00
fi
2011-06-22 09:26:31 -07:00
AM_CONDITIONAL(LINUX_ENABLED, test -n "$KBUILD")
2009-07-08 13:19:16 -07:00
])
2014-03-24 19:23:08 -07:00
dnl OVS_CHECK_DPDK
dnl
dnl Configure DPDK source tree
AC_DEFUN([OVS_CHECK_DPDK], [
AC_ARG_WITH([dpdk],
[AC_HELP_STRING([--with-dpdk=/path/to/dpdk],
2014-05-09 13:29:11 +09:00
[Specify the DPDK build directory])])
2014-03-24 19:23:08 -07:00
if test X"$with_dpdk" != X; then
RTE_SDK=$with_dpdk
DPDK_INCLUDE=$RTE_SDK/include
DPDK_LIB_DIR=$RTE_SDK/lib
2015-03-20 06:02:13 -07:00
DPDK_LIB="-lintel_dpdk"
DPDK_EXTRA_LIB="-lfuse"
2014-03-24 19:23:08 -07:00
2014-09-11 21:34:21 +02:00
ovs_save_CFLAGS="$CFLAGS"
ovs_save_LDFLAGS="$LDFLAGS"
2014-06-03 11:29:53 -07:00
LDFLAGS="$LDFLAGS -L$DPDK_LIB_DIR"
CFLAGS="$CFLAGS -I$DPDK_INCLUDE"
# On some systems we have to add -ldl to link with dpdk
#
# This code, at first, tries to link without -ldl (""),
# then adds it and tries again.
# Before each attempt the search cache must be unset,
# otherwise autoconf will stick with the old result
found=false
save_LIBS=$LIBS
for extras in "" "-ldl"; do
2015-03-20 06:02:13 -07:00
LIBS="$DPDK_LIB $extras $save_LIBS $DPDK_EXTRA_LIB"
2014-06-03 11:29:53 -07:00
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <rte_config.h>
#include <rte_eal.h>],
[int rte_argc; char ** rte_argv;
rte_eal_init(rte_argc, rte_argv);])],
[found=true])
if $found; then
break
fi
done
if $found; then :; else
AC_MSG_ERROR([cannot link with dpdk])
fi
2014-09-11 21:34:21 +02:00
CFLAGS="$ovs_save_CFLAGS"
LDFLAGS="$ovs_save_LDFLAGS"
OVS_LDFLAGS="$OVS_LDFLAGS -L$DPDK_LIB_DIR"
OVS_CFLAGS="$OVS_CFLAGS -I$DPDK_INCLUDE"
2014-03-24 19:23:08 -07:00
2015-03-20 06:02:13 -07:00
# DPDK pmd drivers are not linked unless --whole-archive is used.
2014-08-12 10:43:35 -07:00
#
# This happens because the rest of the DPDK code doesn't use any symbol in
# the pmd driver objects, and the drivers register themselves using an
# __attribute__((constructor)) function.
#
# These options are specified inside a single -Wl directive to prevent
# autotools from reordering them.
2015-03-20 06:02:13 -07:00
DPDK_vswitchd_LDFLAGS=-Wl,--whole-archive,$DPDK_LIB,--no-whole-archive
2014-08-19 01:23:55 +00:00
AC_SUBST([DPDK_vswitchd_LDFLAGS])
2014-03-24 19:23:08 -07:00
AC_DEFINE([DPDK_NETDEV], [1], [System uses the DPDK module.])
else
RTE_SDK=
fi
AM_CONDITIONAL([DPDK_NETDEV], test -n "$RTE_SDK")
])
2010-09-08 16:46:43 -07:00
dnl OVS_GREP_IFELSE(FILE, REGEX, [IF-MATCH], [IF-NO-MATCH])
2009-07-08 13:19:16 -07:00
dnl
dnl Greps FILE for REGEX. If it matches, runs IF-MATCH, otherwise IF-NO-MATCH.
2010-09-08 16:46:43 -07:00
dnl If IF-MATCH is empty then it defines to OVS_DEFINE(HAVE_<REGEX>), with
dnl <REGEX> translated to uppercase.
2009-07-08 13:19:16 -07:00
AC_DEFUN([OVS_GREP_IFELSE], [
AC_MSG_CHECKING([whether $2 matches in $1])
2010-11-02 16:00:16 -07:00
if test -f $1; then
grep '$2' $1 >/dev/null 2>&1
status=$?
case $status in
0)
AC_MSG_RESULT([yes])
2010-09-08 16:46:43 -07:00
m4_if([$3], [], [OVS_DEFINE([HAVE_]m4_toupper([$2]))], [$3])
2010-11-02 16:00:16 -07:00
;;
1)
AC_MSG_RESULT([no])
$4
;;
*)
AC_MSG_ERROR([grep exited with status $status])
;;
esac
else
AC_MSG_RESULT([file not found])
$4
fi
2009-07-08 13:19:16 -07:00
])
2015-03-24 16:16:18 -07:00
dnl OVS_FIND_FIELD_IFELSE(FILE, STRUCTURE, REGEX, [IF-MATCH], [IF-NO-MATCH])
dnl
dnl Looks for STRUCTURE in FILE. If it is found, greps for REGEX within the
dnl structure definition. If this is successful, runs IF-MATCH, otherwise
dnl IF_NO_MATCH. If IF-MATCH is empty then it defines to
dnl OVS_DEFINE(HAVE_<STRUCTURE>_WITH_<REGEX>), with <STRUCTURE> and <REGEX>
dnl translated to uppercase.
AC_DEFUN([OVS_FIND_FIELD_IFELSE], [
AC_MSG_CHECKING([whether $2 has member $3 in $1])
if test -f $1; then
awk '/$2.{/,/^}/' $1 2>/dev/null | grep '$3'
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
])
2009-07-08 13:19:16 -07:00
dnl OVS_DEFINE(NAME)
dnl
dnl Defines NAME to 1 in kcompat.h.
AC_DEFUN([OVS_DEFINE], [
2011-06-23 17:10:00 -07:00
echo '#define $1 1' >> datapath/linux/kcompat.h.new
2009-07-08 13:19:16 -07:00
])
AC_DEFUN([OVS_CHECK_LOG2_H], [
2011-06-22 09:26:31 -07:00
AC_MSG_CHECKING([for $KSRC/include/linux/log2.h])
if test -e $KSRC/include/linux/log2.h; then
2009-07-08 13:19:16 -07:00
AC_MSG_RESULT([yes])
OVS_DEFINE([HAVE_LOG2_H])
else
AC_MSG_RESULT([no])
fi
])
2011-06-22 09:26:31 -07:00
dnl OVS_CHECK_LINUX_COMPAT
2009-07-08 13:19:16 -07:00
dnl
dnl Runs various Autoconf checks on the Linux 2.6 kernel source in
2011-06-22 09:26:31 -07:00
dnl the directory in $KBUILD.
AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
2011-06-23 17:10:00 -07:00
rm -f datapath/linux/kcompat.h.new
mkdir -p datapath/linux
: > datapath/linux/kcompat.h.new
2010-05-14 15:39:48 -07:00
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/arch/x86/include/asm/checksum_32.h], [src_err,],
2010-11-02 15:43:32 -07:00
[OVS_DEFINE([HAVE_CSUM_COPY_DBG])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [ERR_CAST])
2014-09-12 16:03:34 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [IS_ERR_OR_NULL])
2010-05-14 15:39:48 -07:00
2013-03-12 11:34:29 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [eth_hw_addr_random])
2014-05-01 15:50:48 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [ether_addr_copy])
2013-03-12 11:34:29 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [vlan_set_encap_proto])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/in.h], [ipv4_is_multicast])
2013-09-24 18:42:43 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [__ip_select_ident.*dst_entry],
[OVS_DEFINE([HAVE_IP_SELECT_IDENT_USING_DST_ENTRY])])
2015-03-24 16:16:18 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [inet_get_local_port_range.*net],
[OVS_DEFINE([HAVE_INET_GET_LOCAL_PORT_RANGE_USING_NET])])
2010-05-14 15:39:48 -07:00
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_disable_lro])
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_get_stats])
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_get_by_index_rcu])
2013-04-25 14:28:16 +02:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [__skb_gso_segment])
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [can_checksum_protocol])
2013-12-17 10:22:40 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [netdev_features_t])
2014-05-01 15:50:48 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [pcpu_sw_netstats])
OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32])
2010-05-14 15:39:48 -07:00
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/rcupdate.h], [rcu_read_lock_held], [],
[OVS_GREP_IFELSE([$KSRC/include/linux/rtnetlink.h],
2011-02-07 17:22:58 -08:00
[rcu_read_lock_held])])
2013-12-20 15:34:40 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/rtnetlink.h], [lockdep_rtnl_is_held])
2011-02-07 17:22:58 -08:00
2009-11-18 15:19:50 -08:00
# Check for the proto_data_valid member in struct sk_buff. The [^@]
# is necessary because some versions of this header remove the
# member but retain the kerneldoc comment that describes it (which
# starts with @). The brackets must be doubled because of m4
# quoting rules.
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [[[^@]]proto_data_valid],
2009-11-18 15:19:50 -08:00
[OVS_DEFINE([HAVE_PROTO_DATA_VALID])])
2013-12-04 11:26:36 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [rxhash])
2014-06-24 18:28:08 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [u16.*rxhash],
[OVS_DEFINE([HAVE_U16_RXHASH])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_dst(],
2010-05-14 15:44:39 -07:00
[OVS_DEFINE([HAVE_SKB_DST_ACCESSOR_FUNCS])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
2010-09-08 16:46:43 -07:00
[skb_copy_from_linear_data_offset])
2012-01-04 17:20:08 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
[skb_reset_tail_pointer])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_cow_head])
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_transport_header],
2010-05-14 15:39:48 -07:00
[OVS_DEFINE([HAVE_SKBUFF_HEADER_HELPERS])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/icmpv6.h], [icmp6_hdr],
2010-12-29 19:03:46 -08:00
[OVS_DEFINE([HAVE_ICMP6_HDR])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_warn_if_lro],
2010-05-14 15:39:48 -07:00
[OVS_DEFINE([HAVE_SKB_WARN_LRO])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [consume_skb])
2012-07-12 16:25:29 +09:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_frag_page])
2013-12-20 14:30:28 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_has_frag_list])
2013-12-18 10:57:33 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [__skb_fill_page_desc])
2013-03-12 11:34:29 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_reset_mac_len])
2013-07-22 10:38:13 -04:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_unclone])
2014-04-28 13:59:25 +12:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_orphan_frags])
2014-05-01 15:50:48 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_get_hash])
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_clear_hash])
2014-09-29 21:39:56 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [int.skb_zerocopy(],
[OVS_DEFINE([HAVE_SKB_ZEROCOPY])])
2014-05-01 15:50:49 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [l4_rxhash])
2015-01-07 12:55:49 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_ensure_writable])
2015-01-07 12:55:49 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_vlan_pop])
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_vlan_push])
2010-05-14 15:39:48 -07:00
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/types.h], [bool],
2010-05-14 15:39:48 -07:00
[OVS_DEFINE([HAVE_BOOL_TYPE])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/types.h], [__wsum],
2010-09-08 10:04:47 -07:00
[OVS_DEFINE([HAVE_CSUM_TYPES])])
2013-05-13 15:53:06 -07:00
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/types.h], [__wsum],
[OVS_DEFINE([HAVE_CSUM_TYPES])])
2010-05-14 15:39:48 -07:00
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_replace4])
OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_unfold])
2010-05-14 15:39:48 -07:00
2014-09-20 06:25:23 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [genl_has_listeners])
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [mcgrp_offset])
2013-08-01 15:36:06 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [parallel_ops])
2014-09-29 21:39:56 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [genlmsg_new_unicast])
2015-02-03 21:53:36 +01:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [netlink_has_listeners(net->genl_sock],
[OVS_DEFINE([HAVE_GENL_HAS_LISTENERS_TAKES_NET])])
2015-01-21 16:42:51 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [genlmsg_parse])
2015-03-24 16:16:18 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [genl_notify.*family],
[OVS_DEFINE([HAVE_GENL_NOTIFY_TAKES_FAMILY])])
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/genetlink.h],
[genl_multicast_group], [id])
2013-12-22 19:43:58 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/gre.h], [gre_cisco_register])
2014-10-20 16:13:04 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/ipv6.h], [IP6_FH_F_SKIP_RH])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_get_be16])
2013-04-25 14:28:16 +02:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be16])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be32])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be64])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_find_nested])
2014-12-03 13:02:31 +01:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_is_last])
2010-05-14 15:39:48 -07:00
2014-01-03 15:44:28 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/sctp/checksum.h], [sctp_compute_cksum])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [ADD_ALL_VLANS_CMD],
Support vlan_group workaround implemented in XenServer kernels.
Some Linux network drivers support a feature called "VLAN acceleration",
associated with a data structure called a "vlan_group". A vlan_group is,
abstractly, a dictionary that maps from a VLAN ID (in the range 0...4095)
to a VLAN device, that is, a Linux network device associated with a
particular VLAN, e.g. "eth0.9" for VLAN 9 on eth0.
Some drivers that support VLAN acceleration have bugs that fall roughly
into the following categories:
* Some NICs strip VLAN tags on receive if no vlan_group is registered,
so that the tag is completely lost.
* Some drivers size their receive buffers based on whether a vlan_group
is enabled, meaning that a maximum size packet with a VLAN tag will
not fit if a vlan_group is not configured.
* On transmit some drivers expect that VLAN acceleration will be used
if it is available (which can only be done if a vlan_group is
configured). In these cases, the driver may fail to parse the packet
and correctly setup checksum offloading and/or TSO.
The correct long term solution is to fix these driver bugs. To cope until
then, we have prepared a patch to the Linux kernel network stack that works
around these problems. This commit adds support for the workaround
implemented by that patch.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
2011-03-16 14:39:17 -07:00
[OVS_DEFINE([HAVE_VLAN_BUG_WORKAROUND])])
2015-01-07 12:55:49 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [vlan_insert_tag_set_proto])
2015-01-07 12:55:49 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [__vlan_insert_tag])
Support vlan_group workaround implemented in XenServer kernels.
Some Linux network drivers support a feature called "VLAN acceleration",
associated with a data structure called a "vlan_group". A vlan_group is,
abstractly, a dictionary that maps from a VLAN ID (in the range 0...4095)
to a VLAN device, that is, a Linux network device associated with a
particular VLAN, e.g. "eth0.9" for VLAN 9 on eth0.
Some drivers that support VLAN acceleration have bugs that fall roughly
into the following categories:
* Some NICs strip VLAN tags on receive if no vlan_group is registered,
so that the tag is completely lost.
* Some drivers size their receive buffers based on whether a vlan_group
is enabled, meaning that a maximum size packet with a VLAN tag will
not fit if a vlan_group is not configured.
* On transmit some drivers expect that VLAN acceleration will be used
if it is available (which can only be done if a vlan_group is
configured). In these cases, the driver may fail to parse the packet
and correctly setup checksum offloading and/or TSO.
The correct long term solution is to fix these driver bugs. To cope until
then, we have prepared a patch to the Linux kernel network stack that works
around these problems. This commit adds support for the workaround
implemented by that patch.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
2011-03-16 14:39:17 -07:00
2014-06-30 13:43:25 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/u64_stats_sync.h], [u64_stats_fetch_begin_irq])
2013-04-25 14:28:15 +02:00
OVS_GREP_IFELSE([$KSRC/include/linux/openvswitch.h], [openvswitch_handle_frame_hook],
[OVS_DEFINE([HAVE_RHEL_OVS_HOOK])])
datapath: Account for "vxlan: Group Policy extension"
Upstream commit:
vxlan: Group Policy extension
Implements supports for the Group Policy VXLAN extension [0] to provide
a lightweight and simple security label mechanism across network peers
based on VXLAN. The security context and associated metadata is mapped
to/from skb->mark. This allows further mapping to a SELinux context
using SECMARK, to implement ACLs directly with nftables, iptables, OVS,
tc, etc.
The group membership is defined by the lower 16 bits of skb->mark, the
upper 16 bits are used for flags.
SELinux allows to manage label to secure local resources. However,
distributed applications require ACLs to implemented across hosts. This
is typically achieved by matching on L2-L4 fields to identify the
original sending host and process on the receiver. On top of that,
netlabel and specifically CIPSO [1] allow to map security contexts to
universal labels. However, netlabel and CIPSO are relatively complex.
This patch provides a lightweight alternative for overlay network
environments with a trusted underlay. No additional control protocol
is required.
Host 1: Host 2:
Group A Group B Group B Group A
+-----+ +-------------+ +-------+ +-----+
| lxc | | SELinux CTX | | httpd | | VM |
+--+--+ +--+----------+ +---+---+ +--+--+
\---+---/ \----+---/
| |
+---+---+ +---+---+
| vxlan | | vxlan |
+---+---+ +---+---+
+------------------------------+
Backwards compatibility:
A VXLAN-GBP socket can receive standard VXLAN frames and will assign
the default group 0x0000 to such frames. A Linux VXLAN socket will
drop VXLAN-GBP frames. The extension is therefore disabled by default
and needs to be specifically enabled:
ip link add [...] type vxlan [...] gbp
In a mixed environment with VXLAN and VXLAN-GBP sockets, the GBP socket
must run on a separate port number.
Examples:
iptables:
host1# iptables -I OUTPUT -m owner --uid-owner 101 -j MARK --set-mark 0x200
host2# iptables -I INPUT -m mark --mark 0x200 -j DROP
OVS:
# ovs-ofctl add-flow br0 'in_port=1,actions=load:0x200->NXM_NX_TUN_GBP_ID[],NORMAL'
# ovs-ofctl add-flow br0 'in_port=2,tun_gbp_id=0x200,actions=drop'
[0] https://tools.ietf.org/html/draft-smith-vxlan-group-policy
[1] http://lwn.net/Articles/204905/
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: 351149 ("vxlan: Group Policy extension")
Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
2015-02-03 21:53:35 +01:00
OVS_GREP_IFELSE([$KSRC/include/net/vxlan.h], [struct vxlan_metadata],
[OVS_DEFINE([HAVE_VXLAN_METADATA])])
2014-09-18 14:48:56 +02:00
OVS_GREP_IFELSE([$KSRC/include/net/udp.h], [udp_flow_src_port],
2015-03-24 16:16:18 -07:00
[OVS_GREP_IFELSE([$KSRC/include/net/udp.h], [inet_get_local_port_range(net],
[OVS_DEFINE([HAVE_UDP_FLOW_SRC_PORT])])])
OVS_GREP_IFELSE([$KSRC/include/net/udp.h], [udp_v4_check])
OVS_GREP_IFELSE([$KSRC/include/net/udp.h], [udp_set_csum])
2014-09-18 14:48:56 +02:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [ignore_df:1],
[OVS_DEFINE([HAVE_IGNORE_DF_RENAME])])
2015-03-24 16:16:18 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [SKB_GSO_GRE_CSUM],
[OVS_DEFINE([HAVE_SKB_GSO_GRE_CSUM])])
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [SKB_GSO_UDP_TUNNEL_CSUM],
[OVS_DEFINE([HAVE_SKB_GSO_UDP_TUNNEL_CSUM])])
2014-09-18 14:48:56 +02:00
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/netdevice.h], [NET_NAME_UNKNOWN],
[OVS_DEFINE([HAVE_NET_NAME_UNKNOWN])])
2013-04-25 14:28:15 +02:00
2009-07-08 13:19:16 -07:00
OVS_CHECK_LOG2_H
2010-05-14 15:39:48 -07:00
2011-06-23 17:10:00 -07:00
if cmp -s datapath/linux/kcompat.h.new \
datapath/linux/kcompat.h >/dev/null 2>&1; then
rm datapath/linux/kcompat.h.new
2009-07-08 13:19:16 -07:00
else
2011-06-23 17:10:00 -07:00
mv datapath/linux/kcompat.h.new datapath/linux/kcompat.h
2009-07-08 13:19:16 -07:00
fi
])
dnl Checks for net/if_packet.h.
AC_DEFUN([OVS_CHECK_IF_PACKET],
[AC_CHECK_HEADER([net/if_packet.h],
[HAVE_IF_PACKET=yes],
[HAVE_IF_PACKET=no])
AM_CONDITIONAL([HAVE_IF_PACKET], [test "$HAVE_IF_PACKET" = yes])
if test "$HAVE_IF_PACKET" = yes; then
AC_DEFINE([HAVE_IF_PACKET], [1],
[Define to 1 if net/if_packet.h is available.])
fi])
2012-07-25 22:51:05 +02:00
dnl Checks for net/if_dl.h.
2013-03-14 15:20:55 -07:00
dnl
2013-05-21 17:50:02 +09:00
dnl (We use this as a proxy for checking whether we're building on FreeBSD
dnl or NetBSD.)
2012-06-29 21:11:24 +00:00
AC_DEFUN([OVS_CHECK_IF_DL],
[AC_CHECK_HEADER([net/if_dl.h],
[HAVE_IF_DL=yes],
[HAVE_IF_DL=no])
AM_CONDITIONAL([HAVE_IF_DL], [test "$HAVE_IF_DL" = yes])
if test "$HAVE_IF_DL" = yes; then
AC_DEFINE([HAVE_IF_DL], [1],
[Define to 1 if net/if_dl.h is available.])
2013-03-14 15:20:55 -07:00
2013-05-21 17:50:02 +09:00
# On these platforms we use libpcap to access network devices.
2013-03-14 15:20:55 -07:00
AC_SEARCH_LIBS([pcap_open_live], [pcap])
2012-06-29 21:11:24 +00:00
fi])
2009-06-10 14:16:40 -07:00
dnl Checks for buggy strtok_r.
dnl
dnl Some versions of glibc 2.7 has a bug in strtok_r when compiling
dnl with optimization that can cause segfaults:
dnl
dnl http://sources.redhat.com/bugzilla/show_bug.cgi?id=5614.
AC_DEFUN([OVS_CHECK_STRTOK_R],
[AC_CACHE_CHECK(
[whether strtok_r macro segfaults on some inputs],
[ovs_cv_strtok_r_bug],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([#include <stdio.h>
#include <string.h>
],
[[char string[] = ":::";
char *save_ptr = (char *) 0xc0ffee;
char *token1, *token2;
token1 = strtok_r(string, ":", &save_ptr);
token2 = strtok_r(NULL, ":", &save_ptr);
2010-01-25 10:32:39 -08:00
freopen ("/dev/null", "w", stdout);
2009-06-10 14:16:40 -07:00
printf ("%s %s\n", token1, token2);
return 0;
]])],
[ovs_cv_strtok_r_bug=no],
[ovs_cv_strtok_r_bug=yes],
[ovs_cv_strtok_r_bug=yes])])
if test $ovs_cv_strtok_r_bug = yes; then
AC_DEFINE([HAVE_STRTOK_R_BUG], [1],
[Define if strtok_r macro segfaults on some inputs])
fi
])
2009-07-08 13:19:16 -07:00
dnl ----------------------------------------------------------------------
dnl These macros are from GNU PSPP, with the following original license:
dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
2013-06-24 12:25:48 -07:00
AC_DEFUN([_OVS_CHECK_CC_OPTION], [dnl
2014-05-28 16:56:29 -07:00
m4_define([ovs_cv_name], [ovs_cv_[]m4_translit([$1], [-=], [__])])dnl
2009-07-08 13:19:16 -07:00
AC_CACHE_CHECK([whether $CC accepts $1], [ovs_cv_name],
[ovs_save_CFLAGS="$CFLAGS"
2013-06-24 12:25:48 -07:00
dnl Include -Werror in the compiler options, because without -Werror
dnl clang's GCC-compatible compiler driver does not return a failure
dnl exit status even though it complains about options it does not
dnl understand.
CFLAGS="$CFLAGS $WERROR $1"
2009-07-08 13:19:16 -07:00
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [ovs_cv_name[]=yes], [ovs_cv_name[]=no])
CFLAGS="$ovs_save_CFLAGS"])
if test $ovs_cv_name = yes; then
2009-11-18 16:27:55 -08:00
m4_if([$2], [], [:], [$2])
2009-07-08 13:19:16 -07:00
else
m4_if([$3], [], [:], [$3])
fi
])
2013-06-24 12:25:48 -07:00
dnl OVS_CHECK_WERROR
dnl
dnl Check whether the C compiler accepts -Werror.
dnl Sets $WERROR to "-Werror", if so, and otherwise to the empty string.
AC_DEFUN([OVS_CHECK_WERROR],
[WERROR=
_OVS_CHECK_CC_OPTION([-Werror], [WERROR=-Werror])])
dnl OVS_CHECK_CC_OPTION([OPTION], [ACTION-IF-ACCEPTED], [ACTION-IF-REJECTED])
dnl Check whether the given C compiler OPTION is accepted.
dnl If so, execute ACTION-IF-ACCEPTED, otherwise ACTION-IF-REJECTED.
AC_DEFUN([OVS_CHECK_CC_OPTION],
[AC_REQUIRE([OVS_CHECK_WERROR])
_OVS_CHECK_CC_OPTION([$1], [$2], [$3])])
2009-07-08 13:19:16 -07:00
dnl OVS_ENABLE_OPTION([OPTION])
dnl Check whether the given C compiler OPTION is accepted.
2009-11-19 13:25:42 -08:00
dnl If so, add it to WARNING_FLAGS.
2009-07-08 13:19:16 -07:00
dnl Example: OVS_ENABLE_OPTION([-Wdeclaration-after-statement])
AC_DEFUN([OVS_ENABLE_OPTION],
2009-11-19 13:25:42 -08:00
[OVS_CHECK_CC_OPTION([$1], [WARNING_FLAGS="$WARNING_FLAGS $1"])
AC_SUBST([WARNING_FLAGS])])
2009-11-20 09:45:26 -08:00
dnl OVS_CONDITIONAL_CC_OPTION([OPTION], [CONDITIONAL])
dnl Check whether the given C compiler OPTION is accepted.
dnl If so, enable the given Automake CONDITIONAL.
dnl Example: OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED])
AC_DEFUN([OVS_CONDITIONAL_CC_OPTION],
[OVS_CHECK_CC_OPTION(
[$1], [ovs_have_cc_option=yes], [ovs_have_cc_option=no])
AM_CONDITIONAL([$2], [test $ovs_have_cc_option = yes])])
2009-07-08 13:19:16 -07:00
dnl ----------------------------------------------------------------------
2011-02-22 14:47:19 -08:00
dnl Check for too-old XenServer.
AC_DEFUN([OVS_CHECK_XENSERVER_VERSION],
[AC_CACHE_CHECK([XenServer release], [ovs_cv_xsversion],
[if test -e /etc/redhat-release; then
ovs_cv_xsversion=`sed -n 's/^XenServer DDK release \([[^-]]*\)-.*/\1/p' /etc/redhat-release`
fi
if test -z "$ovs_cv_xsversion"; then
ovs_cv_xsversion=none
fi])
case $ovs_cv_xsversion in
none)
;;
[[1-9]][[0-9]]* | dnl XenServer 10 or later
[[6-9]]* | dnl XenServer 6 or later
5.[[7-9]]* | dnl XenServer 5.7 or later
5.6.[[1-9]][[0-9]][[0-9]][[0-9]]* | dnl XenServer 5.6.1000 or later
5.6.[[2-9]][[0-9]][[0-9]]* | dnl XenServer 5.6.200 or later
5.6.1[[0-9]][[0-9]]) dnl Xenserver 5.6.100 or later
;;
*)
AC_MSG_ERROR([This appears to be XenServer $ovs_cv_xsversion, but only XenServer 5.6.100 or later is supported. (If you are really using a supported version of XenServer, you may override this error message by specifying 'ovs_cv_xsversion=5.6.100' on the "configure" command line.)])
;;
esac])
2011-05-06 13:00:49 -07:00
dnl OVS_MAKE_HAS_IF([if-true], [if-false])
dnl
dnl Checks whether make has the GNU make $(if condition,then,else) extension.
dnl Runs 'if-true' if so, 'if-false' otherwise.
2012-07-25 10:28:38 -07:00
AC_DEFUN([OVS_CHECK_MAKE_IF],
2011-05-06 13:00:49 -07:00
[AC_CACHE_CHECK(
[whether ${MAKE-make} has GNU make \$(if) extension],
[ovs_cv_gnu_make_if],
[cat <<'EOF' > conftest.mk
conftest.out:
2014-05-19 07:52:21 -07:00
echo $(if x,y,z) > conftest.out
2011-05-06 13:00:49 -07:00
.PHONY: all
EOF
rm -f conftest.out
AS_ECHO(["$as_me:$LINENO: invoking ${MAKE-make} -f conftest.mk all:"]) >&AS_MESSAGE_LOG_FD 2>&1
${MAKE-make} -f conftest.mk conftest.out >&AS_MESSAGE_LOG_FD 2>&1
AS_ECHO(["$as_me:$LINENO: conftest.out contains:"]) >&AS_MESSAGE_LOG_FD 2>&1
cat conftest.out >&AS_MESSAGE_LOG_FD 2>&1
result=`cat conftest.out`
rm -f conftest.mk conftest.out
if test "X$result" = "Xy"; then
ovs_cv_gnu_make_if=yes
else
ovs_cv_gnu_make_if=no
2012-07-25 10:28:38 -07:00
fi])])
2011-05-06 13:00:49 -07:00
2012-07-25 10:25:55 -07:00
dnl OVS_CHECK_GNU_MAKE
dnl
dnl Checks whether make is GNU make (because Linux kernel Makefiles
dnl only work with GNU make).
AC_DEFUN([OVS_CHECK_GNU_MAKE],
[AC_CACHE_CHECK(
[whether ${MAKE-make} is GNU make],
[ovs_cv_gnu_make],
[rm -f conftest.out
AS_ECHO(["$as_me:$LINENO: invoking ${MAKE-make} --version:"]) >&AS_MESSAGE_LOG_FD 2>&1
${MAKE-make} --version >conftest.out 2>&1
cat conftest.out >&AS_MESSAGE_LOG_FD 2>&1
result=`cat conftest.out`
rm -f conftest.mk conftest.out
case $result in # (
GNU*) ovs_cv_gnu_make=yes ;; # (
*) ovs_cv_gnu_make=no ;;
esac])
AM_CONDITIONAL([GNU_MAKE], [test $ovs_cv_gnu_make = yes])])
2011-07-11 13:57:58 -07:00
dnl OVS_CHECK_SPARSE_TARGET
dnl
dnl The "cgcc" script from "sparse" isn't very good at detecting the
dnl target for which the code is being built. This helps it out.
AC_DEFUN([OVS_CHECK_SPARSE_TARGET],
[AC_CACHE_CHECK(
[target hint for cgcc],
[ac_cv_sparse_target],
[AS_CASE([`$CC -dumpmachine 2>/dev/null`],
[i?86-* | athlon-*], [ac_cv_sparse_target=x86],
[x86_64-*], [ac_cv_sparse_target=x86_64],
[ac_cv_sparse_target=other])])
AS_CASE([$ac_cv_sparse_target],
[x86], [SPARSEFLAGS= CGCCFLAGS=-target=i86],
[x86_64], [SPARSEFLAGS=-m64 CGCCFLAGS=-target=x86_64],
[SPARSEFLAGS= CGCCFLAGS=])
AC_SUBST([SPARSEFLAGS])
AC_SUBST([CGCCFLAGS])])
2013-04-05 16:56:52 -07:00
dnl OVS_SPARSE_EXTRA_INCLUDES
dnl
dnl The cgcc script from "sparse" does not search gcc's default
dnl search path. Get the default search path from GCC and pass
dnl them to sparse.
AC_DEFUN([OVS_SPARSE_EXTRA_INCLUDES],
AC_SUBST([SPARSE_EXTRA_INCLUDES],
[`$CC -v -E - </dev/null 2>&1 >/dev/null | sed -n -e '/^#include.*search.*starts.*here:/,/^End.*of.*search.*list\./s/^ \(.*\)/-I \1/p' |grep -v /usr/lib | grep -x -v '\-I /usr/include' | tr \\\n ' ' `] ))
2011-05-06 13:00:49 -07:00
dnl OVS_ENABLE_SPARSE
AC_DEFUN([OVS_ENABLE_SPARSE],
2011-07-11 13:57:58 -07:00
[AC_REQUIRE([OVS_CHECK_SPARSE_TARGET])
2012-07-25 10:28:38 -07:00
AC_REQUIRE([OVS_CHECK_MAKE_IF])
2013-04-05 16:56:52 -07:00
AC_REQUIRE([OVS_SPARSE_EXTRA_INCLUDES])
2012-07-25 10:28:38 -07:00
: ${SPARSE=sparse}
AC_SUBST([SPARSE])
AC_CONFIG_COMMANDS_PRE(
[if test $ovs_cv_gnu_make_if = yes; then
2013-12-13 18:54:28 +01:00
CC='$(if $(C),env REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS) $(SPARSE_EXTRA_INCLUDES) " cgcc $(CGCCFLAGS),'"$CC"')'
2012-07-25 10:28:38 -07:00
fi])])
2013-08-01 09:35:56 -07:00
dnl OVS_PTHREAD_SET_NAME
dnl
dnl This checks for three known variants of pthreads functions for setting
dnl the name of the current thread:
dnl
dnl glibc: int pthread_setname_np(pthread_t, const char *name);
dnl NetBSD: int pthread_setname_np(pthread_t, const char *format, void *arg);
dnl FreeBSD: int pthread_set_name_np(pthread_t, const char *name);
dnl
dnl For glibc and FreeBSD, the arguments are just a thread and its name. For
dnl NetBSD, 'format' is a printf() format string and 'arg' is an argument to
dnl provide to it.
dnl
dnl This macro defines:
dnl
dnl glibc: HAVE_GLIBC_PTHREAD_SETNAME_NP
dnl NetBSD: HAVE_NETBSD_PTHREAD_SETNAME_NP
dnl FreeBSD: HAVE_PTHREAD_SET_NAME_NP
AC_DEFUN([OVS_CHECK_PTHREAD_SET_NAME],
[AC_CHECK_FUNCS([pthread_set_name_np])
if test $ac_cv_func_pthread_set_name_np != yes; then
AC_CACHE_CHECK(
[for pthread_setname_np() variant],
[ovs_cv_pthread_setname_np],
[AC_LINK_IFELSE(
2014-05-09 13:28:49 +09:00
[AC_LANG_PROGRAM([#include <pthread.h>
2013-08-01 09:35:56 -07:00
], [pthread_setname_np(pthread_self(), "name");])],
2014-05-09 13:28:49 +09:00
[ovs_cv_pthread_setname_np=glibc],
2013-08-01 09:35:56 -07:00
[AC_LINK_IFELSE(
2014-05-09 13:28:49 +09:00
[AC_LANG_PROGRAM([#include <pthread.h>
2013-08-01 09:35:56 -07:00
], [pthread_setname_np(pthread_self(), "%s", "name");])],
[ovs_cv_pthread_setname_np=netbsd],
2014-05-09 13:28:49 +09:00
[ovs_cv_pthread_setname_np=none])])])
2013-08-01 09:35:56 -07:00
case $ovs_cv_pthread_setname_np in # (
glibc)
2014-05-09 13:28:49 +09:00
AC_DEFINE(
[HAVE_GLIBC_PTHREAD_SETNAME_NP], [1],
[Define to 1 if pthread_setname_np() is available and takes 2 parameters (like glibc).])
;; # (
2013-08-01 09:35:56 -07:00
netbsd)
2014-05-09 13:28:49 +09:00
AC_DEFINE(
[HAVE_NETBSD_PTHREAD_SETNAME_NP], [1],
[Define to 1 if pthread_setname_np() is available and takes 3 parameters (like NetBSD).])
;;
2013-08-01 09:35:56 -07:00
esac
fi])
2014-01-23 15:35:22 -08:00
dnl OVS_CHECK_LINUX_HOST.
dnl
dnl Checks whether we're building for a Linux host, based on the presence of
dnl the __linux__ preprocessor symbol, and sets up an Automake conditional
dnl LINUX based on the result.
AC_DEFUN([OVS_CHECK_LINUX_HOST],
[AC_CACHE_CHECK(
[whether __linux__ is defined],
[ovs_cv_linux],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([enum { LINUX = __linux__};], [])],
[ovs_cv_linux=true],
[ovs_cv_linux=false])])
AM_CONDITIONAL([LINUX], [$ovs_cv_linux])])