]> git.proxmox.com Git - ovs.git/blob - m4/openvswitch.m4
Require Python 3 and remove support for Python 2.
[ovs.git] / m4 / openvswitch.m4
1 # -*- autoconf -*-
2
3 # Copyright (c) 2008-2016, 2019 Nicira, Inc.
4 #
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:
8 #
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.
16 #
17 m4_include([m4/compat.m4])
18
19 dnl Checks for --enable-coverage and updates CFLAGS and LDFLAGS appropriately.
20 AC_DEFUN([OVS_CHECK_COVERAGE],
21 [AC_REQUIRE([AC_PROG_CC])
22 AC_ARG_ENABLE(
23 [coverage],
24 [AC_HELP_STRING([--enable-coverage],
25 [Enable gcov coverage tool.])],
26 [case "${enableval}" in
27 (yes) coverage=true ;;
28 (no) coverage=false ;;
29 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-coverage]) ;;
30 esac],
31 [coverage=false])
32 if $coverage; then
33 # Autoconf by default puts "-g -O2" in CFLAGS. We need to remove the -O2
34 # option for coverage to be useful. This does it without otherwise
35 # interfering with anything that the user might have put there.
36 old_CFLAGS=$CFLAGS
37 CFLAGS=
38 for option in $old_CFLAGS; do
39 case $option in
40 (-O2) ;;
41 (*) CFLAGS="$CFLAGS $option" ;;
42 esac
43 done
44
45 OVS_CFLAGS="$OVS_CFLAGS --coverage"
46 OVS_LDFLAGS="$OVS_LDFLAGS --coverage"
47 fi])
48
49 dnl Checks for --enable-ndebug and defines NDEBUG if it is specified.
50 AC_DEFUN([OVS_CHECK_NDEBUG],
51 [AC_ARG_ENABLE(
52 [ndebug],
53 [AC_HELP_STRING([--enable-ndebug],
54 [Disable debugging features for max performance])],
55 [case "${enableval}" in
56 (yes) ndebug=true ;;
57 (no) ndebug=false ;;
58 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ndebug]) ;;
59 esac],
60 [ndebug=false])
61 AM_CONDITIONAL([NDEBUG], [test x$ndebug = xtrue])])
62
63 dnl Checks for MSVC x64 compiler.
64 AC_DEFUN([OVS_CHECK_WIN64],
65 [AC_CACHE_CHECK(
66 [for MSVC x64 compiler],
67 [cl_cv_x64],
68 [dnl "cl" writes x64 output to stdin:
69 if (cl) 2>&1 | grep 'x64' >/dev/null 2>&1; then
70 cl_cv_x64=yes
71 MSVC64_LDFLAGS=" /MACHINE:X64 "
72 MSVC_PLATFORM="x64"
73 else
74 cl_cv_x64=no
75 MSVC64_LDFLAGS=""
76 MSVC_PLATFORM="x86"
77 fi])
78 AC_SUBST([MSVC64_LDFLAGS])
79 AC_SUBST([MSVC_PLATFORM])
80 ])
81
82 dnl Checks for WINDOWS.
83 AC_DEFUN([OVS_CHECK_WIN32],
84 [AC_CHECK_HEADER([windows.h],
85 [WIN32=yes],
86 [WIN32=no])
87 AM_CONDITIONAL([WIN32], [test "$WIN32" = yes])
88 if test "$WIN32" = yes; then
89 AC_ARG_WITH([pthread],
90 [AS_HELP_STRING([--with-pthread=DIR],
91 [root of the pthread-win32 directory])],
92 [
93 case "$withval" in
94 "" | y | ye | yes | n | no)
95 AC_MSG_ERROR([Invalid --with-pthread value])
96 ;;
97 *)
98 if (cl) 2>&1 | grep 'x64' >/dev/null 2>&1; then
99 cl_cv_x64=yes
100 else
101 cl_cv_x64=no
102 fi
103 if test "$cl_cv_x64" = yes; then
104 PTHREAD_WIN32_DIR=$withval/lib/x64
105 PTHREAD_WIN32_DIR_DLL=/$(echo ${withval} | ${SED} -e 's/://')/dll/x64
106 PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x64
107 else
108 PTHREAD_WIN32_DIR=$withval/lib/x86
109 PTHREAD_WIN32_DIR_DLL=/$(echo ${withval} | ${SED} -e 's/://')/dll/x86
110 PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x86
111 fi
112 PTHREAD_INCLUDES=-I$withval/include
113 PTHREAD_LDFLAGS=-L$PTHREAD_WIN32_DIR
114 PTHREAD_LIBS="-lpthreadVC2"
115 AC_SUBST([PTHREAD_WIN32_DIR_DLL_WIN_FORM])
116 AC_SUBST([PTHREAD_WIN32_DIR_DLL])
117 AC_SUBST([PTHREAD_INCLUDES])
118 AC_SUBST([PTHREAD_LDFLAGS])
119 AC_SUBST([PTHREAD_LIBS])
120 ;;
121 esac
122 ], [
123 AC_MSG_ERROR([pthread directory not specified])
124 ]
125 )
126 AC_ARG_WITH([debug],
127 [AS_HELP_STRING([--with-debug],
128 [Build without compiler optimizations])],
129 [
130 MSVC_CFLAGS="-O0"
131 AC_SUBST([MSVC_CFLAGS])
132 ], [
133 MSVC_CFLAGS="-O2"
134 AC_SUBST([MSVC_CFLAGS])
135 ]
136 )
137
138 AC_DEFINE([WIN32], [1], [Define to 1 if building on WIN32.])
139 AC_CHECK_TYPES([struct timespec], [], [], [[#include <time.h>]])
140 AH_BOTTOM([#ifdef WIN32
141 #include "include/windows/windefs.h"
142 #endif])
143 fi])
144
145 dnl OVS_CHECK_WINDOWS
146 dnl
147 dnl Configure Visual Studio solution build
148 AC_DEFUN([OVS_CHECK_VISUAL_STUDIO_DDK], [
149 AC_ARG_WITH([vstudiotarget],
150 [AS_HELP_STRING([--with-vstudiotarget=target_type],
151 [Target type: Debug/Release])],
152 [
153 case "$withval" in
154 "Release") ;;
155 "Debug") ;;
156 *) AC_MSG_ERROR([No valid Visual Studio configuration found]) ;;
157 esac
158
159 VSTUDIO_CONFIG=$withval
160 ], [
161 VSTUDIO_CONFIG=
162 ]
163 )
164
165 AC_SUBST([VSTUDIO_CONFIG])
166
167 AC_ARG_WITH([vstudiotargetver],
168 [AS_HELP_STRING([--with-vstudiotargetver=target_ver1,target_ver2],
169 [Target versions: Win8,Win8.1,Win10])],
170 [
171 targetver=`echo "$withval" | tr -s , ' ' `
172 for ver in $targetver; do
173 case "$ver" in
174 "Win8") VSTUDIO_WIN8=true ;;
175 "Win8.1") VSTUDIO_WIN8_1=true ;;
176 "Win10") VSTUDIO_WIN10=true ;;
177 *) AC_MSG_ERROR([No valid Visual Studio target version found]) ;;
178 esac
179 done
180
181 ], [
182 VSTUDIO_WIN8=true
183 VSTUDIO_WIN8_1=true
184 VSTUDIO_WIN10=true
185 ]
186 )
187
188 AM_CONDITIONAL([VSTUDIO_WIN8], [test -n "$VSTUDIO_WIN8"])
189 AM_CONDITIONAL([VSTUDIO_WIN8_1], [test -n "$VSTUDIO_WIN8_1"])
190 AM_CONDITIONAL([VSTUDIO_WIN10], [test -n "$VSTUDIO_WIN10"])
191
192 AC_DEFINE([VSTUDIO_DDK], [1], [System uses the Visual Studio build target.])
193 AM_CONDITIONAL([VSTUDIO_DDK], [test -n "$VSTUDIO_CONFIG"])
194 ])
195
196 dnl Checks for Netlink support.
197 AC_DEFUN([OVS_CHECK_NETLINK],
198 [AC_CHECK_HEADER([linux/netlink.h],
199 [HAVE_NETLINK=yes],
200 [HAVE_NETLINK=no],
201 [#include <sys/socket.h>
202 ])
203 AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes])
204 if test "$HAVE_NETLINK" = yes; then
205 AC_DEFINE([HAVE_NETLINK], [1],
206 [Define to 1 if Netlink protocol is available.])
207 fi])
208
209 dnl Checks for libcap-ng.
210 AC_DEFUN([OVS_CHECK_LIBCAPNG],
211 [AC_ARG_ENABLE(
212 [libcapng],
213 [AC_HELP_STRING([--disable-libcapng], [Disable Linux capability support])],
214 [case "${enableval}" in
215 (yes) libcapng=true ;;
216 (no) libcapng=false ;;
217 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-libcapng]) ;;
218 esac],
219 [libcapng=check])
220
221 if test "$libcapng" != false; then
222 AC_CHECK_LIB([cap-ng], [capng_clear], [HAVE_LIBCAPNG=yes])
223
224 if test "$HAVE_LIBCAPNG" != yes; then
225 if test "$libcapng" = true ; then
226 AC_MSG_ERROR([libcap-ng support requested, but not found])
227 fi
228 if test "$libcapng" = check ; then
229 AC_MSG_WARN([cannot find libcap-ng.
230 --user option will not be supported on Linux.
231 (you may use --disable-libcapng to suppress this warning). ])
232 fi
233 fi
234 fi
235
236 AC_SUBST([HAVE_LIBCAPNG])
237 AM_CONDITIONAL([HAVE_LIBCAPNG], [test "$HAVE_LIBCAPNG" = yes])
238 if test "$HAVE_LIBCAPNG" = yes; then
239 AC_DEFINE([HAVE_LIBCAPNG], [1],
240 [Define to 1 if libcap-ng is available.])
241 CAPNG_LDADD="-lcap-ng"
242 AC_SUBST([CAPNG_LDADD])
243 fi])
244
245 dnl Checks for OpenSSL.
246 AC_DEFUN([OVS_CHECK_OPENSSL],
247 [AC_ARG_ENABLE(
248 [ssl],
249 [AC_HELP_STRING([--disable-ssl], [Disable OpenSSL support])],
250 [case "${enableval}" in
251 (yes) ssl=true ;;
252 (no) ssl=false ;;
253 (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;;
254 esac],
255 [ssl=check])
256
257 if test "$ssl" != false; then
258 AX_CHECK_OPENSSL(
259 [HAVE_OPENSSL=yes],
260 [HAVE_OPENSSL=no
261 if test "$ssl" = check; then
262 AC_MSG_WARN([Cannot find openssl:
263
264 $SSL_PKG_ERRORS
265
266 OpenFlow connections over SSL will not be supported.
267 (You may use --disable-ssl to suppress this warning.)])
268 else
269 AC_MSG_ERROR([Cannot find openssl (use --disable-ssl to configure without SSL support)])
270 fi])
271 else
272 HAVE_OPENSSL=no
273 fi
274 AC_SUBST([HAVE_OPENSSL])
275 AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes])
276 if test "$HAVE_OPENSSL" = yes; then
277 AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
278 fi
279
280 OPENSSL_SUPPORTS_SNI=no
281 if test $HAVE_OPENSSL = yes; then
282 save_CPPFLAGS=$CPPFLAGS
283 CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
284 AC_CHECK_DECL([SSL_set_tlsext_host_name], [OPENSSL_SUPPORTS_SNI=yes],
285 [], [#include <openssl/ssl.h>
286 ])
287 if test $OPENSSL_SUPPORTS_SNI = yes; then
288 AC_DEFINE(
289 [OPENSSL_SUPPORTS_SNI], [1],
290 [Define to 1 if OpenSSL supports Server Name Indication (SNI).])
291 fi
292 CPPFLAGS=$save_CPPFLAGS
293 fi
294 AC_SUBST([OPENSSL_SUPPORTS_SNI])
295 ])
296
297 dnl Checks for libraries needed by lib/socket-util.c.
298 AC_DEFUN([OVS_CHECK_SOCKET_LIBS],
299 [AC_CHECK_LIB([socket], [connect])
300 AC_SEARCH_LIBS([gethostbyname], [resolv])])
301
302 dnl Checks for the directory in which to store the PKI.
303 AC_DEFUN([OVS_CHECK_PKIDIR],
304 [AC_ARG_WITH(
305 [pkidir],
306 AC_HELP_STRING([--with-pkidir=DIR],
307 [PKI hierarchy directory [[LOCALSTATEDIR/lib/openvswitch/pki]]]),
308 [PKIDIR=$withval],
309 [PKIDIR='${localstatedir}/lib/openvswitch/pki'])
310 AC_SUBST([PKIDIR])])
311
312 dnl Checks for the directory in which to store pidfiles.
313 AC_DEFUN([OVS_CHECK_RUNDIR],
314 [AC_ARG_WITH(
315 [rundir],
316 AC_HELP_STRING([--with-rundir=DIR],
317 [directory used for pidfiles
318 [[LOCALSTATEDIR/run/openvswitch]]]),
319 [RUNDIR=$withval],
320 [RUNDIR='${localstatedir}/run/openvswitch'])
321 AC_SUBST([RUNDIR])])
322
323 dnl Checks for the directory in which to store logs.
324 AC_DEFUN([OVS_CHECK_LOGDIR],
325 [AC_ARG_WITH(
326 [logdir],
327 AC_HELP_STRING([--with-logdir=DIR],
328 [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]),
329 [LOGDIR=$withval],
330 [LOGDIR='${localstatedir}/log/${PACKAGE}'])
331 AC_SUBST([LOGDIR])])
332
333 dnl Checks for the directory in which to store the Open vSwitch database.
334 AC_DEFUN([OVS_CHECK_DBDIR],
335 [AC_ARG_WITH(
336 [dbdir],
337 AC_HELP_STRING([--with-dbdir=DIR],
338 [directory used for conf.db [[SYSCONFDIR/PACKAGE]]]),
339 [DBDIR=$withval],
340 [DBDIR='${sysconfdir}/${PACKAGE}'])
341 AC_SUBST([DBDIR])])
342
343 dnl Defines HAVE_BACKTRACE if backtrace() is found.
344 AC_DEFUN([OVS_CHECK_BACKTRACE],
345 [AC_SEARCH_LIBS([backtrace], [execinfo ubacktrace],
346 [AC_DEFINE([HAVE_BACKTRACE], [1],
347 [Define to 1 if you have backtrace(3).])])])
348
349 dnl Defines HAVE_PERF_EVENT if linux/perf_event.h is found.
350 AC_DEFUN([OVS_CHECK_PERF_EVENT],
351 [AC_CHECK_HEADERS([linux/perf_event.h])])
352
353 dnl Checks for valgrind/valgrind.h.
354 AC_DEFUN([OVS_CHECK_VALGRIND],
355 [AC_CHECK_HEADERS([valgrind/valgrind.h])])
356
357 dnl Checks for Python 3.4 or later.
358 AC_DEFUN([OVS_CHECK_PYTHON3],
359 [AC_CACHE_CHECK(
360 [for Python 3 (version 3.4 or later)],
361 [ovs_cv_python3],
362 [if test -n "$PYTHON3"; then
363 ovs_cv_python3=$PYTHON3
364 else
365 ovs_cv_python3=no
366 for binary in python3 python3.4 python3.5 python3.6 python3.7; do
367 ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
368 for dir in $PATH; do
369 IFS=$ovs_save_IFS
370 test -z "$dir" && dir=.
371 if test -x "$dir"/"$binary" && "$dir"/"$binary" -c 'import sys
372 if sys.hexversion >= 0x03040000 and sys.hexversion < 0x04000000:
373 sys.exit(0)
374 else:
375 sys.exit(1)'; then
376 ovs_cv_python3=$dir/$binary
377 break 2
378 fi
379 done
380 done
381 fi])
382 if test "$ovs_cv_python3" = no; then
383 AC_MSG_ERROR([Python 3.4 or later is required but not found in $PATH, please install it or set $PYTHON3 to point to it])
384 fi
385 AC_ARG_VAR([PYTHON3])
386 PYTHON3=$ovs_cv_python3])
387
388 dnl Checks for python six library.
389 AC_DEFUN([OVS_CHECK_SIX],
390 [AC_REQUIRE([OVS_CHECK_PYTHON3])
391 AC_CACHE_CHECK(
392 [where Python six library is available],
393 [ovs_cv_six],
394 [if $PYTHON3 -c 'import six' >/dev/null 2>&1; then
395 ovs_cv_six=yes
396 else
397 AC_MSG_ERROR([Missing Python six library.])
398 fi])])
399
400 dnl Checks for flake8.
401 AC_DEFUN([OVS_CHECK_FLAKE8],
402 [AC_CACHE_CHECK(
403 [for flake8],
404 [ovs_cv_flake8],
405 [if flake8 --version >/dev/null 2>&1; then
406 ovs_cv_flake8=yes
407 else
408 ovs_cv_flake8=no
409 fi])
410 AM_CONDITIONAL([HAVE_FLAKE8], [test "$ovs_cv_flake8" = yes])])
411
412 dnl Checks for sphinx.
413 AC_DEFUN([OVS_CHECK_SPHINX],
414 [AC_CHECK_PROGS(
415 [SPHINXBUILD], [sphinx-build-3 sphinx-build-2 sphinx-build], [none])
416 AC_ARG_VAR([SPHINXBUILD])
417 AM_CONDITIONAL([HAVE_SPHINX], [test "$SPHINXBUILD" != none])])
418
419 dnl Checks for dot.
420 AC_DEFUN([OVS_CHECK_DOT],
421 [AC_CACHE_CHECK(
422 [for dot],
423 [ovs_cv_dot],
424 [dnl "dot" writes -V output to stderr:
425 if (dot -V) 2>&1 | grep '^dot - [[gG]]raphviz version' >/dev/null 2>&1; then
426 ovs_cv_dot=yes
427 else
428 ovs_cv_dot=no
429 fi])
430 AM_CONDITIONAL([HAVE_DOT], [test "$ovs_cv_dot" = yes])])
431
432 dnl Checks for groff.
433 AC_DEFUN([OVS_CHECK_GROFF],
434 [AC_CACHE_CHECK(
435 [for groff],
436 [ovs_cv_groff],
437 [if (groff -v) >/dev/null 2>&1; then
438 ovs_cv_groff=yes
439 else
440 ovs_cv_groff=no
441 fi])
442 AM_CONDITIONAL([HAVE_GROFF], [test "$ovs_cv_groff" = yes])])
443
444 dnl Checks for thread-local storage support.
445 dnl
446 dnl Checks whether the compiler and linker support the C11
447 dnl thread_local macro from <threads.h>, and if so defines
448 dnl HAVE_THREAD_LOCAL. If not, checks whether the compiler and linker
449 dnl support the GCC __thread extension, and if so defines
450 dnl HAVE___THREAD.
451 AC_DEFUN([OVS_CHECK_TLS],
452 [AC_CACHE_CHECK(
453 [whether $CC has <threads.h> that supports thread_local],
454 [ovs_cv_thread_local],
455 [AC_LINK_IFELSE(
456 [AC_LANG_PROGRAM([#include <threads.h>
457 static thread_local int var;], [return var;])],
458 [ovs_cv_thread_local=yes],
459 [ovs_cv_thread_local=no])])
460 if test $ovs_cv_thread_local = yes; then
461 AC_DEFINE([HAVE_THREAD_LOCAL], [1],
462 [Define to 1 if the C compiler and linker supports the C11
463 thread_local matcro defined in <threads.h>.])
464 else
465 AC_CACHE_CHECK(
466 [whether $CC supports __thread],
467 [ovs_cv___thread],
468 [AC_LINK_IFELSE(
469 [AC_LANG_PROGRAM([static __thread int var;], [return var;])],
470 [ovs_cv___thread=yes],
471 [ovs_cv___thread=no])])
472 if test $ovs_cv___thread = yes; then
473 AC_DEFINE([HAVE___THREAD], [1],
474 [Define to 1 if the C compiler and linker supports the
475 GCC __thread extenions.])
476 fi
477 fi])
478
479 dnl OVS_CHECK_ATOMIC_LIBS
480 dnl
481 dnl Check to see if -latomic is need for GCC atomic built-ins.
482 AC_DEFUN([OVS_CHECK_ATOMIC_LIBS],
483 [AC_SEARCH_LIBS([__atomic_load_8], [atomic])])
484
485 dnl OVS_CHECK_GCC4_ATOMICS
486 dnl
487 dnl Checks whether the compiler and linker support GCC 4.0+ atomic built-ins.
488 dnl A compile-time only check is not enough because the compiler defers
489 dnl unimplemented built-ins to libgcc, which sometimes also lacks
490 dnl implementations.
491 AC_DEFUN([OVS_CHECK_GCC4_ATOMICS],
492 [AC_CACHE_CHECK(
493 [whether $CC supports GCC 4.0+ atomic built-ins],
494 [ovs_cv_gcc4_atomics],
495 [AC_LINK_IFELSE(
496 [AC_LANG_PROGRAM([[#include <stdlib.h>
497
498 #define ovs_assert(expr) if (!(expr)) abort();
499 #define TEST_ATOMIC_TYPE(TYPE) \
500 { \
501 TYPE x = 1; \
502 TYPE orig; \
503 \
504 __sync_synchronize(); \
505 ovs_assert(x == 1); \
506 \
507 __sync_synchronize(); \
508 x = 3; \
509 __sync_synchronize(); \
510 ovs_assert(x == 3); \
511 \
512 orig = __sync_fetch_and_add(&x, 1); \
513 ovs_assert(orig == 3); \
514 __sync_synchronize(); \
515 ovs_assert(x == 4); \
516 \
517 orig = __sync_fetch_and_sub(&x, 2); \
518 ovs_assert(orig == 4); \
519 __sync_synchronize(); \
520 ovs_assert(x == 2); \
521 \
522 orig = __sync_fetch_and_or(&x, 6); \
523 ovs_assert(orig == 2); \
524 __sync_synchronize(); \
525 ovs_assert(x == 6); \
526 \
527 orig = __sync_fetch_and_and(&x, 10); \
528 ovs_assert(orig == 6); \
529 __sync_synchronize(); \
530 ovs_assert(x == 2); \
531 \
532 orig = __sync_fetch_and_xor(&x, 10); \
533 ovs_assert(orig == 2); \
534 __sync_synchronize(); \
535 ovs_assert(x == 8); \
536 }]], [dnl
537 TEST_ATOMIC_TYPE(char);
538 TEST_ATOMIC_TYPE(unsigned char);
539 TEST_ATOMIC_TYPE(signed char);
540 TEST_ATOMIC_TYPE(short);
541 TEST_ATOMIC_TYPE(unsigned short);
542 TEST_ATOMIC_TYPE(int);
543 TEST_ATOMIC_TYPE(unsigned int);
544 TEST_ATOMIC_TYPE(long int);
545 TEST_ATOMIC_TYPE(unsigned long int);
546 TEST_ATOMIC_TYPE(long long int);
547 TEST_ATOMIC_TYPE(unsigned long long int);
548 ])],
549 [ovs_cv_gcc4_atomics=yes],
550 [ovs_cv_gcc4_atomics=no])])
551 if test $ovs_cv_gcc4_atomics = yes; then
552 AC_DEFINE([HAVE_GCC4_ATOMICS], [1],
553 [Define to 1 if the C compiler and linker supports the GCC 4.0+
554 atomic built-ins.])
555 fi])
556
557 dnl OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE(SIZE)
558 dnl
559 dnl Checks __atomic_always_lock_free(SIZE, 0)
560 AC_DEFUN([OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE],
561 [AC_CACHE_CHECK(
562 [value of __atomic_always_lock_free($1)],
563 [ovs_cv_atomic_always_lock_free_$1],
564 [AC_COMPUTE_INT(
565 [ovs_cv_atomic_always_lock_free_$1],
566 [__atomic_always_lock_free($1, 0)],
567 [],
568 [ovs_cv_atomic_always_lock_free_$1=unsupported])])
569 if test ovs_cv_atomic_always_lock_free_$1 != unsupported; then
570 AC_DEFINE_UNQUOTED(
571 [ATOMIC_ALWAYS_LOCK_FREE_$1B],
572 [$ovs_cv_atomic_always_lock_free_$1],
573 [If the C compiler is GCC 4.7 or later, define to the return value of
574 __atomic_always_lock_free($1, 0). If the C compiler is not GCC or is
575 an older version of GCC, the value does not matter.])
576 fi])
577
578 dnl OVS_CHECK_POSIX_AIO
579 AC_DEFUN([OVS_CHECK_POSIX_AIO],
580 [AC_SEARCH_LIBS([aio_write], [rt])
581 AM_CONDITIONAL([HAVE_POSIX_AIO], [test "$ac_cv_search_aio_write" != no])])
582
583 dnl OVS_CHECK_INCLUDE_NEXT
584 AC_DEFUN([OVS_CHECK_INCLUDE_NEXT],
585 [AC_REQUIRE([gl_CHECK_NEXT_HEADERS])
586 gl_CHECK_NEXT_HEADERS([$1])])
587
588 dnl OVS_CHECK_PRAGMA_MESSAGE
589 AC_DEFUN([OVS_CHECK_PRAGMA_MESSAGE],
590 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
591 [[_Pragma("message(\"Checking for pragma message\")")
592 ]])],
593 [AC_DEFINE(HAVE_PRAGMA_MESSAGE,1,[Define if compiler supports #pragma
594 message directive])])
595 ])
596
597 dnl OVS_LIBTOOL_VERSIONS sets the major, minor, micro version information for
598 dnl OVS_LTINFO variable. This variable locks libtool information for shared
599 dnl objects, allowing multiple versions with different ABIs to coexist.
600 AC_DEFUN([OVS_LIBTOOL_VERSIONS],
601 [AC_MSG_CHECKING(linker output version information)
602 OVS_MAJOR=`echo "$PACKAGE_VERSION" | sed -e 's/[[.]].*//'`
603 OVS_MINOR=`echo "$PACKAGE_VERSION" | sed -e "s/^$OVS_MAJOR//" -e 's/^.//' -e 's/[[.]].*//'`
604 OVS_MICRO=`echo "$PACKAGE_VERSION" | sed -e "s/^$OVS_MAJOR.$OVS_MINOR//" -e 's/^.//' -e 's/[[^0-9]].*//'`
605 OVS_LT_RELINFO="-release $OVS_MAJOR.$OVS_MINOR"
606 OVS_LT_VERINFO="-version-info $LT_CURRENT:$OVS_MICRO"
607 OVS_LTINFO="$OVS_LT_RELINFO $OVS_LT_VERINFO"
608 AC_MSG_RESULT([libX-$OVS_MAJOR.$OVS_MINOR.so.$LT_CURRENT.0.$OVS_MICRO)])
609 AC_SUBST(OVS_LTINFO)
610 ])
611
612 dnl OVS does not use C++ itself, but it provides public header files
613 dnl that a C++ compiler should accept, so when --enable-Werror is in
614 dnl effect and a C++ compiler is available, we enable building a C++
615 dnl source file that #includes all the public headers, as a way to
616 dnl ensure that they are acceptable as C++.
617 AC_DEFUN([OVS_CHECK_CXX],
618 [AC_REQUIRE([AC_PROG_CXX])
619 AC_REQUIRE([OVS_ENABLE_WERROR])
620 AX_CXX_COMPILE_STDCXX([11], [], [optional])
621 if test $enable_Werror = yes && test $HAVE_CXX11 = 1; then
622 enable_cxx=:
623 AC_LANG_PUSH([C++])
624 AC_CHECK_HEADERS([atomic])
625 AC_LANG_POP([C++])
626 else
627 enable_cxx=false
628 fi
629 AM_CONDITIONAL([HAVE_CXX], [$enable_cxx])])
630
631 dnl Checks for unbound library.
632 AC_DEFUN([OVS_CHECK_UNBOUND],
633 [AC_CHECK_LIB(unbound, ub_ctx_create, [HAVE_UNBOUND=yes], [HAVE_UNBOUND=no])
634 if test "$HAVE_UNBOUND" = yes; then
635 AC_DEFINE([HAVE_UNBOUND], [1], [Define to 1 if unbound is detected.])
636 LIBS="$LIBS -lunbound"
637 fi
638 AM_CONDITIONAL([HAVE_UNBOUND], [test "$HAVE_UNBOUND" = yes])
639 AC_SUBST([HAVE_UNBOUND])])