]>
Commit | Line | Data |
---|---|---|
064af421 BP |
1 | # -*- autoconf -*- |
2 | ||
c22095a5 | 3 | # Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 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 |
17 | dnl Checks for --enable-coverage and updates CFLAGS and LDFLAGS appropriately. |
18 | AC_DEFUN([OVS_CHECK_COVERAGE], | |
19 | [AC_REQUIRE([AC_PROG_CC]) | |
20 | AC_ARG_ENABLE( | |
21 | [coverage], | |
2e22e1c7 | 22 | [AC_HELP_STRING([--enable-coverage], |
c2b07021 BP |
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 |
35 | dnl Checks for --enable-ndebug and defines NDEBUG if it is specified. |
36 | AC_DEFUN([OVS_CHECK_NDEBUG], | |
37 | [AC_ARG_ENABLE( | |
38 | [ndebug], | |
2e22e1c7 | 39 | [AC_HELP_STRING([--enable-ndebug], |
064af421 BP |
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 | ||
3d7cab5f EJ |
49 | dnl Checks for --enable-cache-time and defines CACHE_TIME if it is specified. |
50 | AC_DEFUN([OVS_CHECK_CACHE_TIME], | |
51 | [AC_ARG_ENABLE( | |
52 | [cache-time], | |
53 | [AC_HELP_STRING([--enable-cache-time], | |
54 | [Override time caching default (for testing only)])], | |
55 | [case "${enableval}" in | |
56 | (yes) cache_time=1;; | |
57 | (no) cache_time=0;; | |
58 | (*) AC_MSG_ERROR([bad value ${enableval} for --enable-cache-time]) ;; | |
59 | esac | |
60 | AC_DEFINE_UNQUOTED([CACHE_TIME], [$cache_time], | |
61 | [Define to 1 to enable time caching, to 0 to disable time caching, or | |
62 | leave undefined to use the default (as one should | |
63 | ordinarily do).])])]) | |
64 | ||
361906b1 EJ |
65 | dnl Checks for ESX. |
66 | AC_DEFUN([OVS_CHECK_ESX], | |
67 | [AC_CHECK_HEADER([vmware.h], | |
68 | [ESX=yes], | |
69 | [ESX=no]) | |
70 | AM_CONDITIONAL([ESX], [test "$ESX" = yes]) | |
71 | if test "$ESX" = yes; then | |
72 | AC_DEFINE([ESX], [1], [Define to 1 if building on ESX.]) | |
73 | fi]) | |
74 | ||
064af421 BP |
75 | dnl Checks for Netlink support. |
76 | AC_DEFUN([OVS_CHECK_NETLINK], | |
77 | [AC_CHECK_HEADER([linux/netlink.h], | |
78 | [HAVE_NETLINK=yes], | |
79 | [HAVE_NETLINK=no], | |
80 | [#include <sys/socket.h> | |
81 | #include <linux/types.h> | |
82 | ]) | |
83 | AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes]) | |
84 | if test "$HAVE_NETLINK" = yes; then | |
85 | AC_DEFINE([HAVE_NETLINK], [1], | |
86 | [Define to 1 if Netlink protocol is available.]) | |
87 | fi]) | |
88 | ||
f272ec73 | 89 | dnl Checks for OpenSSL. |
064af421 BP |
90 | AC_DEFUN([OVS_CHECK_OPENSSL], |
91 | [AC_ARG_ENABLE( | |
92 | [ssl], | |
f272ec73 | 93 | [AC_HELP_STRING([--disable-ssl], [Disable OpenSSL support])], |
064af421 BP |
94 | [case "${enableval}" in |
95 | (yes) ssl=true ;; | |
96 | (no) ssl=false ;; | |
97 | (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;; | |
98 | esac], | |
f272ec73 | 99 | [ssl=check]) |
064af421 | 100 | |
f272ec73 | 101 | if test "$ssl" != false; then |
0f31bef5 | 102 | AX_CHECK_OPENSSL( |
48b9616a BP |
103 | [HAVE_OPENSSL=yes], |
104 | [HAVE_OPENSSL=no | |
f272ec73 | 105 | if test "$ssl" = check; then |
924c2434 | 106 | AC_MSG_WARN([Cannot find openssl: |
064af421 | 107 | |
48b9616a | 108 | $SSL_PKG_ERRORS |
064af421 | 109 | |
f272ec73 BP |
110 | OpenFlow connections over SSL will not be supported. |
111 | (You may use --disable-ssl to suppress this warning.)]) | |
112 | else | |
924c2434 | 113 | AC_MSG_ERROR([Cannot find openssl (use --disable-ssl to configure without SSL support)]) |
f272ec73 | 114 | fi]) |
869decd4 BP |
115 | else |
116 | HAVE_OPENSSL=no | |
064af421 | 117 | fi |
d27ce529 | 118 | AC_SUBST([HAVE_OPENSSL]) |
064af421 BP |
119 | AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes]) |
120 | if test "$HAVE_OPENSSL" = yes; then | |
121 | AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.]) | |
122 | fi]) | |
123 | ||
064af421 BP |
124 | dnl Checks for libraries needed by lib/socket-util.c. |
125 | AC_DEFUN([OVS_CHECK_SOCKET_LIBS], | |
126 | [AC_CHECK_LIB([socket], [connect]) | |
127 | AC_SEARCH_LIBS([gethostbyname], [resolv], [RESOLVER_LIBS=-lresolv])]) | |
128 | ||
129 | dnl Checks for the directory in which to store the PKI. | |
130 | AC_DEFUN([OVS_CHECK_PKIDIR], | |
131 | [AC_ARG_WITH( | |
2e22e1c7 EJ |
132 | [pkidir], |
133 | AC_HELP_STRING([--with-pkidir=DIR], | |
14bd2d51 | 134 | [PKI hierarchy directory [[LOCALSTATEDIR/lib/openvswitch/pki]]]), |
064af421 | 135 | [PKIDIR=$withval], |
14bd2d51 | 136 | [PKIDIR='${localstatedir}/lib/openvswitch/pki']) |
064af421 BP |
137 | AC_SUBST([PKIDIR])]) |
138 | ||
139 | dnl Checks for the directory in which to store pidfiles. | |
140 | AC_DEFUN([OVS_CHECK_RUNDIR], | |
141 | [AC_ARG_WITH( | |
2e22e1c7 EJ |
142 | [rundir], |
143 | AC_HELP_STRING([--with-rundir=DIR], | |
bc391960 JP |
144 | [directory used for pidfiles |
145 | [[LOCALSTATEDIR/run/openvswitch]]]), | |
064af421 | 146 | [RUNDIR=$withval], |
bc391960 | 147 | [RUNDIR='${localstatedir}/run/openvswitch']) |
064af421 BP |
148 | AC_SUBST([RUNDIR])]) |
149 | ||
150 | dnl Checks for the directory in which to store logs. | |
151 | AC_DEFUN([OVS_CHECK_LOGDIR], | |
152 | [AC_ARG_WITH( | |
2e22e1c7 EJ |
153 | [logdir], |
154 | AC_HELP_STRING([--with-logdir=DIR], | |
064af421 BP |
155 | [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]), |
156 | [LOGDIR=$withval], | |
157 | [LOGDIR='${localstatedir}/log/${PACKAGE}']) | |
158 | AC_SUBST([LOGDIR])]) | |
159 | ||
f973f2af BP |
160 | dnl Checks for the directory in which to store the Open vSwitch database. |
161 | AC_DEFUN([OVS_CHECK_DBDIR], | |
162 | [AC_ARG_WITH( | |
163 | [dbdir], | |
164 | AC_HELP_STRING([--with-dbdir=DIR], | |
165 | [directory used for conf.db [[SYSCONFDIR/PACKAGE]]]), | |
166 | [DBDIR=$withval], | |
167 | [DBDIR='${sysconfdir}/${PACKAGE}']) | |
168 | AC_SUBST([DBDIR])]) | |
169 | ||
92f75e60 | 170 | dnl Defines HAVE_BACKTRACE if backtrace() is found. |
0e6644c3 | 171 | AC_DEFUN([OVS_CHECK_BACKTRACE], |
3453ed24 YT |
172 | [AC_SEARCH_LIBS([backtrace], [execinfo ubacktrace], |
173 | [AC_DEFINE([HAVE_BACKTRACE], [1], | |
174 | [Define to 1 if you have backtrace(3).])])]) | |
0e6644c3 | 175 | |
064af421 BP |
176 | dnl Checks for __malloc_hook, etc., supported by glibc. |
177 | AC_DEFUN([OVS_CHECK_MALLOC_HOOKS], | |
178 | [AC_CACHE_CHECK( | |
179 | [whether libc supports hooks for malloc and related functions], | |
180 | [ovs_cv_malloc_hooks], | |
181 | [AC_COMPILE_IFELSE( | |
182 | [AC_LANG_PROGRAM( | |
183 | [#include <malloc.h> | |
2e22e1c7 | 184 | ], |
064af421 BP |
185 | [(void) __malloc_hook; |
186 | (void) __realloc_hook; | |
187 | (void) __free_hook;])], | |
188 | [ovs_cv_malloc_hooks=yes], | |
189 | [ovs_cv_malloc_hooks=no])]) | |
190 | if test $ovs_cv_malloc_hooks = yes; then | |
2e22e1c7 | 191 | AC_DEFINE([HAVE_MALLOC_HOOKS], [1], |
064af421 BP |
192 | [Define to 1 if you have __malloc_hook, __realloc_hook, and |
193 | __free_hook in <malloc.h>.]) | |
194 | fi]) | |
195 | ||
196 | dnl Checks for valgrind/valgrind.h. | |
2e22e1c7 | 197 | AC_DEFUN([OVS_CHECK_VALGRIND], |
064af421 BP |
198 | [AC_CHECK_HEADERS([valgrind/valgrind.h])]) |
199 | ||
3b135da3 BP |
200 | dnl Checks for Python 2.x, x >= 4. |
201 | AC_DEFUN([OVS_CHECK_PYTHON], | |
195b5c35 | 202 | [AC_CACHE_CHECK( |
3b135da3 BP |
203 | [for Python 2.x for x >= 4], |
204 | [ovs_cv_python], | |
205 | [if test -n "$PYTHON"; then | |
206 | ovs_cv_python=$PYTHON | |
207 | else | |
208 | ovs_cv_python=no | |
209 | for binary in python python2.4 python2.5; do | |
210 | ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR | |
211 | for dir in $PATH; do | |
212 | IFS=$ovs_save_IFS | |
213 | test -z "$dir" && dir=. | |
214 | if test -x $dir/$binary && $dir/$binary -c 'import sys | |
215 | if sys.hexversion >= 0x02040000 and sys.hexversion < 0x03000000: | |
216 | sys.exit(0) | |
217 | else: | |
218 | sys.exit(1)'; then | |
219 | ovs_cv_python=$dir/$binary | |
220 | break 2 | |
221 | fi | |
222 | done | |
223 | done | |
224 | fi]) | |
05b3c97b | 225 | AC_SUBST([HAVE_PYTHON]) |
195b5c35 BP |
226 | AM_MISSING_PROG([PYTHON], [python]) |
227 | if test $ovs_cv_python != no; then | |
228 | PYTHON=$ovs_cv_python | |
05b3c97b BP |
229 | HAVE_PYTHON=yes |
230 | else | |
231 | HAVE_PYTHON=no | |
232 | fi | |
233 | AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])]) | |
436f27dd | 234 | |
f8d739a9 BP |
235 | dnl Checks for dot. |
236 | AC_DEFUN([OVS_CHECK_DOT], | |
237 | [AC_CACHE_CHECK( | |
238 | [for dot], | |
239 | [ovs_cv_dot], | |
240 | [dnl "dot" writes -V output to stderr: | |
a5eef57e | 241 | if (dot -V) 2>&1 | grep '^dot - [[gG]]raphviz version' >/dev/null 2>&1; then |
f8d739a9 BP |
242 | ovs_cv_dot=yes |
243 | else | |
244 | ovs_cv_dot=no | |
f8d739a9 | 245 | fi]) |
7c9b0073 | 246 | AM_CONDITIONAL([HAVE_DOT], [test "$ovs_cv_dot" = yes])]) |
f8d739a9 | 247 | |
436f27dd AS |
248 | dnl Checks for pyuic4. |
249 | AC_DEFUN([OVS_CHECK_PYUIC4], | |
250 | [AC_CACHE_CHECK( | |
251 | [for pyuic4], | |
252 | [ovs_cv_pyuic4], | |
253 | [if (pyuic4 --version) >/dev/null 2>&1; then | |
254 | ovs_cv_pyuic4=pyuic4 | |
255 | else | |
256 | ovs_cv_pyuic4=no | |
257 | fi]) | |
258 | AM_MISSING_PROG([PYUIC4], [pyuic4]) | |
259 | if test $ovs_cv_pyuic4 != no; then | |
260 | PYUIC4=$ovs_cv_pyuic4 | |
261 | fi]) | |
262 | ||
263 | dnl Checks whether $PYTHON supports the module given as $1 | |
264 | AC_DEFUN([OVS_CHECK_PYTHON_MODULE], | |
265 | [AC_REQUIRE([OVS_CHECK_PYTHON]) | |
266 | AC_CACHE_CHECK( | |
267 | [for $1 Python module], | |
268 | [ovs_cv_py_[]AS_TR_SH([$1])], | |
269 | [ovs_cv_py_[]AS_TR_SH([$1])=no | |
270 | if test $HAVE_PYTHON = yes; then | |
271 | AS_ECHO(["running $PYTHON -c 'import $1 | |
272 | import sys | |
1df624e6 | 273 | sys.exit(0)'..."]) >&AS_MESSAGE_LOG_FD 2>&1 |
436f27dd AS |
274 | if $PYTHON -c 'import $1 |
275 | import sys | |
1df624e6 | 276 | sys.exit(0)' >&AS_MESSAGE_LOG_FD 2>&1; then |
436f27dd AS |
277 | ovs_cv_py_[]AS_TR_SH([$1])=yes |
278 | fi | |
279 | fi])]) | |
280 | ||
281 | dnl Checks for Python modules needed by ovsdbmonitor. | |
282 | AC_DEFUN([OVS_CHECK_OVSDBMONITOR], | |
283 | [OVS_CHECK_PYTHON_MODULE([PySide.QtCore]) | |
284 | OVS_CHECK_PYTHON_MODULE([PyQt4.QtCore]) | |
285 | OVS_CHECK_PYTHON_MODULE([twisted.conch.ssh]) | |
286 | OVS_CHECK_PYTHON_MODULE([twisted.internet]) | |
287 | OVS_CHECK_PYTHON_MODULE([twisted.application]) | |
288 | OVS_CHECK_PYTHON_MODULE([json]) | |
289 | OVS_CHECK_PYTHON_MODULE([zope.interface]) | |
290 | if (test $ovs_cv_py_PySide_QtCore = yes \ | |
291 | || test $ovs_cv_py_PyQt4_QtCore = yes) \ | |
292 | && test $ovs_cv_py_twisted_conch_ssh = yes \ | |
293 | && test $ovs_cv_py_twisted_internet = yes \ | |
294 | && test $ovs_cv_py_twisted_application = yes \ | |
295 | && test $ovs_cv_py_json = yes \ | |
296 | && test $ovs_cv_py_zope_interface = yes; then | |
297 | BUILD_OVSDBMONITOR=yes | |
298 | else | |
299 | BUILD_OVSDBMONITOR=no | |
300 | fi | |
301 | AC_MSG_CHECKING([whether to build ovsdbmonitor]) | |
302 | AC_MSG_RESULT([$BUILD_OVSDBMONITOR]) | |
303 | AM_CONDITIONAL([BUILD_OVSDBMONITOR], [test $BUILD_OVSDBMONITOR = yes])]) | |
480ce8ab BP |
304 | |
305 | # OVS_LINK2_IFELSE(SOURCE1, SOURCE2, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) | |
306 | # ------------------------------------------------------------- | |
307 | # Based on AC_LINK_IFELSE, but tries to link both SOURCE1 and SOURCE2 | |
308 | # into a program. | |
309 | # | |
310 | # This macro is borrowed from acinclude.m4 in GNU PSPP, which has the | |
311 | # following license: | |
312 | # | |
313 | # Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc. | |
314 | # This file is free software; the Free Software Foundation | |
315 | # gives unlimited permission to copy and/or distribute it, | |
316 | # with or without modifications, as long as this notice is preserved. | |
317 | # | |
318 | m4_define([OVS_LINK2_IFELSE], | |
319 | [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl | |
320 | mv conftest.$ac_ext conftest1.$ac_ext | |
321 | m4_ifvaln([$2], [AC_LANG_CONFTEST([$2])])dnl | |
322 | mv conftest.$ac_ext conftest2.$ac_ext | |
323 | rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext | |
324 | ovs_link2='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest1.$ac_ext conftest2.$ac_ext $LIBS >&5' | |
325 | AS_IF([_AC_DO_STDERR($ovs_link2) && { | |
326 | test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || | |
327 | test ! -s conftest.err | |
328 | } && test -s conftest$ac_exeext && { | |
329 | test "$cross_compiling" = yes || | |
330 | AS_TEST_X([conftest$ac_exeext]) | |
331 | }], | |
332 | [$3], | |
333 | [echo "$as_me: failed source file 1 of 2 was:" >&5 | |
334 | sed 's/^/| /' conftest1.$ac_ext >&5 | |
335 | echo "$as_me: failed source file 2 of 2 was:" >&5 | |
336 | sed 's/^/| /' conftest2.$ac_ext >&5 | |
337 | $4]) | |
338 | dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization) | |
339 | dnl information created by the PGI compiler (conftest_ipa8_conftest.oo), | |
340 | dnl as it would interfere with the next link command. | |
341 | rm -rf conftest.dSYM conftest1.dSYM conftest2.dSYM | |
342 | rm -f core conftest.err conftest1.err conftest2.err | |
343 | rm -f conftest1.$ac_objext conftest2.$ac_objext conftest*_ipa8_conftest*.oo | |
344 | rm -f conftest$ac_exeext | |
345 | rm -f m4_ifval([$1], [conftest1.$ac_ext]) m4_ifval([$2], [conftest1.$ac_ext])[]dnl | |
346 | ])# OVS_LINK2_IFELSE | |
347 | ||
348 | dnl Defines USE_LINKER_SECTIONS to 1 if the compiler supports putting | |
349 | dnl variables in sections with user-defined names and the linker | |
350 | dnl automatically defines __start_SECNAME and __stop_SECNAME symbols | |
351 | dnl that designate the start and end of the sections. | |
352 | AC_DEFUN([OVS_CHECK_LINKER_SECTIONS], | |
353 | [AC_CACHE_CHECK( | |
354 | [for user-defined linker section support], | |
355 | [ovs_cv_use_linker_sections], | |
356 | [OVS_LINK2_IFELSE( | |
357 | [AC_LANG_SOURCE( | |
358 | [int a __attribute__((__section__("mysection"))) = 1; | |
359 | int b __attribute__((__section__("mysection"))) = 2; | |
360 | int c __attribute__((__section__("mysection"))) = 3;])], | |
361 | [AC_LANG_PROGRAM( | |
362 | [#include <stdio.h> | |
363 | extern int __start_mysection; | |
364 | extern int __stop_mysection;], | |
365 | [int n_ints = &__stop_mysection - &__start_mysection; | |
366 | int *i; | |
367 | for (i = &__start_mysection; i < &__start_mysection + n_ints; i++) { | |
368 | printf("%d\n", *i); | |
369 | }])], | |
370 | [ovs_cv_use_linker_sections=yes], | |
371 | [ovs_cv_use_linker_sections=no])]) | |
372 | if test $ovs_cv_use_linker_sections = yes; then | |
373 | AC_DEFINE([USE_LINKER_SECTIONS], [1], | |
374 | [Define to 1 if the compiler support putting variables | |
375 | into sections with user-defined names and the linker | |
376 | automatically defines __start_SECNAME and __stop_SECNAME | |
377 | symbols that designate the start and end of the section.]) | |
611d30ce BP |
378 | fi |
379 | AM_CONDITIONAL( | |
380 | [USE_LINKER_SECTIONS], [test $ovs_cv_use_linker_sections = yes])]) | |
0027492d BP |
381 | |
382 | dnl Checks for groff. | |
383 | AC_DEFUN([OVS_CHECK_GROFF], | |
384 | [AC_CACHE_CHECK( | |
385 | [for groff], | |
386 | [ovs_cv_groff], | |
387 | [if (groff -v) >/dev/null 2>&1; then | |
388 | ovs_cv_groff=yes | |
389 | else | |
390 | ovs_cv_groff=no | |
391 | fi]) | |
392 | AM_CONDITIONAL([HAVE_GROFF], [test "$ovs_cv_groff" = yes])]) | |
c22095a5 BP |
393 | |
394 | dnl Checks for thread-local storage support. | |
395 | dnl | |
396 | dnl Checks whether the compiler and linker support the C11 | |
397 | dnl thread_local macro from <threads.h>, and if so defines | |
398 | dnl HAVE_THREAD_LOCAL. If not, checks whether the compiler and linker | |
399 | dnl support the GCC __thread extension, and if so defines | |
400 | dnl HAVE___THREAD. | |
401 | AC_DEFUN([OVS_CHECK_TLS], | |
402 | [AC_CACHE_CHECK( | |
403 | [whether $CC has <threads.h> that supports thread_local], | |
404 | [ovs_cv_thread_local], | |
405 | [AC_LINK_IFELSE( | |
406 | [AC_LANG_PROGRAM([#include <threads.h> | |
407 | static thread_local int var;], [return var;])], | |
408 | [ovs_cv_thread_local=yes], | |
409 | [ovs_cv_thread_local=no])]) | |
410 | if test $ovs_cv_thread_local = yes; then | |
411 | AC_DEFINE([HAVE_THREAD_LOCAL], [1], | |
412 | [Define to 1 if the C compiler and linker supports the C11 | |
413 | thread_local matcro defined in <threads.h>.]) | |
414 | else | |
415 | AC_CACHE_CHECK( | |
416 | [whether $CC supports __thread], | |
417 | [ovs_cv___thread], | |
418 | [AC_LINK_IFELSE( | |
419 | [AC_LANG_PROGRAM([static __thread int var;], [return var;])], | |
420 | [ovs_cv___thread=yes], | |
421 | [ovs_cv___thread=no])]) | |
422 | if test $ovs_cv___thread = yes; then | |
423 | AC_DEFINE([HAVE___THREAD], [1], | |
424 | [Define to 1 if the C compiler and linker supports the | |
425 | GCC __thread extenions.]) | |
426 | fi | |
427 | fi]) | |
31a3fc6e | 428 | |
15248032 BP |
429 | dnl OVS_CHECK_GCC4_ATOMICS |
430 | dnl | |
431 | dnl Checks whether the compiler and linker support GCC 4.0+ atomic built-ins. | |
432 | dnl A compile-time only check is not enough because the compiler defers | |
433 | dnl unimplemented built-ins to libgcc, which sometimes also lacks | |
434 | dnl implementations. | |
435 | AC_DEFUN([OVS_CHECK_GCC4_ATOMICS], | |
436 | [AC_CACHE_CHECK( | |
437 | [whether $CC supports GCC 4.0+ atomic built-ins], | |
438 | [ovs_cv_gcc4_atomics], | |
439 | [AC_LINK_IFELSE( | |
440 | [AC_LANG_PROGRAM([[#include <stdlib.h> | |
441 | ||
442 | #define ovs_assert(expr) if (!(expr)) abort(); | |
443 | #define TEST_ATOMIC_TYPE(TYPE) \ | |
444 | { \ | |
445 | TYPE x = 1; \ | |
446 | TYPE orig; \ | |
447 | \ | |
448 | __sync_synchronize(); \ | |
449 | ovs_assert(x == 1); \ | |
450 | \ | |
451 | __sync_synchronize(); \ | |
452 | x = 3; \ | |
453 | __sync_synchronize(); \ | |
454 | ovs_assert(x == 3); \ | |
455 | \ | |
456 | orig = __sync_fetch_and_add(&x, 1); \ | |
457 | ovs_assert(orig == 3); \ | |
458 | __sync_synchronize(); \ | |
459 | ovs_assert(x == 4); \ | |
460 | \ | |
461 | orig = __sync_fetch_and_sub(&x, 2); \ | |
462 | ovs_assert(orig == 4); \ | |
463 | __sync_synchronize(); \ | |
464 | ovs_assert(x == 2); \ | |
465 | \ | |
466 | orig = __sync_fetch_and_or(&x, 6); \ | |
467 | ovs_assert(orig == 2); \ | |
468 | __sync_synchronize(); \ | |
469 | ovs_assert(x == 6); \ | |
470 | \ | |
471 | orig = __sync_fetch_and_and(&x, 10); \ | |
472 | ovs_assert(orig == 6); \ | |
473 | __sync_synchronize(); \ | |
474 | ovs_assert(x == 2); \ | |
475 | \ | |
476 | orig = __sync_fetch_and_xor(&x, 10); \ | |
477 | ovs_assert(orig == 2); \ | |
478 | __sync_synchronize(); \ | |
479 | ovs_assert(x == 8); \ | |
480 | }]], [dnl | |
481 | TEST_ATOMIC_TYPE(char); | |
482 | TEST_ATOMIC_TYPE(unsigned char); | |
483 | TEST_ATOMIC_TYPE(signed char); | |
484 | TEST_ATOMIC_TYPE(short); | |
485 | TEST_ATOMIC_TYPE(unsigned short); | |
486 | TEST_ATOMIC_TYPE(int); | |
487 | TEST_ATOMIC_TYPE(unsigned int); | |
488 | TEST_ATOMIC_TYPE(long int); | |
489 | TEST_ATOMIC_TYPE(unsigned long int); | |
490 | TEST_ATOMIC_TYPE(long long int); | |
491 | TEST_ATOMIC_TYPE(unsigned long long int); | |
492 | ])], | |
493 | [ovs_cv_gcc4_atomics=yes], | |
494 | [ovs_cv_gcc4_atomics=no])]) | |
495 | if test $ovs_cv_gcc4_atomics = yes; then | |
496 | AC_DEFINE([HAVE_GCC4_ATOMICS], [1], | |
497 | [Define to 1 if the C compiler and linker supports the GCC 4.0+ | |
498 | atomic built-ins.]) | |
499 | fi]) | |
500 | ||
31a3fc6e BP |
501 | dnl OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE(SIZE) |
502 | dnl | |
503 | dnl Checks __atomic_always_lock_free(SIZE, 0) | |
504 | AC_DEFUN([OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE], | |
505 | [AC_CACHE_CHECK( | |
506 | [value of __atomic_always_lock_free($1)], | |
507 | [ovs_cv_atomic_always_lock_free_$1], | |
508 | [AC_COMPUTE_INT( | |
509 | [ovs_cv_atomic_always_lock_free_$1], | |
510 | [__atomic_always_lock_free($1, 0)], | |
511 | [], | |
512 | [ovs_cv_atomic_always_lock_free_$1=unsupported])]) | |
513 | if test ovs_cv_atomic_always_lock_free_$1 != unsupported; then | |
514 | AC_DEFINE_UNQUOTED( | |
515 | [ATOMIC_ALWAYS_LOCK_FREE_$1B], | |
516 | [$ovs_cv_atomic_always_lock_free_$1], | |
517 | [If the C compiler is GCC 4.7 or later, define to the return value of | |
518 | __atomic_always_lock_free($1, 0). If the C compiler is not GCC or is | |
519 | an older version of GCC, the value does not matter.]) | |
520 | fi]) | |
97eba8fc BP |
521 | |
522 | dnl OVS_CHECK_POSIX_AIO | |
523 | AC_DEFUN([OVS_CHECK_POSIX_AIO], | |
524 | [AC_SEARCH_LIBS([aio_write], [rt]) | |
525 | AM_CONDITIONAL([HAVE_POSIX_AIO], [test "$ac_cv_search_aio_write" != no])]) |