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