3 # Copyright (c) 2008, 2009, 2010 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-coverage and updates CFLAGS and LDFLAGS appropriately.
18 AC_DEFUN([OVS_CHECK_COVERAGE],
19 [AC_REQUIRE([AC_PROG_CC])
22 [AC_HELP_STRING([--enable-coverage],
23 [Enable gcov coverage tool.])],
24 [case "${enableval}" in
25 (lcov) coverage=true lcov=true ;;
26 (yes) coverage=true lcov=false ;;
27 (no) coverage=false lcov=false ;;
28 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-coverage]) ;;
30 [coverage=false lcov=false])
32 CFLAGS="$CFLAGS -O0 --coverage"
33 LDFLAGS="$LDFLAGS --coverage"
36 if lcov --version >/dev/null 2>&1; then :; else
37 AC_MSG_ERROR([--enable-coverage=lcov was specified but lcov is not in \$PATH])
40 AC_SUBST([LCOV], [$lcov])])
42 dnl Checks for --enable-ndebug and defines NDEBUG if it is specified.
43 AC_DEFUN([OVS_CHECK_NDEBUG],
46 [AC_HELP_STRING([--enable-ndebug],
47 [Disable debugging features for max performance])],
48 [case "${enableval}" in
51 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;;
54 AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])])
56 dnl Checks for Netlink support.
57 AC_DEFUN([OVS_CHECK_NETLINK],
58 [AC_CHECK_HEADER([linux/netlink.h],
61 [#include <sys/socket.h>
62 #include <linux/types.h>
64 AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes])
65 if test "$HAVE_NETLINK" = yes; then
66 AC_DEFINE([HAVE_NETLINK], [1],
67 [Define to 1 if Netlink protocol is available.])
70 dnl Checks for OpenSSL, if --enable-ssl is passed in.
71 AC_DEFUN([OVS_CHECK_OPENSSL],
74 [AC_HELP_STRING([--enable-ssl],
75 [Enable ssl support (requires libssl)])],
76 [case "${enableval}" in
79 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;;
83 if test "$ssl" = true; then
84 dnl Make sure that pkg-config is installed.
85 m4_pattern_forbid([PKG_CHECK_MODULES])
86 PKG_CHECK_MODULES([SSL], [libssl],
89 AC_MSG_WARN([Cannot find libssl:
93 OpenFlow connections over SSL will not be supported.])])
97 AC_SUBST([HAVE_OPENSSL])
98 AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes])
99 if test "$HAVE_OPENSSL" = yes; then
100 AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
103 dnl Checks for libraries needed by lib/socket-util.c.
104 AC_DEFUN([OVS_CHECK_SOCKET_LIBS],
105 [AC_CHECK_LIB([socket], [connect])
106 AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])])
108 dnl Checks for the directory in which to store the PKI.
109 AC_DEFUN([OVS_CHECK_PKIDIR],
112 AC_HELP_STRING([--with-pkidir=DIR],
113 [PKI hierarchy directory [[DATADIR/openvswitch/pki]]]),
115 [PKIDIR='${pkgdatadir}/pki'])
118 dnl Checks for the directory in which to store pidfiles.
119 AC_DEFUN([OVS_CHECK_RUNDIR],
122 AC_HELP_STRING([--with-rundir=DIR],
123 [directory used for pidfiles [[LOCALSTATEDIR/run]]]),
125 [RUNDIR='${localstatedir}/run'])
128 dnl Checks for the directory in which to store logs.
129 AC_DEFUN([OVS_CHECK_LOGDIR],
132 AC_HELP_STRING([--with-logdir=DIR],
133 [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]),
135 [LOGDIR='${localstatedir}/log/${PACKAGE}'])
138 dnl Checks for __malloc_hook, etc., supported by glibc.
139 AC_DEFUN([OVS_CHECK_MALLOC_HOOKS],
141 [whether libc supports hooks for malloc and related functions],
142 [ovs_cv_malloc_hooks],
147 [(void) __malloc_hook;
148 (void) __realloc_hook;
149 (void) __free_hook;])],
150 [ovs_cv_malloc_hooks=yes],
151 [ovs_cv_malloc_hooks=no])])
152 if test $ovs_cv_malloc_hooks = yes; then
153 AC_DEFINE([HAVE_MALLOC_HOOKS], [1],
154 [Define to 1 if you have __malloc_hook, __realloc_hook, and
155 __free_hook in <malloc.h>.])
158 dnl Checks for valgrind/valgrind.h.
159 AC_DEFUN([OVS_CHECK_VALGRIND],
160 [AC_CHECK_HEADERS([valgrind/valgrind.h])])
162 dnl Searches for a directory to put lockfiles for tty devices.
163 dnl Defines C preprocessor variable TTY_LOCK_DIR to a quoted string
164 dnl for that directory.
165 AC_DEFUN([OVS_CHECK_TTY_LOCK_DIR],
166 [AC_CACHE_CHECK([directory used for serial device lockfiles],
167 [ovs_cv_path_tty_locks],
168 [# This list of candidate directories is from minicom.
169 ovs_cv_path_tty_locks=none
170 for dir in /etc/locks /var/lock /usr/spool/locks \
171 /var/spool/locks /var/spool/lock \
172 /usr/spool/uucp /var/spool/uucp /var/run; do
173 if test -d $dir; then
174 ovs_cv_path_tty_locks=$dir
178 if test "$ovs_cv_path_tty_locks" = none; then
179 AC_MSG_ERROR([cannot find a directory for tty locks])
181 AC_DEFINE_UNQUOTED([TTY_LOCK_DIR], "$ovs_cv_path_tty_locks",
182 [Directory used for serial device lockfiles])])
184 dnl The following check is adapted from GNU PSPP.
185 dnl It searches for the ncurses library. If it finds it, it sets
186 dnl HAVE_CURSES to yes and sets NCURSES_LIBS and NCURSES_CFLAGS
187 dnl appropriate. Otherwise, it sets HAVE_CURSES to no.
188 AC_DEFUN([OVS_CHECK_CURSES],
189 [if test "$cross_compiling" != yes; then
190 AC_CHECK_PROGS([NCURSES_CONFIG], [ncurses5-config ncurses8-config])
192 if test "$NCURSES_CONFIG" = ""; then
193 AC_SEARCH_LIBS([tgetent], [ncurses],
194 [AC_CHECK_HEADERS([term.h curses.h],
199 CFLAGS="$CFLAGS $($NCURSES_CONFIG --cflags)"
200 AC_CHECK_HEADERS([term.h curses.h],
204 if test "$HAVE_CURSES" = yes; then
205 NCURSES_LIBS=$($NCURSES_CONFIG --libs)
206 NCURSES_CFLAGS=$($NCURSES_CONFIG --cflags)
207 AC_SUBST(NCURSES_CFLAGS)
208 AC_SUBST(NCURSES_LIBS)
211 AM_CONDITIONAL([HAVE_CURSES], [test "$HAVE_CURSES" = yes])])
213 dnl Checks for linux/vt.h.
214 AC_DEFUN([OVS_CHECK_LINUX_VT_H],
215 [AC_CHECK_HEADER([linux/vt.h],
216 [HAVE_LINUX_VT_H=yes],
217 [HAVE_LINUX_VT_H=no])
218 AM_CONDITIONAL([HAVE_LINUX_VT_H], [test "$HAVE_LINUX_VT_H" = yes])
219 if test "$HAVE_LINUX_VT_H" = yes; then
220 AC_DEFINE([HAVE_LINUX_VT_H], [1],
221 [Define to 1 if linux/vt.h is available.])
224 dnl Checks for libpcre.
225 AC_DEFUN([OVS_CHECK_PCRE],
226 [dnl Make sure that pkg-config is installed.
227 m4_pattern_forbid([PKG_CHECK_MODULES])
228 PKG_CHECK_MODULES([PCRE], [libpcre >= 7.2], [HAVE_PCRE=yes], [HAVE_PCRE=no])
229 AM_CONDITIONAL([HAVE_PCRE], [test "$HAVE_PCRE" = yes])
230 if test "$HAVE_PCRE" = yes; then
231 AC_DEFINE([HAVE_PCRE], [1], [Define to 1 if libpcre is installed.])
234 dnl Checks for Python 2.x, x >= 4.
235 AC_DEFUN([OVS_CHECK_PYTHON],
237 [for Python 2.x for x >= 4],
239 [if test -n "$PYTHON"; then
240 ovs_cv_python=$PYTHON
243 for binary in python python2.4 python2.5; do
244 ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
247 test -z "$dir" && dir=.
248 if test -x $dir/$binary && $dir/$binary -c 'import sys
249 if sys.hexversion >= 0x02040000 and sys.hexversion < 0x03000000:
253 ovs_cv_python=$dir/$binary
259 AC_SUBST([HAVE_PYTHON])
260 AM_MISSING_PROG([PYTHON], [python])
261 if test $ovs_cv_python != no; then
262 PYTHON=$ovs_cv_python
267 AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])