]> git.proxmox.com Git - mirror_ovs.git/blame - m4/openvswitch.m4
tests: Remove bit-rotted support for "lcov".
[mirror_ovs.git] / m4 / openvswitch.m4
CommitLineData
064af421
BP
1# -*- autoconf -*-
2
e0edde6f 3# Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
064af421 4#
a14bc59f
BP
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:
064af421 8#
a14bc59f
BP
9# http://www.apache.org/licenses/LICENSE-2.0
10#
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.
064af421 16
c2b07021
BP
17dnl Checks for --enable-coverage and updates CFLAGS and LDFLAGS appropriately.
18AC_DEFUN([OVS_CHECK_COVERAGE],
19 [AC_REQUIRE([AC_PROG_CC])
20 AC_ARG_ENABLE(
21 [coverage],
22 [AC_HELP_STRING([--enable-coverage],
23 [Enable gcov coverage tool.])],
24 [case "${enableval}" in
8faa5a21 25 (yes) coverage=true ;;
7c126fbb 26 (no) coverage=false ;;
c2b07021
BP
27 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-coverage]) ;;
28 esac],
7c126fbb 29 [coverage=false])
c2b07021
BP
30 if $coverage; then
31 CFLAGS="$CFLAGS -O0 --coverage"
32 LDFLAGS="$LDFLAGS --coverage"
7c126fbb 33 fi])
c2b07021 34
064af421
BP
35dnl Checks for --enable-ndebug and defines NDEBUG if it is specified.
36AC_DEFUN([OVS_CHECK_NDEBUG],
37 [AC_ARG_ENABLE(
38 [ndebug],
39 [AC_HELP_STRING([--enable-ndebug],
40 [Disable debugging features for max performance])],
41 [case "${enableval}" in
42 (yes) ndebug=true ;;
43 (no) ndebug=false ;;
44 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;;
45 esac],
46 [ndebug=false])
47 AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])])
48
49dnl Checks for Netlink support.
50AC_DEFUN([OVS_CHECK_NETLINK],
51 [AC_CHECK_HEADER([linux/netlink.h],
52 [HAVE_NETLINK=yes],
53 [HAVE_NETLINK=no],
54 [#include <sys/socket.h>
55 #include <linux/types.h>
56 ])
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.])
61 fi])
62
f272ec73 63dnl Checks for OpenSSL.
064af421
BP
64AC_DEFUN([OVS_CHECK_OPENSSL],
65 [AC_ARG_ENABLE(
66 [ssl],
f272ec73 67 [AC_HELP_STRING([--disable-ssl], [Disable OpenSSL support])],
064af421
BP
68 [case "${enableval}" in
69 (yes) ssl=true ;;
70 (no) ssl=false ;;
71 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;;
72 esac],
f272ec73 73 [ssl=check])
064af421 74
f272ec73 75 if test "$ssl" != false; then
2bc458b3 76 m4_ifndef([PKG_CHECK_MODULES], [m4_fatal([Please install pkg-config.])])
924c2434 77 PKG_CHECK_MODULES([SSL], [openssl],
48b9616a
BP
78 [HAVE_OPENSSL=yes],
79 [HAVE_OPENSSL=no
f272ec73 80 if test "$ssl" = check; then
924c2434 81 AC_MSG_WARN([Cannot find openssl:
064af421 82
48b9616a 83$SSL_PKG_ERRORS
064af421 84
f272ec73
BP
85OpenFlow connections over SSL will not be supported.
86(You may use --disable-ssl to suppress this warning.)])
87 else
924c2434 88 AC_MSG_ERROR([Cannot find openssl (use --disable-ssl to configure without SSL support)])
f272ec73 89 fi])
869decd4
BP
90 else
91 HAVE_OPENSSL=no
064af421 92 fi
d27ce529 93 AC_SUBST([HAVE_OPENSSL])
064af421
BP
94 AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes])
95 if test "$HAVE_OPENSSL" = yes; then
96 AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
97 fi])
98
064af421
BP
99dnl Checks for libraries needed by lib/socket-util.c.
100AC_DEFUN([OVS_CHECK_SOCKET_LIBS],
101 [AC_CHECK_LIB([socket], [connect])
102 AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])])
103
104dnl Checks for the directory in which to store the PKI.
105AC_DEFUN([OVS_CHECK_PKIDIR],
106 [AC_ARG_WITH(
107 [pkidir],
108 AC_HELP_STRING([--with-pkidir=DIR],
14bd2d51 109 [PKI hierarchy directory [[LOCALSTATEDIR/lib/openvswitch/pki]]]),
064af421 110 [PKIDIR=$withval],
14bd2d51 111 [PKIDIR='${localstatedir}/lib/openvswitch/pki'])
064af421
BP
112 AC_SUBST([PKIDIR])])
113
114dnl Checks for the directory in which to store pidfiles.
115AC_DEFUN([OVS_CHECK_RUNDIR],
116 [AC_ARG_WITH(
117 [rundir],
118 AC_HELP_STRING([--with-rundir=DIR],
bc391960
JP
119 [directory used for pidfiles
120 [[LOCALSTATEDIR/run/openvswitch]]]),
064af421 121 [RUNDIR=$withval],
bc391960 122 [RUNDIR='${localstatedir}/run/openvswitch'])
064af421
BP
123 AC_SUBST([RUNDIR])])
124
125dnl Checks for the directory in which to store logs.
126AC_DEFUN([OVS_CHECK_LOGDIR],
127 [AC_ARG_WITH(
128 [logdir],
129 AC_HELP_STRING([--with-logdir=DIR],
130 [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]),
131 [LOGDIR=$withval],
132 [LOGDIR='${localstatedir}/log/${PACKAGE}'])
133 AC_SUBST([LOGDIR])])
134
0e6644c3
BP
135dnl Defines HAVE_BACKTRACE if backtrace() is declared in <execinfo.h>
136dnl and exists in libc.
137AC_DEFUN([OVS_CHECK_BACKTRACE],
138 [AC_CHECK_HEADER([execinfo.h], [AC_CHECK_FUNCS([backtrace])])])
139
064af421
BP
140dnl Checks for __malloc_hook, etc., supported by glibc.
141AC_DEFUN([OVS_CHECK_MALLOC_HOOKS],
142 [AC_CACHE_CHECK(
143 [whether libc supports hooks for malloc and related functions],
144 [ovs_cv_malloc_hooks],
145 [AC_COMPILE_IFELSE(
146 [AC_LANG_PROGRAM(
147 [#include <malloc.h>
148 ],
149 [(void) __malloc_hook;
150 (void) __realloc_hook;
151 (void) __free_hook;])],
152 [ovs_cv_malloc_hooks=yes],
153 [ovs_cv_malloc_hooks=no])])
154 if test $ovs_cv_malloc_hooks = yes; then
155 AC_DEFINE([HAVE_MALLOC_HOOKS], [1],
156 [Define to 1 if you have __malloc_hook, __realloc_hook, and
157 __free_hook in <malloc.h>.])
158 fi])
159
160dnl Checks for valgrind/valgrind.h.
161AC_DEFUN([OVS_CHECK_VALGRIND],
162 [AC_CHECK_HEADERS([valgrind/valgrind.h])])
163
3b135da3
BP
164dnl Checks for Python 2.x, x >= 4.
165AC_DEFUN([OVS_CHECK_PYTHON],
195b5c35 166 [AC_CACHE_CHECK(
3b135da3
BP
167 [for Python 2.x for x >= 4],
168 [ovs_cv_python],
169 [if test -n "$PYTHON"; then
170 ovs_cv_python=$PYTHON
171 else
172 ovs_cv_python=no
173 for binary in python python2.4 python2.5; do
174 ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
175 for dir in $PATH; do
176 IFS=$ovs_save_IFS
177 test -z "$dir" && dir=.
178 if test -x $dir/$binary && $dir/$binary -c 'import sys
179if sys.hexversion >= 0x02040000 and sys.hexversion < 0x03000000:
180 sys.exit(0)
181else:
182 sys.exit(1)'; then
183 ovs_cv_python=$dir/$binary
184 break 2
185 fi
186 done
187 done
188 fi])
05b3c97b 189 AC_SUBST([HAVE_PYTHON])
195b5c35
BP
190 AM_MISSING_PROG([PYTHON], [python])
191 if test $ovs_cv_python != no; then
192 PYTHON=$ovs_cv_python
05b3c97b
BP
193 HAVE_PYTHON=yes
194 else
195 HAVE_PYTHON=no
196 fi
197 AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])
436f27dd 198
f8d739a9
BP
199dnl Checks for dot.
200AC_DEFUN([OVS_CHECK_DOT],
201 [AC_CACHE_CHECK(
202 [for dot],
203 [ovs_cv_dot],
204 [dnl "dot" writes -V output to stderr:
a5eef57e 205 if (dot -V) 2>&1 | grep '^dot - [[gG]]raphviz version' >/dev/null 2>&1; then
f8d739a9
BP
206 ovs_cv_dot=yes
207 else
208 ovs_cv_dot=no
f8d739a9 209 fi])
7c9b0073 210 AM_CONDITIONAL([HAVE_DOT], [test "$ovs_cv_dot" = yes])])
f8d739a9 211
436f27dd
AS
212dnl Checks for pyuic4.
213AC_DEFUN([OVS_CHECK_PYUIC4],
214 [AC_CACHE_CHECK(
215 [for pyuic4],
216 [ovs_cv_pyuic4],
217 [if (pyuic4 --version) >/dev/null 2>&1; then
218 ovs_cv_pyuic4=pyuic4
219 else
220 ovs_cv_pyuic4=no
221 fi])
222 AM_MISSING_PROG([PYUIC4], [pyuic4])
223 if test $ovs_cv_pyuic4 != no; then
224 PYUIC4=$ovs_cv_pyuic4
225 fi])
226
227dnl Checks whether $PYTHON supports the module given as $1
228AC_DEFUN([OVS_CHECK_PYTHON_MODULE],
229 [AC_REQUIRE([OVS_CHECK_PYTHON])
230 AC_CACHE_CHECK(
231 [for $1 Python module],
232 [ovs_cv_py_[]AS_TR_SH([$1])],
233 [ovs_cv_py_[]AS_TR_SH([$1])=no
234 if test $HAVE_PYTHON = yes; then
235 AS_ECHO(["running $PYTHON -c 'import $1
236import sys
1df624e6 237sys.exit(0)'..."]) >&AS_MESSAGE_LOG_FD 2>&1
436f27dd
AS
238 if $PYTHON -c 'import $1
239import sys
1df624e6 240sys.exit(0)' >&AS_MESSAGE_LOG_FD 2>&1; then
436f27dd
AS
241 ovs_cv_py_[]AS_TR_SH([$1])=yes
242 fi
243 fi])])
244
245dnl Checks for Python modules needed by ovsdbmonitor.
246AC_DEFUN([OVS_CHECK_OVSDBMONITOR],
247 [OVS_CHECK_PYTHON_MODULE([PySide.QtCore])
248 OVS_CHECK_PYTHON_MODULE([PyQt4.QtCore])
249 OVS_CHECK_PYTHON_MODULE([twisted.conch.ssh])
250 OVS_CHECK_PYTHON_MODULE([twisted.internet])
251 OVS_CHECK_PYTHON_MODULE([twisted.application])
252 OVS_CHECK_PYTHON_MODULE([json])
253 OVS_CHECK_PYTHON_MODULE([zope.interface])
254 if (test $ovs_cv_py_PySide_QtCore = yes \
255 || test $ovs_cv_py_PyQt4_QtCore = yes) \
256 && test $ovs_cv_py_twisted_conch_ssh = yes \
257 && test $ovs_cv_py_twisted_internet = yes \
258 && test $ovs_cv_py_twisted_application = yes \
259 && test $ovs_cv_py_json = yes \
260 && test $ovs_cv_py_zope_interface = yes; then
261 BUILD_OVSDBMONITOR=yes
262 else
263 BUILD_OVSDBMONITOR=no
264 fi
265 AC_MSG_CHECKING([whether to build ovsdbmonitor])
266 AC_MSG_RESULT([$BUILD_OVSDBMONITOR])
267 AM_CONDITIONAL([BUILD_OVSDBMONITOR], [test $BUILD_OVSDBMONITOR = yes])])
480ce8ab
BP
268
269# OVS_LINK2_IFELSE(SOURCE1, SOURCE2, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
270# -------------------------------------------------------------
271# Based on AC_LINK_IFELSE, but tries to link both SOURCE1 and SOURCE2
272# into a program.
273#
274# This macro is borrowed from acinclude.m4 in GNU PSPP, which has the
275# following license:
276#
277# Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
278# This file is free software; the Free Software Foundation
279# gives unlimited permission to copy and/or distribute it,
280# with or without modifications, as long as this notice is preserved.
281#
282m4_define([OVS_LINK2_IFELSE],
283[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
284mv conftest.$ac_ext conftest1.$ac_ext
285m4_ifvaln([$2], [AC_LANG_CONFTEST([$2])])dnl
286mv conftest.$ac_ext conftest2.$ac_ext
287rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
288ovs_link2='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest1.$ac_ext conftest2.$ac_ext $LIBS >&5'
289AS_IF([_AC_DO_STDERR($ovs_link2) && {
290 test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" ||
291 test ! -s conftest.err
292 } && test -s conftest$ac_exeext && {
293 test "$cross_compiling" = yes ||
294 AS_TEST_X([conftest$ac_exeext])
295 }],
296 [$3],
297 [echo "$as_me: failed source file 1 of 2 was:" >&5
298sed 's/^/| /' conftest1.$ac_ext >&5
299echo "$as_me: failed source file 2 of 2 was:" >&5
300sed 's/^/| /' conftest2.$ac_ext >&5
301 $4])
302dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization)
303dnl information created by the PGI compiler (conftest_ipa8_conftest.oo),
304dnl as it would interfere with the next link command.
305rm -rf conftest.dSYM conftest1.dSYM conftest2.dSYM
306rm -f core conftest.err conftest1.err conftest2.err
307rm -f conftest1.$ac_objext conftest2.$ac_objext conftest*_ipa8_conftest*.oo
308rm -f conftest$ac_exeext
309rm -f m4_ifval([$1], [conftest1.$ac_ext]) m4_ifval([$2], [conftest1.$ac_ext])[]dnl
310])# OVS_LINK2_IFELSE
311
312dnl Defines USE_LINKER_SECTIONS to 1 if the compiler supports putting
313dnl variables in sections with user-defined names and the linker
314dnl automatically defines __start_SECNAME and __stop_SECNAME symbols
315dnl that designate the start and end of the sections.
316AC_DEFUN([OVS_CHECK_LINKER_SECTIONS],
317 [AC_CACHE_CHECK(
318 [for user-defined linker section support],
319 [ovs_cv_use_linker_sections],
320 [OVS_LINK2_IFELSE(
321 [AC_LANG_SOURCE(
322 [int a __attribute__((__section__("mysection"))) = 1;
323 int b __attribute__((__section__("mysection"))) = 2;
324 int c __attribute__((__section__("mysection"))) = 3;])],
325 [AC_LANG_PROGRAM(
326 [#include <stdio.h>
327 extern int __start_mysection;
328 extern int __stop_mysection;],
329 [int n_ints = &__stop_mysection - &__start_mysection;
330 int *i;
331 for (i = &__start_mysection; i < &__start_mysection + n_ints; i++) {
332 printf("%d\n", *i);
333 }])],
334 [ovs_cv_use_linker_sections=yes],
335 [ovs_cv_use_linker_sections=no])])
336 if test $ovs_cv_use_linker_sections = yes; then
337 AC_DEFINE([USE_LINKER_SECTIONS], [1],
338 [Define to 1 if the compiler support putting variables
339 into sections with user-defined names and the linker
340 automatically defines __start_SECNAME and __stop_SECNAME
341 symbols that designate the start and end of the section.])
611d30ce
BP
342 fi
343 AM_CONDITIONAL(
344 [USE_LINKER_SECTIONS], [test $ovs_cv_use_linker_sections = yes])])
0027492d
BP
345
346dnl Checks for groff.
347AC_DEFUN([OVS_CHECK_GROFF],
348 [AC_CACHE_CHECK(
349 [for groff],
350 [ovs_cv_groff],
351 [if (groff -v) >/dev/null 2>&1; then
352 ovs_cv_groff=yes
353 else
354 ovs_cv_groff=no
355 fi])
356 AM_CONDITIONAL([HAVE_GROFF], [test "$ovs_cv_groff" = yes])])
d8965755
CW
357
358dnl Checks for --disable-brcompat and undefines BUILD_BRCOMPAT if it is specified.
359AC_DEFUN([OVS_CHECK_BRCOMPAT],
360 [AC_ARG_ENABLE(
361 [brcompat],
362 [AC_HELP_STRING([--disable-brcompat],
363 [Disable building brcompat])],
364 [case "${enableval}" in
365 (yes) brcompat=true ;;
366 (no) brcompat=false ;;
367 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-brcompat]) ;;
368 esac],
369 [brcompat=true])
370 if test x$brcompat = xtrue; then
371 BUILD_BRCOMPAT=yes
372 else
373 BUILD_BRCOMPAT=""
374 fi
375 AC_SUBST([BUILD_BRCOMPAT])
376 AM_CONDITIONAL([BUILD_BRCOMPAT], [test x$brcompat = xtrue])])