Add support for listing and deleting entries based on an output port.
[sliver-openvswitch.git] / m4 / libopenflow.m4
1 # -*- autoconf -*-
2
3 # Copyright (c) 2008 The Board of Trustees of The Leland Stanford
4 # Junior University
5 #
6 # We are making the OpenFlow specification and associated documentation
7 # (Software) available for public use and benefit with the expectation
8 # that others will use, modify and enhance the Software and contribute
9 # those enhancements back to the community. However, since we would
10 # like to make the Software available for broadest use, with as few
11 # restrictions as possible permission is hereby granted, free of
12 # charge, to any person obtaining a copy of this Software to deal in
13 # the Software under the copyrights without restriction, including
14 # without limitation the rights to use, copy, modify, merge, publish,
15 # distribute, sublicense, and/or sell copies of the Software, and to
16 # permit persons to whom the Software is furnished to do so, subject to
17 # the following conditions:
18 #
19 # The above copyright notice and this permission notice shall be
20 # included in all copies or substantial portions of the Software.
21 #
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 # NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
26 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 # SOFTWARE.
30 #
31 # The name and trademarks of copyright holder(s) may NOT be used in
32 # advertising or publicity pertaining to the Software or any
33 # derivatives without specific, written prior permission.
34
35 dnl Checks for --enable-ndebug and defines NDEBUG if it is specified.
36 AC_DEFUN([OFP_CHECK_NDEBUG],
37   [AC_ARG_ENABLE(
38      [ndebug],
39      [AC_HELP_STRING([--enable-ndebug], 
40                      [Disable debugging features for max performance])],
41      [case "${enableval}" in
42         (yes) ndebug=true ;;
43         (no)  ndebug=false ;;
44         (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;;
45       esac],
46      [ndebug=false])
47    AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])])
48
49 dnl Checks for Netlink support.
50 AC_DEFUN([OFP_CHECK_NETLINK],
51   [AC_CHECK_HEADER([linux/netlink.h],
52                    [HAVE_NETLINK=yes],
53                    [HAVE_NETLINK=no],
54                    [#include <sys/socket.h>
55    #include <linux/types.h>
56    ])
57    AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes])
58    if test "$HAVE_NETLINK" = yes; then
59       AC_DEFINE([HAVE_NETLINK], [1],
60                 [Define to 1 if Netlink protocol is available.])
61    fi])
62
63 dnl Checks for OpenSSL, if --enable-ssl is passed in.
64 AC_DEFUN([OFP_CHECK_OPENSSL],
65   [AC_ARG_ENABLE(
66      [ssl],
67      [AC_HELP_STRING([--enable-ssl], 
68                      [Enable ssl support (requires libssl)])],
69      [case "${enableval}" in
70         (yes) ssl=true ;;
71         (no)  ssl=false ;;
72         (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;;
73       esac],
74      [ssl=false])
75
76    if test "$ssl" = true; then
77    dnl Make sure that pkg-config is installed.
78    m4_pattern_forbid([PKG_CHECK_MODULES])
79    PKG_CHECK_MODULES([SSL], [libssl], 
80      [HAVE_OPENSSL=yes],
81      [HAVE_OPENSSL=no
82       AC_MSG_WARN([Cannot find libssl:
83
84    $SSL_PKG_ERRORS
85
86    OpenFlow will not support SSL connections.])])
87
88    fi
89    AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes])
90    if test "$HAVE_OPENSSL" = yes; then
91       AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
92    fi])
93
94 dnl Checks for --enable-snat and defines SUPPORT_SNAT if it is specified.
95 AC_DEFUN([OFP_CHECK_SNAT],
96   [AC_ARG_ENABLE(
97      [snat],
98      [AC_HELP_STRING([--enable-snat], 
99                      [Enable support for source-NAT action])],
100      [case "${enableval}" in
101         (yes) snat=true ;;
102         (no)  snat=false ;;
103         (*) AC_MSG_ERROR([bad value ${enableval} for --enable-snat]) ;;
104       esac],
105      [snat=false])
106    AM_CONDITIONAL([SUPPORT_SNAT], [test x$snat = xtrue])
107    if test x$snat = xtrue; then
108       AC_DEFINE([SUPPORT_SNAT], [1], [Define to 1 if SNAT is desired.])
109       SUPPORT_SNAT=-DSUPPORT_SNAT
110       AC_SUBST([SUPPORT_SNAT])
111    fi])
112
113 dnl Checks for libraries needed by lib/fault.c.
114 AC_DEFUN([OFP_CHECK_FAULT_LIBS],
115   [AC_CHECK_LIB([dl], [dladdr], [FAULT_LIBS=-ldl])
116    AC_SUBST([FAULT_LIBS])])
117
118 dnl Checks for libraries needed by lib/socket-util.c.
119 AC_DEFUN([OFP_CHECK_SOCKET_LIBS],
120   [AC_CHECK_LIB([socket], [connect])
121    AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])])
122
123 dnl Checks for the directory in which to store the PKI.
124 AC_DEFUN([OFP_CHECK_PKIDIR],
125   [AC_ARG_WITH(
126      [pkidir], 
127      AC_HELP_STRING([--with-pkidir=DIR], 
128                     [PKI hierarchy directory [[DATADIR/openflow/pki]]]),
129      [PKIDIR=$withval],
130      [PKIDIR='${pkgdatadir}/pki'])
131    AC_SUBST([PKIDIR])])
132
133 dnl Checks for the directory in which to store pidfiles.
134 AC_DEFUN([OFP_CHECK_RUNDIR],
135   [AC_ARG_WITH(
136      [rundir], 
137      AC_HELP_STRING([--with-rundir=DIR], 
138                     [directory used for pidfiles [[LOCALSTATEDIR/run]]]),
139      [RUNDIR=$withval],
140      [RUNDIR='${localstatedir}/run'])
141    AC_SUBST([RUNDIR])])
142
143 dnl Checks for the directory in which to store logs.
144 AC_DEFUN([OFP_CHECK_LOGDIR],
145   [AC_ARG_WITH(
146      [logdir], 
147      AC_HELP_STRING([--with-logdir=DIR], 
148                     [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]),
149      [LOGDIR=$withval],
150      [LOGDIR='${localstatedir}/log/${PACKAGE}'])
151    AC_SUBST([LOGDIR])])
152
153 dnl Runs the checks required to include the headers in include/ and
154 dnl link against lib/libopenflow.a.
155 AC_DEFUN([OFP_CHECK_LIBOPENFLOW],
156   [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
157    AC_REQUIRE([OFP_CHECK_NDEBUG])
158    AC_REQUIRE([OFP_CHECK_NETLINK])
159    AC_REQUIRE([OFP_CHECK_OPENSSL])
160    AC_REQUIRE([OFP_CHECK_SNAT])
161    AC_REQUIRE([OFP_CHECK_FAULT_LIBS])
162    AC_REQUIRE([OFP_CHECK_SOCKET_LIBS])
163    AC_REQUIRE([OFP_CHECK_PKIDIR])
164    AC_REQUIRE([OFP_CHECK_RUNDIR])
165    AC_REQUIRE([OFP_CHECK_LOGDIR])
166    AC_CHECK_FUNCS([strlcpy])])
167