3 # Copyright (c) 2008, 2009, 2010, 2011 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 struct rtnl_link_stats64.
51 dnl (OVS checks for this structure in both kernel and userspace headers. This
52 dnl is not redundant, because the kernel and userspace builds have completely
53 dnl different include paths. It is possible for the kernel to have this
54 dnl structure but not userspace, and vice versa.)
55 AC_DEFUN([OVS_CHECK_RTNL_LINK_STATS64],
56 [AC_REQUIRE([OVS_CHECK_NETLINK])
57 if test $HAVE_NETLINK = yes; then
59 [struct rtnl_link_stats64.tx_packets],
60 [AC_DEFINE([HAVE_RTNL_LINK_STATS64], [1],
61 [Define to 1 if <linux/if_link.h> defines
62 struct rtnl_link_stats64.])],
63 [], [#include <sys/socket.h> /* Provides sa_family_t. */
64 #include <linux/if_link.h>
68 dnl Checks for Netlink support.
69 AC_DEFUN([OVS_CHECK_NETLINK],
70 [AC_CHECK_HEADER([linux/netlink.h],
73 [#include <sys/socket.h>
74 #include <linux/types.h>
76 AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes])
77 if test "$HAVE_NETLINK" = yes; then
78 AC_DEFINE([HAVE_NETLINK], [1],
79 [Define to 1 if Netlink protocol is available.])
82 dnl Checks for OpenSSL.
83 AC_DEFUN([OVS_CHECK_OPENSSL],
86 [AC_HELP_STRING([--disable-ssl], [Disable OpenSSL support])],
87 [case "${enableval}" in
90 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;;
94 if test "$ssl" != false; then
95 dnl Make sure that pkg-config is installed.
96 m4_pattern_forbid([PKG_CHECK_MODULES])
97 PKG_CHECK_MODULES([SSL], [openssl],
100 if test "$ssl" = check; then
101 AC_MSG_WARN([Cannot find openssl:
105 OpenFlow connections over SSL will not be supported.
106 (You may use --disable-ssl to suppress this warning.)])
108 AC_MSG_ERROR([Cannot find openssl (use --disable-ssl to configure without SSL support)])
113 AC_SUBST([HAVE_OPENSSL])
114 AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes])
115 if test "$HAVE_OPENSSL" = yes; then
116 AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
119 dnl Checks for libraries needed by lib/socket-util.c.
120 AC_DEFUN([OVS_CHECK_SOCKET_LIBS],
121 [AC_CHECK_LIB([socket], [connect])
122 AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])])
124 dnl Checks for the directory in which to store the PKI.
125 AC_DEFUN([OVS_CHECK_PKIDIR],
128 AC_HELP_STRING([--with-pkidir=DIR],
129 [PKI hierarchy directory [[DATADIR/openvswitch/pki]]]),
131 [PKIDIR='${pkgdatadir}/pki'])
134 dnl Checks for the directory in which to store pidfiles.
135 AC_DEFUN([OVS_CHECK_RUNDIR],
138 AC_HELP_STRING([--with-rundir=DIR],
139 [directory used for pidfiles
140 [[LOCALSTATEDIR/run/openvswitch]]]),
142 [RUNDIR='${localstatedir}/run/openvswitch'])
145 dnl Checks for the directory in which to store logs.
146 AC_DEFUN([OVS_CHECK_LOGDIR],
149 AC_HELP_STRING([--with-logdir=DIR],
150 [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]),
152 [LOGDIR='${localstatedir}/log/${PACKAGE}'])
155 dnl Checks for __malloc_hook, etc., supported by glibc.
156 AC_DEFUN([OVS_CHECK_MALLOC_HOOKS],
158 [whether libc supports hooks for malloc and related functions],
159 [ovs_cv_malloc_hooks],
164 [(void) __malloc_hook;
165 (void) __realloc_hook;
166 (void) __free_hook;])],
167 [ovs_cv_malloc_hooks=yes],
168 [ovs_cv_malloc_hooks=no])])
169 if test $ovs_cv_malloc_hooks = yes; then
170 AC_DEFINE([HAVE_MALLOC_HOOKS], [1],
171 [Define to 1 if you have __malloc_hook, __realloc_hook, and
172 __free_hook in <malloc.h>.])
175 dnl Checks for valgrind/valgrind.h.
176 AC_DEFUN([OVS_CHECK_VALGRIND],
177 [AC_CHECK_HEADERS([valgrind/valgrind.h])])
179 dnl Checks for Python 2.x, x >= 4.
180 AC_DEFUN([OVS_CHECK_PYTHON],
182 [for Python 2.x for x >= 4],
184 [if test -n "$PYTHON"; then
185 ovs_cv_python=$PYTHON
188 for binary in python python2.4 python2.5; do
189 ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
192 test -z "$dir" && dir=.
193 if test -x $dir/$binary && $dir/$binary -c 'import sys
194 if sys.hexversion >= 0x02040000 and sys.hexversion < 0x03000000:
198 ovs_cv_python=$dir/$binary
204 AC_SUBST([HAVE_PYTHON])
205 AM_MISSING_PROG([PYTHON], [python])
206 if test $ovs_cv_python != no; then
207 PYTHON=$ovs_cv_python
212 AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])
215 AC_DEFUN([OVS_CHECK_DOT],
219 [dnl "dot" writes -V output to stderr:
220 if (dot -V) 2>&1 | grep '^dot - [[gG]]raphviz version' >/dev/null 2>&1; then
225 AM_CONDITIONAL([HAVE_DOT], [test "$ovs_cv_dot" = yes])])
227 dnl Checks for pyuic4.
228 AC_DEFUN([OVS_CHECK_PYUIC4],
232 [if (pyuic4 --version) >/dev/null 2>&1; then
237 AM_MISSING_PROG([PYUIC4], [pyuic4])
238 if test $ovs_cv_pyuic4 != no; then
239 PYUIC4=$ovs_cv_pyuic4
242 dnl Checks whether $PYTHON supports the module given as $1
243 AC_DEFUN([OVS_CHECK_PYTHON_MODULE],
244 [AC_REQUIRE([OVS_CHECK_PYTHON])
246 [for $1 Python module],
247 [ovs_cv_py_[]AS_TR_SH([$1])],
248 [ovs_cv_py_[]AS_TR_SH([$1])=no
249 if test $HAVE_PYTHON = yes; then
250 AS_ECHO(["running $PYTHON -c 'import $1
252 sys.exit(0)'..."]) >&AS_MESSAGE_LOG_FD 2>&1
253 if $PYTHON -c 'import $1
255 sys.exit(0)' >&AS_MESSAGE_LOG_FD 2>&1; then
256 ovs_cv_py_[]AS_TR_SH([$1])=yes
260 dnl Checks for Python modules needed by ovsdbmonitor.
261 AC_DEFUN([OVS_CHECK_OVSDBMONITOR],
262 [OVS_CHECK_PYTHON_MODULE([PySide.QtCore])
263 OVS_CHECK_PYTHON_MODULE([PyQt4.QtCore])
264 OVS_CHECK_PYTHON_MODULE([twisted.conch.ssh])
265 OVS_CHECK_PYTHON_MODULE([twisted.internet])
266 OVS_CHECK_PYTHON_MODULE([twisted.application])
267 OVS_CHECK_PYTHON_MODULE([json])
268 OVS_CHECK_PYTHON_MODULE([zope.interface])
269 if (test $ovs_cv_py_PySide_QtCore = yes \
270 || test $ovs_cv_py_PyQt4_QtCore = yes) \
271 && test $ovs_cv_py_twisted_conch_ssh = yes \
272 && test $ovs_cv_py_twisted_internet = yes \
273 && test $ovs_cv_py_twisted_application = yes \
274 && test $ovs_cv_py_json = yes \
275 && test $ovs_cv_py_zope_interface = yes; then
276 BUILD_OVSDBMONITOR=yes
278 BUILD_OVSDBMONITOR=no
280 AC_MSG_CHECKING([whether to build ovsdbmonitor])
281 AC_MSG_RESULT([$BUILD_OVSDBMONITOR])
282 AM_CONDITIONAL([BUILD_OVSDBMONITOR], [test $BUILD_OVSDBMONITOR = yes])])
284 # OVS_LINK2_IFELSE(SOURCE1, SOURCE2, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
285 # -------------------------------------------------------------
286 # Based on AC_LINK_IFELSE, but tries to link both SOURCE1 and SOURCE2
289 # This macro is borrowed from acinclude.m4 in GNU PSPP, which has the
292 # Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
293 # This file is free software; the Free Software Foundation
294 # gives unlimited permission to copy and/or distribute it,
295 # with or without modifications, as long as this notice is preserved.
297 m4_define([OVS_LINK2_IFELSE],
298 [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
299 mv conftest.$ac_ext conftest1.$ac_ext
300 m4_ifvaln([$2], [AC_LANG_CONFTEST([$2])])dnl
301 mv conftest.$ac_ext conftest2.$ac_ext
302 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
303 ovs_link2='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest1.$ac_ext conftest2.$ac_ext $LIBS >&5'
304 AS_IF([_AC_DO_STDERR($ovs_link2) && {
305 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
306 test ! -s conftest.err
307 } && test -s conftest$ac_exeext && {
308 test "$cross_compiling" = yes ||
309 AS_TEST_X([conftest$ac_exeext])
312 [echo "$as_me: failed source file 1 of 2 was:" >&5
313 sed 's/^/| /' conftest1.$ac_ext >&5
314 echo "$as_me: failed source file 2 of 2 was:" >&5
315 sed 's/^/| /' conftest2.$ac_ext >&5
317 dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
318 dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
319 dnl as it would interfere with the next link command.
320 rm -rf conftest.dSYM conftest1.dSYM conftest2.dSYM
321 rm -f core conftest.err conftest1.err conftest2.err
322 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest*_ipa8_conftest*.oo
323 rm -f conftest$ac_exeext
324 rm -f m4_ifval([$1], [conftest1.$ac_ext]) m4_ifval([$2], [conftest1.$ac_ext])[]dnl
327 dnl Defines USE_LINKER_SECTIONS to 1 if the compiler supports putting
328 dnl variables in sections with user-defined names and the linker
329 dnl automatically defines __start_SECNAME and __stop_SECNAME symbols
330 dnl that designate the start and end of the sections.
331 AC_DEFUN([OVS_CHECK_LINKER_SECTIONS],
333 [for user-defined linker section support],
334 [ovs_cv_use_linker_sections],
337 [int a __attribute__((__section__("mysection"))) = 1;
338 int b __attribute__((__section__("mysection"))) = 2;
339 int c __attribute__((__section__("mysection"))) = 3;])],
342 extern int __start_mysection;
343 extern int __stop_mysection;],
344 [int n_ints = &__stop_mysection - &__start_mysection;
346 for (i = &__start_mysection; i < &__start_mysection + n_ints; i++) {
349 [ovs_cv_use_linker_sections=yes],
350 [ovs_cv_use_linker_sections=no])])
351 if test $ovs_cv_use_linker_sections = yes; then
352 AC_DEFINE([USE_LINKER_SECTIONS], [1],
353 [Define to 1 if the compiler support putting variables
354 into sections with user-defined names and the linker
355 automatically defines __start_SECNAME and __stop_SECNAME
356 symbols that designate the start and end of the section.])
359 [USE_LINKER_SECTIONS], [test $ovs_cv_use_linker_sections = yes])])