3 # Copyright (c) 2008, 2009 Nicira Networks.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 dnl Checks for --enable-ndebug and defines NDEBUG if it is specified.
18 AC_DEFUN([OVS_CHECK_NDEBUG],
21 [AC_HELP_STRING([--enable-ndebug],
22 [Disable debugging features for max performance])],
23 [case "${enableval}" in
26 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;;
29 AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])])
31 dnl Checks for Netlink support.
32 AC_DEFUN([OVS_CHECK_NETLINK],
33 [AC_CHECK_HEADER([linux/netlink.h],
36 [#include <sys/socket.h>
37 #include <linux/types.h>
39 AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes])
40 if test "$HAVE_NETLINK" = yes; then
41 AC_DEFINE([HAVE_NETLINK], [1],
42 [Define to 1 if Netlink protocol is available.])
45 dnl Checks for OpenSSL, if --enable-ssl is passed in.
46 AC_DEFUN([OVS_CHECK_OPENSSL],
49 [AC_HELP_STRING([--enable-ssl],
50 [Enable ssl support (requires libssl)])],
51 [case "${enableval}" in
54 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;;
58 if test "$ssl" = true; then
59 dnl Make sure that pkg-config is installed.
60 m4_pattern_forbid([PKG_CHECK_MODULES])
61 PKG_CHECK_MODULES([SSL], [libssl],
64 AC_MSG_WARN([Cannot find libssl:
68 OpenFlow connections over SSL will not be supported.])])
71 AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes])
72 if test "$HAVE_OPENSSL" = yes; then
73 AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
76 dnl Checks for libraries needed by lib/fault.c.
77 AC_DEFUN([OVS_CHECK_FAULT_LIBS],
78 [AC_CHECK_LIB([dl], [dladdr], [FAULT_LIBS=-ldl])
79 AC_SUBST([FAULT_LIBS])])
81 dnl Checks for libraries needed by lib/socket-util.c.
82 AC_DEFUN([OVS_CHECK_SOCKET_LIBS],
83 [AC_CHECK_LIB([socket], [connect])
84 AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])])
86 dnl Checks for the directory in which to store the PKI.
87 AC_DEFUN([OVS_CHECK_PKIDIR],
90 AC_HELP_STRING([--with-pkidir=DIR],
91 [PKI hierarchy directory [[DATADIR/openvswitch/pki]]]),
93 [PKIDIR='${pkgdatadir}/pki'])
96 dnl Checks for the directory in which to store pidfiles.
97 AC_DEFUN([OVS_CHECK_RUNDIR],
100 AC_HELP_STRING([--with-rundir=DIR],
101 [directory used for pidfiles [[LOCALSTATEDIR/run]]]),
103 [RUNDIR='${localstatedir}/run'])
106 dnl Checks for the directory in which to store logs.
107 AC_DEFUN([OVS_CHECK_LOGDIR],
110 AC_HELP_STRING([--with-logdir=DIR],
111 [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]),
113 [LOGDIR='${localstatedir}/log/${PACKAGE}'])
116 dnl Checks for __malloc_hook, etc., supported by glibc.
117 AC_DEFUN([OVS_CHECK_MALLOC_HOOKS],
119 [whether libc supports hooks for malloc and related functions],
120 [ovs_cv_malloc_hooks],
125 [(void) __malloc_hook;
126 (void) __realloc_hook;
127 (void) __free_hook;])],
128 [ovs_cv_malloc_hooks=yes],
129 [ovs_cv_malloc_hooks=no])])
130 if test $ovs_cv_malloc_hooks = yes; then
131 AC_DEFINE([HAVE_MALLOC_HOOKS], [1],
132 [Define to 1 if you have __malloc_hook, __realloc_hook, and
133 __free_hook in <malloc.h>.])
136 dnl Checks for valgrind/valgrind.h.
137 AC_DEFUN([OVS_CHECK_VALGRIND],
138 [AC_CHECK_HEADERS([valgrind/valgrind.h])])
140 dnl Searches for a directory to put lockfiles for tty devices.
141 dnl Defines C preprocessor variable TTY_LOCK_DIR to a quoted string
142 dnl for that directory.
143 AC_DEFUN([OVS_CHECK_TTY_LOCK_DIR],
144 [AC_CACHE_CHECK([directory used for serial device lockfiles],
145 [ovs_cv_path_tty_locks],
146 [# This list of candidate directories is from minicom.
147 ovs_cv_path_tty_locks=none
148 for dir in /etc/locks /var/lock /usr/spool/locks \
149 /var/spool/locks /var/spool/lock \
150 /usr/spool/uucp /var/spool/uucp /var/run; do
151 if test -d $dir; then
152 ovs_cv_path_tty_locks=$dir
156 if test "$ovs_cv_path_tty_locks" = none; then
157 AC_MSG_ERROR([cannot find a directory for tty locks])
159 AC_DEFINE_UNQUOTED([TTY_LOCK_DIR], "$ovs_cv_path_tty_locks",
160 [Directory used for serial device lockfiles])])
162 dnl The following check is adapted from GNU PSPP.
163 dnl It searches for the ncurses library. If it finds it, it sets
164 dnl HAVE_CURSES to yes and sets NCURSES_LIBS and NCURSES_CFLAGS
165 dnl appropriate. Otherwise, it sets HAVE_CURSES to no.
166 AC_DEFUN([OVS_CHECK_CURSES],
167 [if test "$cross_compiling" != yes; then
168 AC_CHECK_PROGS([NCURSES_CONFIG], [ncurses5-config ncurses8-config])
170 if test "$NCURSES_CONFIG" = ""; then
171 AC_SEARCH_LIBS([tgetent], [ncurses],
172 [AC_CHECK_HEADERS([term.h curses.h],
177 CFLAGS="$CFLAGS $($NCURSES_CONFIG --cflags)"
178 AC_CHECK_HEADERS([term.h curses.h],
182 if test "$HAVE_CURSES" = yes; then
183 NCURSES_LIBS=$($NCURSES_CONFIG --libs)
184 NCURSES_CFLAGS=$($NCURSES_CONFIG --cflags)
185 AC_SUBST(NCURSES_CFLAGS)
186 AC_SUBST(NCURSES_LIBS)
189 AM_CONDITIONAL([HAVE_CURSES], [test "$HAVE_CURSES" = yes])])
191 dnl Checks for linux/vt.h.
192 AC_DEFUN([OVS_CHECK_LINUX_VT_H],
193 [AC_CHECK_HEADER([linux/vt.h],
194 [HAVE_LINUX_VT_H=yes],
195 [HAVE_LINUX_VT_H=no])
196 AM_CONDITIONAL([HAVE_LINUX_VT_H], [test "$HAVE_LINUX_VT_H" = yes])
197 if test "$HAVE_LINUX_VT_H" = yes; then
198 AC_DEFINE([HAVE_LINUX_VT_H], [1],
199 [Define to 1 if linux/vt.h is available.])
202 dnl Checks for libpcre.
203 AC_DEFUN([OVS_CHECK_PCRE],
204 [dnl Make sure that pkg-config is installed.
205 m4_pattern_forbid([PKG_CHECK_MODULES])
206 PKG_CHECK_MODULES([PCRE], [libpcre], [HAVE_PCRE=yes], [HAVE_PCRE=no])
207 AM_CONDITIONAL([HAVE_PCRE], [test "$HAVE_PCRE" = yes])
208 if test "$HAVE_PCRE" = yes; then
209 AC_DEFINE([HAVE_PCRE], [1], [Define to 1 if libpcre is installed.])