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|yes) coverage=true ;;
26 (no) coverage=false ;;
27 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-coverage]) ;;
31 CFLAGS="$CFLAGS -O0 --coverage"
32 LDFLAGS="$LDFLAGS --coverage"
35 dnl Checks for --enable-ndebug and defines NDEBUG if it is specified.
36 AC_DEFUN([OVS_CHECK_NDEBUG],
39 [AC_HELP_STRING([--enable-ndebug],
40 [Disable debugging features for max performance])],
41 [case "${enableval}" in
44 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;;
47 AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])])
49 dnl Checks for Netlink support.
50 AC_DEFUN([OVS_CHECK_NETLINK],
51 [AC_CHECK_HEADER([linux/netlink.h],
54 [#include <sys/socket.h>
55 #include <linux/types.h>
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.])
63 dnl Checks for OpenSSL, if --enable-ssl is passed in.
64 AC_DEFUN([OVS_CHECK_OPENSSL],
67 [AC_HELP_STRING([--enable-ssl],
68 [Enable ssl support (requires libssl)])],
69 [case "${enableval}" in
72 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;;
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],
82 AC_MSG_WARN([Cannot find libssl:
86 OpenFlow connections over SSL will not be supported.])])
90 AC_SUBST([HAVE_OPENSSL])
91 AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes])
92 if test "$HAVE_OPENSSL" = yes; then
93 AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
96 dnl Checks for libraries needed by lib/socket-util.c.
97 AC_DEFUN([OVS_CHECK_SOCKET_LIBS],
98 [AC_CHECK_LIB([socket], [connect])
99 AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])])
101 dnl Checks for the directory in which to store the PKI.
102 AC_DEFUN([OVS_CHECK_PKIDIR],
105 AC_HELP_STRING([--with-pkidir=DIR],
106 [PKI hierarchy directory [[DATADIR/openvswitch/pki]]]),
108 [PKIDIR='${pkgdatadir}/pki'])
111 dnl Checks for the directory in which to store pidfiles.
112 AC_DEFUN([OVS_CHECK_RUNDIR],
115 AC_HELP_STRING([--with-rundir=DIR],
116 [directory used for pidfiles
117 [[LOCALSTATEDIR/run/openvswitch]]]),
119 [RUNDIR='${localstatedir}/run/openvswitch'])
122 dnl Checks for the directory in which to store logs.
123 AC_DEFUN([OVS_CHECK_LOGDIR],
126 AC_HELP_STRING([--with-logdir=DIR],
127 [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]),
129 [LOGDIR='${localstatedir}/log/${PACKAGE}'])
132 dnl Checks for __malloc_hook, etc., supported by glibc.
133 AC_DEFUN([OVS_CHECK_MALLOC_HOOKS],
135 [whether libc supports hooks for malloc and related functions],
136 [ovs_cv_malloc_hooks],
141 [(void) __malloc_hook;
142 (void) __realloc_hook;
143 (void) __free_hook;])],
144 [ovs_cv_malloc_hooks=yes],
145 [ovs_cv_malloc_hooks=no])])
146 if test $ovs_cv_malloc_hooks = yes; then
147 AC_DEFINE([HAVE_MALLOC_HOOKS], [1],
148 [Define to 1 if you have __malloc_hook, __realloc_hook, and
149 __free_hook in <malloc.h>.])
152 dnl Checks for valgrind/valgrind.h.
153 AC_DEFUN([OVS_CHECK_VALGRIND],
154 [AC_CHECK_HEADERS([valgrind/valgrind.h])])
156 dnl Searches for a directory to put lockfiles for tty devices.
157 dnl Defines C preprocessor variable TTY_LOCK_DIR to a quoted string
158 dnl for that directory.
159 AC_DEFUN([OVS_CHECK_TTY_LOCK_DIR],
160 [AC_CACHE_CHECK([directory used for serial device lockfiles],
161 [ovs_cv_path_tty_locks],
162 [# This list of candidate directories is from minicom.
163 ovs_cv_path_tty_locks=none
164 for dir in /etc/locks /var/lock /usr/spool/locks \
165 /var/spool/locks /var/spool/lock \
166 /usr/spool/uucp /var/spool/uucp /var/run; do
167 if test -d $dir; then
168 ovs_cv_path_tty_locks=$dir
172 if test "$ovs_cv_path_tty_locks" = none; then
173 AC_MSG_ERROR([cannot find a directory for tty locks])
175 AC_DEFINE_UNQUOTED([TTY_LOCK_DIR], "$ovs_cv_path_tty_locks",
176 [Directory used for serial device lockfiles])])
178 dnl The following check is adapted from GNU PSPP.
179 dnl It searches for the ncurses library. If it finds it, it sets
180 dnl HAVE_CURSES to yes and sets NCURSES_LIBS and NCURSES_CFLAGS
181 dnl appropriate. Otherwise, it sets HAVE_CURSES to no.
182 AC_DEFUN([OVS_CHECK_CURSES],
183 [if test "$cross_compiling" != yes; then
184 AC_CHECK_PROGS([NCURSES_CONFIG], [ncurses5-config ncurses8-config])
186 if test "$NCURSES_CONFIG" = ""; then
187 AC_SEARCH_LIBS([tgetent], [ncurses],
188 [AC_CHECK_HEADERS([term.h curses.h],
193 CFLAGS="$CFLAGS $($NCURSES_CONFIG --cflags)"
194 AC_CHECK_HEADERS([term.h curses.h],
198 if test "$HAVE_CURSES" = yes; then
199 NCURSES_LIBS=$($NCURSES_CONFIG --libs)
200 NCURSES_CFLAGS=$($NCURSES_CONFIG --cflags)
201 AC_SUBST(NCURSES_CFLAGS)
202 AC_SUBST(NCURSES_LIBS)
205 AM_CONDITIONAL([HAVE_CURSES], [test "$HAVE_CURSES" = yes])])
207 dnl Checks for linux/vt.h.
208 AC_DEFUN([OVS_CHECK_LINUX_VT_H],
209 [AC_CHECK_HEADER([linux/vt.h],
210 [HAVE_LINUX_VT_H=yes],
211 [HAVE_LINUX_VT_H=no])
212 AM_CONDITIONAL([HAVE_LINUX_VT_H], [test "$HAVE_LINUX_VT_H" = yes])
213 if test "$HAVE_LINUX_VT_H" = yes; then
214 AC_DEFINE([HAVE_LINUX_VT_H], [1],
215 [Define to 1 if linux/vt.h is available.])
218 dnl Checks for libpcre.
220 dnl ezio-term wants libpcre that supports the PCRE_PARTIAL feature,
221 dnl which is libpcre 7.2 or later.
222 AC_DEFUN([OVS_CHECK_PCRE],
223 [dnl Make sure that pkg-config is installed.
224 m4_pattern_forbid([PKG_CHECK_MODULES])
225 PKG_CHECK_MODULES([PCRE],
227 [HAVE_PCRE_PARTIAL=yes],
228 [HAVE_PCRE_PARTIAL=no])
229 AM_CONDITIONAL([HAVE_PCRE_PARTIAL], [test "$HAVE_PCRE_PARTIAL" = yes])
230 AC_SUBST([HAVE_PCRE_PARTIAL])
233 dnl Checks for Python 2.x, x >= 4.
234 AC_DEFUN([OVS_CHECK_PYTHON],
236 [for Python 2.x for x >= 4],
238 [if test -n "$PYTHON"; then
239 ovs_cv_python=$PYTHON
242 for binary in python python2.4 python2.5; do
243 ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
246 test -z "$dir" && dir=.
247 if test -x $dir/$binary && $dir/$binary -c 'import sys
248 if sys.hexversion >= 0x02040000 and sys.hexversion < 0x03000000:
252 ovs_cv_python=$dir/$binary
258 AC_SUBST([HAVE_PYTHON])
259 AM_MISSING_PROG([PYTHON], [python])
260 if test $ovs_cv_python != no; then
261 PYTHON=$ovs_cv_python
266 AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])
269 AC_DEFUN([OVS_CHECK_DOT],
273 [dnl "dot" writes -V output to stderr:
274 if (dot -V) 2>&1 | grep '^dot - [gG]raphviz version' >/dev/null 2>&1; then
280 dnl Check whether to build E-R diagrams.
281 AC_DEFUN([OVS_CHECK_ER_DIAGRAMS],
282 [AC_REQUIRE([OVS_CHECK_DOT])
283 AC_REQUIRE([OVS_CHECK_PYTHON])
285 [whether to build E-R diagrams for database],
286 [ovs_cv_er_diagrams],
287 [if test $ovs_cv_dot != no && test $ovs_cv_python != no; then
288 ovs_cv_er_diagrams=yes
290 ovs_cv_er_diagrams=no
292 AM_CONDITIONAL([BUILD_ER_DIAGRAMS], [test $ovs_cv_er_diagrams = yes])])
294 dnl Checks for pyuic4.
295 AC_DEFUN([OVS_CHECK_PYUIC4],
299 [if (pyuic4 --version) >/dev/null 2>&1; then
304 AM_MISSING_PROG([PYUIC4], [pyuic4])
305 if test $ovs_cv_pyuic4 != no; then
306 PYUIC4=$ovs_cv_pyuic4
309 dnl Checks whether $PYTHON supports the module given as $1
310 AC_DEFUN([OVS_CHECK_PYTHON_MODULE],
311 [AC_REQUIRE([OVS_CHECK_PYTHON])
313 [for $1 Python module],
314 [ovs_cv_py_[]AS_TR_SH([$1])],
315 [ovs_cv_py_[]AS_TR_SH([$1])=no
316 if test $HAVE_PYTHON = yes; then
317 AS_ECHO(["running $PYTHON -c 'import $1
319 sys.exit(0)'..."]) >&AS_MESSAGE_LOG_FD 2>&1
320 if $PYTHON -c 'import $1
322 sys.exit(0)' >&AS_MESSAGE_LOG_FD 2>&1; then
323 ovs_cv_py_[]AS_TR_SH([$1])=yes
327 dnl Checks for Python modules needed by ovsdbmonitor.
328 AC_DEFUN([OVS_CHECK_OVSDBMONITOR],
329 [OVS_CHECK_PYTHON_MODULE([PySide.QtCore])
330 OVS_CHECK_PYTHON_MODULE([PyQt4.QtCore])
331 OVS_CHECK_PYTHON_MODULE([twisted.conch.ssh])
332 OVS_CHECK_PYTHON_MODULE([twisted.internet])
333 OVS_CHECK_PYTHON_MODULE([twisted.application])
334 OVS_CHECK_PYTHON_MODULE([json])
335 OVS_CHECK_PYTHON_MODULE([zope.interface])
336 if (test $ovs_cv_py_PySide_QtCore = yes \
337 || test $ovs_cv_py_PyQt4_QtCore = yes) \
338 && test $ovs_cv_py_twisted_conch_ssh = yes \
339 && test $ovs_cv_py_twisted_internet = yes \
340 && test $ovs_cv_py_twisted_application = yes \
341 && test $ovs_cv_py_json = yes \
342 && test $ovs_cv_py_zope_interface = yes; then
343 BUILD_OVSDBMONITOR=yes
345 BUILD_OVSDBMONITOR=no
347 AC_MSG_CHECKING([whether to build ovsdbmonitor])
348 AC_MSG_RESULT([$BUILD_OVSDBMONITOR])
349 AM_CONDITIONAL([BUILD_OVSDBMONITOR], [test $BUILD_OVSDBMONITOR = yes])])
351 # OVS_LINK2_IFELSE(SOURCE1, SOURCE2, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
352 # -------------------------------------------------------------
353 # Based on AC_LINK_IFELSE, but tries to link both SOURCE1 and SOURCE2
356 # This macro is borrowed from acinclude.m4 in GNU PSPP, which has the
359 # Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
360 # This file is free software; the Free Software Foundation
361 # gives unlimited permission to copy and/or distribute it,
362 # with or without modifications, as long as this notice is preserved.
364 m4_define([OVS_LINK2_IFELSE],
365 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
366 mv conftest.$ac_ext conftest1.$ac_ext
367 m4_ifvaln([$2], [AC_LANG_CONFTEST([$2])])dnl
368 mv conftest.$ac_ext conftest2.$ac_ext
369 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
370 ovs_link2='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest1.$ac_ext conftest2.$ac_ext $LIBS >&5'
371 AS_IF([_AC_DO_STDERR($ovs_link2) && {
372 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
373 test ! -s conftest.err
374 } && test -s conftest$ac_exeext && {
375 test "$cross_compiling" = yes ||
376 AS_TEST_X([conftest$ac_exeext])
379 [echo "$as_me: failed source file 1 of 2 was:" >&5
380 sed 's/^/| /' conftest1.$ac_ext >&5
381 echo "$as_me: failed source file 2 of 2 was:" >&5
382 sed 's/^/| /' conftest2.$ac_ext >&5
384 dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
385 dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
386 dnl as it would interfere with the next link command.
387 rm -rf conftest.dSYM conftest1.dSYM conftest2.dSYM
388 rm -f core conftest.err conftest1.err conftest2.err
389 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest*_ipa8_conftest*.oo
390 rm -f conftest$ac_exeext
391 rm -f m4_ifval([$1], [conftest1.$ac_ext]) m4_ifval([$2], [conftest1.$ac_ext])[]dnl
394 dnl Defines USE_LINKER_SECTIONS to 1 if the compiler supports putting
395 dnl variables in sections with user-defined names and the linker
396 dnl automatically defines __start_SECNAME and __stop_SECNAME symbols
397 dnl that designate the start and end of the sections.
398 AC_DEFUN([OVS_CHECK_LINKER_SECTIONS],
400 [for user-defined linker section support],
401 [ovs_cv_use_linker_sections],
404 [int a __attribute__((__section__("mysection"))) = 1;
405 int b __attribute__((__section__("mysection"))) = 2;
406 int c __attribute__((__section__("mysection"))) = 3;])],
409 extern int __start_mysection;
410 extern int __stop_mysection;],
411 [int n_ints = &__stop_mysection - &__start_mysection;
413 for (i = &__start_mysection; i < &__start_mysection + n_ints; i++) {
416 [ovs_cv_use_linker_sections=yes],
417 [ovs_cv_use_linker_sections=no])])
418 if test $ovs_cv_use_linker_sections = yes; then
419 AC_DEFINE([USE_LINKER_SECTIONS], [1],
420 [Define to 1 if the compiler support putting variables
421 into sections with user-defined names and the linker
422 automatically defines __start_SECNAME and __stop_SECNAME
423 symbols that designate the start and end of the section.])