]>
Commit | Line | Data |
---|---|---|
064af421 BP |
1 | # -*- autoconf -*- |
2 | ||
12878bc4 | 3 | # Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 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. | |
0877a018 | 16 | # |
12878bc4 | 17 | m4_include([m4/compat.m4]) |
064af421 | 18 | |
c2b07021 BP |
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], | |
2e22e1c7 | 24 | [AC_HELP_STRING([--enable-coverage], |
c2b07021 BP |
25 | [Enable gcov coverage tool.])], |
26 | [case "${enableval}" in | |
8faa5a21 | 27 | (yes) coverage=true ;; |
7c126fbb | 28 | (no) coverage=false ;; |
c2b07021 BP |
29 | (*) AC_MSG_ERROR([bad value ${enableval} for --enable-coverage]) ;; |
30 | esac], | |
7c126fbb | 31 | [coverage=false]) |
c2b07021 | 32 | if $coverage; then |
27a79a44 BP |
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" | |
95626395 | 46 | OVS_LDFLAGS="$OVS_LDFLAGS --coverage" |
7c126fbb | 47 | fi]) |
c2b07021 | 48 | |
064af421 BP |
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], | |
2e22e1c7 | 53 | [AC_HELP_STRING([--enable-ndebug], |
064af421 BP |
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 | ||
361906b1 EJ |
63 | dnl Checks for ESX. |
64 | AC_DEFUN([OVS_CHECK_ESX], | |
65 | [AC_CHECK_HEADER([vmware.h], | |
66 | [ESX=yes], | |
67 | [ESX=no]) | |
68 | AM_CONDITIONAL([ESX], [test "$ESX" = yes]) | |
69 | if test "$ESX" = yes; then | |
70 | AC_DEFINE([ESX], [1], [Define to 1 if building on ESX.]) | |
71 | fi]) | |
72 | ||
1cb3649c AS |
73 | dnl Checks for MSVC x64 compiler. |
74 | AC_DEFUN([OVS_CHECK_WIN64], | |
75 | [AC_CACHE_CHECK( | |
76 | [for MSVC x64 compiler], | |
77 | [cl_cv_x64], | |
78 | [dnl "cl" writes x64 output to stdin: | |
79 | if (cl) 2>&1 | grep 'x64' >/dev/null 2>&1; then | |
80 | cl_cv_x64=yes | |
81 | MSVC64_LDFLAGS=" /MACHINE:X64 " | |
82 | else | |
83 | cl_cv_x64=no | |
84 | MSVC64_LDFLAGS="" | |
85 | fi]) | |
86 | AC_SUBST([MSVC64_LDFLAGS]) | |
87 | ]) | |
88 | ||
db6964bb GS |
89 | dnl Checks for WINDOWS. |
90 | AC_DEFUN([OVS_CHECK_WIN32], | |
91 | [AC_CHECK_HEADER([windows.h], | |
92 | [WIN32=yes], | |
93 | [WIN32=no]) | |
94 | AM_CONDITIONAL([WIN32], [test "$WIN32" = yes]) | |
95 | if test "$WIN32" = yes; then | |
94887cf4 GS |
96 | AC_ARG_WITH([pthread], |
97 | [AS_HELP_STRING([--with-pthread=DIR], | |
98 | [root of the pthread-win32 directory])], | |
99 | [ | |
100 | case "$withval" in | |
101 | "" | y | ye | yes | n | no) | |
102 | AC_MSG_ERROR([Invalid --with-pthread value]) | |
103 | ;; | |
104 | *) | |
1cb3649c AS |
105 | if (cl) 2>&1 | grep 'x64' >/dev/null 2>&1; then |
106 | cl_cv_x64=yes | |
107 | else | |
108 | cl_cv_x64=no | |
109 | fi | |
110 | if test "$cl_cv_x64" = yes; then | |
111 | PTHREAD_WIN32_DIR=$withval/lib/x64 | |
aca8be36 | 112 | PTHREAD_WIN32_DIR_DLL=/$(echo ${withval} | ${SED} -e 's/://')/dll/x64 |
1cb3649c AS |
113 | PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x64 |
114 | else | |
115 | PTHREAD_WIN32_DIR=$withval/lib/x86 | |
aca8be36 | 116 | PTHREAD_WIN32_DIR_DLL=/$(echo ${withval} | ${SED} -e 's/://')/dll/x86 |
1cb3649c AS |
117 | PTHREAD_WIN32_DIR_DLL_WIN_FORM=$withval/dll/x86 |
118 | fi | |
3e2e7588 AS |
119 | PTHREAD_INCLUDES=-I$withval/include |
120 | PTHREAD_LDFLAGS=-L$PTHREAD_WIN32_DIR | |
94887cf4 | 121 | PTHREAD_LIBS="-lpthreadVC2" |
1cb3649c | 122 | AC_SUBST([PTHREAD_WIN32_DIR_DLL_WIN_FORM]) |
3e2e7588 | 123 | AC_SUBST([PTHREAD_WIN32_DIR_DLL]) |
94887cf4 GS |
124 | AC_SUBST([PTHREAD_INCLUDES]) |
125 | AC_SUBST([PTHREAD_LDFLAGS]) | |
126 | AC_SUBST([PTHREAD_LIBS]) | |
127 | ;; | |
128 | esac | |
129 | ], [ | |
130 | AC_MSG_ERROR([pthread directory not specified]) | |
131 | ] | |
132 | ) | |
b0e1bce5 GS |
133 | AC_ARG_WITH([debug], |
134 | [AS_HELP_STRING([--with-debug], | |
135 | [Build without compiler optimizations])], | |
136 | [ | |
137 | MSVC_CFLAGS="-O0" | |
138 | AC_SUBST([MSVC_CFLAGS]) | |
139 | ], [ | |
140 | MSVC_CFLAGS="-O2" | |
141 | AC_SUBST([MSVC_CFLAGS]) | |
142 | ] | |
143 | ) | |
bd9d7025 | 144 | |
db6964bb | 145 | AC_DEFINE([WIN32], [1], [Define to 1 if building on WIN32.]) |
e42dfc72 AS |
146 | AH_BOTTOM([#ifdef WIN32 |
147 | #include "include/windows/windefs.h" | |
148 | #endif]) | |
db6964bb GS |
149 | fi]) |
150 | ||
bd9d7025 AS |
151 | dnl OVS_CHECK_WINDOWS |
152 | dnl | |
153 | dnl Configure Visual Studio solution build | |
154 | AC_DEFUN([OVS_CHECK_VISUAL_STUDIO_DDK], [ | |
d183efc2 AS |
155 | AC_ARG_WITH([vstudiotarget], |
156 | [AS_HELP_STRING([--with-vstudiotarget=target_type], | |
157 | [Target type: Debug/Release])], | |
bd9d7025 AS |
158 | [ |
159 | case "$withval" in | |
d183efc2 AS |
160 | "Release") ;; |
161 | "Debug") ;; | |
162 | *) AC_MSG_ERROR([No valid Visual Studio configuration found]) ;; | |
bd9d7025 AS |
163 | esac |
164 | ||
165 | VSTUDIO_CONFIG=$withval | |
166 | ], [ | |
167 | VSTUDIO_CONFIG= | |
168 | ] | |
169 | ) | |
170 | ||
171 | AC_SUBST([VSTUDIO_CONFIG]) | |
d183efc2 | 172 | AC_DEFINE([VSTUDIO_DDK], [1], [System uses the Visual Studio build target.]) |
bd9d7025 AS |
173 | AM_CONDITIONAL([VSTUDIO_DDK], [test -n "$VSTUDIO_CONFIG"]) |
174 | ]) | |
175 | ||
064af421 BP |
176 | dnl Checks for Netlink support. |
177 | AC_DEFUN([OVS_CHECK_NETLINK], | |
178 | [AC_CHECK_HEADER([linux/netlink.h], | |
179 | [HAVE_NETLINK=yes], | |
180 | [HAVE_NETLINK=no], | |
181 | [#include <sys/socket.h> | |
064af421 BP |
182 | ]) |
183 | AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes]) | |
184 | if test "$HAVE_NETLINK" = yes; then | |
185 | AC_DEFINE([HAVE_NETLINK], [1], | |
186 | [Define to 1 if Netlink protocol is available.]) | |
187 | fi]) | |
188 | ||
1bbebfb7 AZ |
189 | dnl Checks for libcap-ng. |
190 | AC_DEFUN([OVS_CHECK_LIBCAPNG], | |
191 | [AC_ARG_ENABLE( | |
192 | [libcapng], | |
193 | [AC_HELP_STRING([--disable-libcapng], [Disable Linux capability support])], | |
194 | [case "${enableval}" in | |
195 | (yes) libcapng=true ;; | |
196 | (no) libcapng=false ;; | |
197 | (*) AC_MSG_ERROR([bad value ${enableval} for --enable-libcapng]) ;; | |
198 | esac], | |
199 | [libcapng=check]) | |
200 | ||
201 | if test "$libcapng" != false; then | |
202 | AC_CHECK_LIB([cap-ng], [capng_clear], [HAVE_LIBCAPNG=yes]) | |
203 | ||
204 | if test "$HAVE_LIBCAPNG" != yes; then | |
205 | if test "$libcapng" = true ; then | |
206 | AC_MSG_ERROR([libcap-ng support requested, but not found]) | |
207 | fi | |
208 | if test "$libcapng" = check ; then | |
209 | AC_MSG_WARN([cannot find libcap-ng. | |
210 | --user option will not be supported on Linux. | |
211 | (you may use --disable-libcapng to suppress this warning). ]) | |
212 | fi | |
213 | fi | |
214 | fi | |
215 | ||
216 | AC_SUBST([HAVE_LIBCAPNG]) | |
217 | AM_CONDITIONAL([HAVE_LIBCAPNG], [test "$HAVE_LIBCAPNG" = yes]) | |
218 | if test "$HAVE_LIBCAPNG" = yes; then | |
219 | AC_DEFINE([HAVE_LIBCAPNG], [1], | |
220 | [Define to 1 if libcap-ng is available.]) | |
221 | CAPNG_LDADD="-lcap-ng" | |
222 | AC_SUBST([CAPNG_LDADD]) | |
223 | fi]) | |
224 | ||
f272ec73 | 225 | dnl Checks for OpenSSL. |
064af421 BP |
226 | AC_DEFUN([OVS_CHECK_OPENSSL], |
227 | [AC_ARG_ENABLE( | |
228 | [ssl], | |
f272ec73 | 229 | [AC_HELP_STRING([--disable-ssl], [Disable OpenSSL support])], |
064af421 BP |
230 | [case "${enableval}" in |
231 | (yes) ssl=true ;; | |
232 | (no) ssl=false ;; | |
233 | (*) AC_MSG_ERROR([bad value ${enableval} for --enable-ssl]) ;; | |
234 | esac], | |
f272ec73 | 235 | [ssl=check]) |
064af421 | 236 | |
f272ec73 | 237 | if test "$ssl" != false; then |
0f31bef5 | 238 | AX_CHECK_OPENSSL( |
48b9616a BP |
239 | [HAVE_OPENSSL=yes], |
240 | [HAVE_OPENSSL=no | |
f272ec73 | 241 | if test "$ssl" = check; then |
924c2434 | 242 | AC_MSG_WARN([Cannot find openssl: |
064af421 | 243 | |
48b9616a | 244 | $SSL_PKG_ERRORS |
064af421 | 245 | |
f272ec73 BP |
246 | OpenFlow connections over SSL will not be supported. |
247 | (You may use --disable-ssl to suppress this warning.)]) | |
248 | else | |
924c2434 | 249 | AC_MSG_ERROR([Cannot find openssl (use --disable-ssl to configure without SSL support)]) |
f272ec73 | 250 | fi]) |
869decd4 BP |
251 | else |
252 | HAVE_OPENSSL=no | |
064af421 | 253 | fi |
d27ce529 | 254 | AC_SUBST([HAVE_OPENSSL]) |
064af421 BP |
255 | AM_CONDITIONAL([HAVE_OPENSSL], [test "$HAVE_OPENSSL" = yes]) |
256 | if test "$HAVE_OPENSSL" = yes; then | |
257 | AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.]) | |
258 | fi]) | |
259 | ||
064af421 BP |
260 | dnl Checks for libraries needed by lib/socket-util.c. |
261 | AC_DEFUN([OVS_CHECK_SOCKET_LIBS], | |
262 | [AC_CHECK_LIB([socket], [connect]) | |
c6e02a5c | 263 | AC_SEARCH_LIBS([gethostbyname], [resolv])]) |
064af421 BP |
264 | |
265 | dnl Checks for the directory in which to store the PKI. | |
266 | AC_DEFUN([OVS_CHECK_PKIDIR], | |
267 | [AC_ARG_WITH( | |
2e22e1c7 EJ |
268 | [pkidir], |
269 | AC_HELP_STRING([--with-pkidir=DIR], | |
14bd2d51 | 270 | [PKI hierarchy directory [[LOCALSTATEDIR/lib/openvswitch/pki]]]), |
064af421 | 271 | [PKIDIR=$withval], |
14bd2d51 | 272 | [PKIDIR='${localstatedir}/lib/openvswitch/pki']) |
064af421 BP |
273 | AC_SUBST([PKIDIR])]) |
274 | ||
275 | dnl Checks for the directory in which to store pidfiles. | |
276 | AC_DEFUN([OVS_CHECK_RUNDIR], | |
277 | [AC_ARG_WITH( | |
2e22e1c7 EJ |
278 | [rundir], |
279 | AC_HELP_STRING([--with-rundir=DIR], | |
bc391960 JP |
280 | [directory used for pidfiles |
281 | [[LOCALSTATEDIR/run/openvswitch]]]), | |
064af421 | 282 | [RUNDIR=$withval], |
bc391960 | 283 | [RUNDIR='${localstatedir}/run/openvswitch']) |
064af421 BP |
284 | AC_SUBST([RUNDIR])]) |
285 | ||
286 | dnl Checks for the directory in which to store logs. | |
287 | AC_DEFUN([OVS_CHECK_LOGDIR], | |
288 | [AC_ARG_WITH( | |
2e22e1c7 EJ |
289 | [logdir], |
290 | AC_HELP_STRING([--with-logdir=DIR], | |
064af421 BP |
291 | [directory used for logs [[LOCALSTATEDIR/log/PACKAGE]]]), |
292 | [LOGDIR=$withval], | |
293 | [LOGDIR='${localstatedir}/log/${PACKAGE}']) | |
294 | AC_SUBST([LOGDIR])]) | |
295 | ||
f973f2af BP |
296 | dnl Checks for the directory in which to store the Open vSwitch database. |
297 | AC_DEFUN([OVS_CHECK_DBDIR], | |
298 | [AC_ARG_WITH( | |
299 | [dbdir], | |
300 | AC_HELP_STRING([--with-dbdir=DIR], | |
301 | [directory used for conf.db [[SYSCONFDIR/PACKAGE]]]), | |
302 | [DBDIR=$withval], | |
303 | [DBDIR='${sysconfdir}/${PACKAGE}']) | |
304 | AC_SUBST([DBDIR])]) | |
305 | ||
92f75e60 | 306 | dnl Defines HAVE_BACKTRACE if backtrace() is found. |
0e6644c3 | 307 | AC_DEFUN([OVS_CHECK_BACKTRACE], |
3453ed24 YT |
308 | [AC_SEARCH_LIBS([backtrace], [execinfo ubacktrace], |
309 | [AC_DEFINE([HAVE_BACKTRACE], [1], | |
310 | [Define to 1 if you have backtrace(3).])])]) | |
0e6644c3 | 311 | |
9a6156bb AZ |
312 | dnl Defines HAVE_PERF_EVENT if linux/perf_event.h is found. |
313 | AC_DEFUN([OVS_CHECK_PERF_EVENT], | |
314 | [AC_CHECK_HEADERS([linux/perf_event.h])]) | |
315 | ||
064af421 | 316 | dnl Checks for valgrind/valgrind.h. |
2e22e1c7 | 317 | AC_DEFUN([OVS_CHECK_VALGRIND], |
064af421 BP |
318 | [AC_CHECK_HEADERS([valgrind/valgrind.h])]) |
319 | ||
e23812fc | 320 | dnl Checks for Python 2.x, x >= 7. |
3b135da3 | 321 | AC_DEFUN([OVS_CHECK_PYTHON], |
195b5c35 | 322 | [AC_CACHE_CHECK( |
e23812fc | 323 | [for Python 2.x for x >= 7], |
3b135da3 BP |
324 | [ovs_cv_python], |
325 | [if test -n "$PYTHON"; then | |
326 | ovs_cv_python=$PYTHON | |
327 | else | |
328 | ovs_cv_python=no | |
e23812fc | 329 | for binary in python python2.7; do |
3b135da3 BP |
330 | ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR |
331 | for dir in $PATH; do | |
332 | IFS=$ovs_save_IFS | |
333 | test -z "$dir" && dir=. | |
4a6ba437 | 334 | if test -x "$dir"/"$binary" && "$dir"/"$binary" -c 'import sys |
e23812fc | 335 | if sys.hexversion >= 0x02070000 and sys.hexversion < 0x03000000: |
3b135da3 BP |
336 | sys.exit(0) |
337 | else: | |
338 | sys.exit(1)'; then | |
339 | ovs_cv_python=$dir/$binary | |
340 | break 2 | |
341 | fi | |
342 | done | |
343 | done | |
73eb682e RB |
344 | if test $ovs_cv_python != no; then |
345 | if test -x "$ovs_cv_python" && ! "$ovs_cv_python" -c 'import six' >/dev/null 2>&1; then | |
346 | ovs_cv_python=no | |
347 | AC_MSG_WARN([Missing Python six library.]) | |
348 | fi | |
349 | fi | |
3b135da3 | 350 | fi]) |
05b3c97b | 351 | AC_SUBST([HAVE_PYTHON]) |
195b5c35 BP |
352 | AM_MISSING_PROG([PYTHON], [python]) |
353 | if test $ovs_cv_python != no; then | |
354 | PYTHON=$ovs_cv_python | |
05b3c97b BP |
355 | HAVE_PYTHON=yes |
356 | else | |
357 | HAVE_PYTHON=no | |
358 | fi | |
359 | AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])]) | |
436f27dd | 360 | |
8fb7d026 RB |
361 | dnl Checks for Python 3.x, x >= 4. |
362 | AC_DEFUN([OVS_CHECK_PYTHON3], | |
363 | [AC_CACHE_CHECK( | |
364 | [for Python 3.x for x >= 4], | |
365 | [ovs_cv_python3], | |
366 | [if test -n "$PYTHON3"; then | |
367 | ovs_cv_python3=$PYTHON3 | |
368 | else | |
369 | ovs_cv_python3=no | |
370 | for binary in python3 python3.4; do | |
371 | ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR | |
372 | for dir in $PATH; do | |
373 | IFS=$ovs_save_IFS | |
374 | test -z "$dir" && dir=. | |
375 | if test -x "$dir"/"$binary" && "$dir"/"$binary" -c 'import sys | |
376 | if sys.hexversion >= 0x03040000 and sys.hexversion < 0x04000000: | |
377 | sys.exit(0) | |
378 | else: | |
379 | sys.exit(1)'; then | |
380 | ovs_cv_python3=$dir/$binary | |
381 | break 2 | |
382 | fi | |
383 | done | |
384 | done | |
1478295a IM |
385 | if test $ovs_cv_python3 != no; then |
386 | if test -x "$ovs_cv_python3" && ! "$ovs_cv_python3" -c 'import six' >/dev/null 2>&1; then | |
387 | ovs_cv_python3=no | |
8fb7d026 RB |
388 | AC_MSG_WARN([Missing Python six library.]) |
389 | fi | |
390 | fi | |
391 | fi]) | |
392 | AC_SUBST([HAVE_PYTHON3]) | |
393 | AM_MISSING_PROG([PYTHON3], [python3]) | |
394 | if test $ovs_cv_python3 != no; then | |
395 | PYTHON3=$ovs_cv_python3 | |
396 | HAVE_PYTHON3=yes | |
397 | else | |
398 | HAVE_PYTHON3=no | |
399 | fi | |
400 | AM_CONDITIONAL([HAVE_PYTHON3], [test "$HAVE_PYTHON3" = yes])]) | |
401 | ||
402 | ||
115d8719 RB |
403 | dnl Checks for dot. |
404 | AC_DEFUN([OVS_CHECK_FLAKE8], | |
405 | [AC_CACHE_CHECK( | |
406 | [for flake8], | |
407 | [ovs_cv_flake8], | |
408 | [if flake8 --version >/dev/null 2>&1; then | |
409 | ovs_cv_flake8=yes | |
410 | else | |
411 | ovs_cv_flake8=no | |
412 | fi]) | |
413 | AM_CONDITIONAL([HAVE_FLAKE8], [test "$ovs_cv_flake8" = yes])]) | |
414 | ||
f8d739a9 BP |
415 | dnl Checks for dot. |
416 | AC_DEFUN([OVS_CHECK_DOT], | |
417 | [AC_CACHE_CHECK( | |
418 | [for dot], | |
419 | [ovs_cv_dot], | |
420 | [dnl "dot" writes -V output to stderr: | |
a5eef57e | 421 | if (dot -V) 2>&1 | grep '^dot - [[gG]]raphviz version' >/dev/null 2>&1; then |
f8d739a9 BP |
422 | ovs_cv_dot=yes |
423 | else | |
424 | ovs_cv_dot=no | |
f8d739a9 | 425 | fi]) |
7c9b0073 | 426 | AM_CONDITIONAL([HAVE_DOT], [test "$ovs_cv_dot" = yes])]) |
f8d739a9 | 427 | |
0027492d BP |
428 | dnl Checks for groff. |
429 | AC_DEFUN([OVS_CHECK_GROFF], | |
430 | [AC_CACHE_CHECK( | |
431 | [for groff], | |
432 | [ovs_cv_groff], | |
433 | [if (groff -v) >/dev/null 2>&1; then | |
434 | ovs_cv_groff=yes | |
435 | else | |
436 | ovs_cv_groff=no | |
437 | fi]) | |
438 | AM_CONDITIONAL([HAVE_GROFF], [test "$ovs_cv_groff" = yes])]) | |
c22095a5 BP |
439 | |
440 | dnl Checks for thread-local storage support. | |
441 | dnl | |
442 | dnl Checks whether the compiler and linker support the C11 | |
443 | dnl thread_local macro from <threads.h>, and if so defines | |
444 | dnl HAVE_THREAD_LOCAL. If not, checks whether the compiler and linker | |
445 | dnl support the GCC __thread extension, and if so defines | |
446 | dnl HAVE___THREAD. | |
447 | AC_DEFUN([OVS_CHECK_TLS], | |
448 | [AC_CACHE_CHECK( | |
449 | [whether $CC has <threads.h> that supports thread_local], | |
450 | [ovs_cv_thread_local], | |
451 | [AC_LINK_IFELSE( | |
452 | [AC_LANG_PROGRAM([#include <threads.h> | |
453 | static thread_local int var;], [return var;])], | |
454 | [ovs_cv_thread_local=yes], | |
455 | [ovs_cv_thread_local=no])]) | |
456 | if test $ovs_cv_thread_local = yes; then | |
457 | AC_DEFINE([HAVE_THREAD_LOCAL], [1], | |
458 | [Define to 1 if the C compiler and linker supports the C11 | |
459 | thread_local matcro defined in <threads.h>.]) | |
460 | else | |
461 | AC_CACHE_CHECK( | |
462 | [whether $CC supports __thread], | |
463 | [ovs_cv___thread], | |
464 | [AC_LINK_IFELSE( | |
465 | [AC_LANG_PROGRAM([static __thread int var;], [return var;])], | |
466 | [ovs_cv___thread=yes], | |
467 | [ovs_cv___thread=no])]) | |
468 | if test $ovs_cv___thread = yes; then | |
469 | AC_DEFINE([HAVE___THREAD], [1], | |
470 | [Define to 1 if the C compiler and linker supports the | |
471 | GCC __thread extenions.]) | |
472 | fi | |
473 | fi]) | |
31a3fc6e | 474 | |
fd2e50cd JP |
475 | dnl OVS_CHECK_ATOMIC_LIBS |
476 | dnl | |
477 | dnl Check to see if -latomic is need for GCC atomic built-ins. | |
478 | AC_DEFUN([OVS_CHECK_ATOMIC_LIBS], | |
479 | [AC_SEARCH_LIBS([__atomic_load_8], [atomic])]) | |
480 | ||
15248032 BP |
481 | dnl OVS_CHECK_GCC4_ATOMICS |
482 | dnl | |
483 | dnl Checks whether the compiler and linker support GCC 4.0+ atomic built-ins. | |
484 | dnl A compile-time only check is not enough because the compiler defers | |
485 | dnl unimplemented built-ins to libgcc, which sometimes also lacks | |
486 | dnl implementations. | |
487 | AC_DEFUN([OVS_CHECK_GCC4_ATOMICS], | |
488 | [AC_CACHE_CHECK( | |
489 | [whether $CC supports GCC 4.0+ atomic built-ins], | |
490 | [ovs_cv_gcc4_atomics], | |
491 | [AC_LINK_IFELSE( | |
492 | [AC_LANG_PROGRAM([[#include <stdlib.h> | |
493 | ||
494 | #define ovs_assert(expr) if (!(expr)) abort(); | |
495 | #define TEST_ATOMIC_TYPE(TYPE) \ | |
496 | { \ | |
497 | TYPE x = 1; \ | |
498 | TYPE orig; \ | |
499 | \ | |
500 | __sync_synchronize(); \ | |
501 | ovs_assert(x == 1); \ | |
502 | \ | |
503 | __sync_synchronize(); \ | |
504 | x = 3; \ | |
505 | __sync_synchronize(); \ | |
506 | ovs_assert(x == 3); \ | |
507 | \ | |
508 | orig = __sync_fetch_and_add(&x, 1); \ | |
509 | ovs_assert(orig == 3); \ | |
510 | __sync_synchronize(); \ | |
511 | ovs_assert(x == 4); \ | |
512 | \ | |
513 | orig = __sync_fetch_and_sub(&x, 2); \ | |
514 | ovs_assert(orig == 4); \ | |
515 | __sync_synchronize(); \ | |
516 | ovs_assert(x == 2); \ | |
517 | \ | |
518 | orig = __sync_fetch_and_or(&x, 6); \ | |
519 | ovs_assert(orig == 2); \ | |
520 | __sync_synchronize(); \ | |
521 | ovs_assert(x == 6); \ | |
522 | \ | |
523 | orig = __sync_fetch_and_and(&x, 10); \ | |
524 | ovs_assert(orig == 6); \ | |
525 | __sync_synchronize(); \ | |
526 | ovs_assert(x == 2); \ | |
527 | \ | |
528 | orig = __sync_fetch_and_xor(&x, 10); \ | |
529 | ovs_assert(orig == 2); \ | |
530 | __sync_synchronize(); \ | |
531 | ovs_assert(x == 8); \ | |
532 | }]], [dnl | |
533 | TEST_ATOMIC_TYPE(char); | |
534 | TEST_ATOMIC_TYPE(unsigned char); | |
535 | TEST_ATOMIC_TYPE(signed char); | |
536 | TEST_ATOMIC_TYPE(short); | |
537 | TEST_ATOMIC_TYPE(unsigned short); | |
538 | TEST_ATOMIC_TYPE(int); | |
539 | TEST_ATOMIC_TYPE(unsigned int); | |
540 | TEST_ATOMIC_TYPE(long int); | |
541 | TEST_ATOMIC_TYPE(unsigned long int); | |
542 | TEST_ATOMIC_TYPE(long long int); | |
543 | TEST_ATOMIC_TYPE(unsigned long long int); | |
544 | ])], | |
545 | [ovs_cv_gcc4_atomics=yes], | |
546 | [ovs_cv_gcc4_atomics=no])]) | |
547 | if test $ovs_cv_gcc4_atomics = yes; then | |
548 | AC_DEFINE([HAVE_GCC4_ATOMICS], [1], | |
549 | [Define to 1 if the C compiler and linker supports the GCC 4.0+ | |
550 | atomic built-ins.]) | |
551 | fi]) | |
552 | ||
31a3fc6e BP |
553 | dnl OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE(SIZE) |
554 | dnl | |
555 | dnl Checks __atomic_always_lock_free(SIZE, 0) | |
556 | AC_DEFUN([OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE], | |
557 | [AC_CACHE_CHECK( | |
558 | [value of __atomic_always_lock_free($1)], | |
559 | [ovs_cv_atomic_always_lock_free_$1], | |
560 | [AC_COMPUTE_INT( | |
561 | [ovs_cv_atomic_always_lock_free_$1], | |
562 | [__atomic_always_lock_free($1, 0)], | |
563 | [], | |
564 | [ovs_cv_atomic_always_lock_free_$1=unsupported])]) | |
565 | if test ovs_cv_atomic_always_lock_free_$1 != unsupported; then | |
566 | AC_DEFINE_UNQUOTED( | |
567 | [ATOMIC_ALWAYS_LOCK_FREE_$1B], | |
568 | [$ovs_cv_atomic_always_lock_free_$1], | |
569 | [If the C compiler is GCC 4.7 or later, define to the return value of | |
570 | __atomic_always_lock_free($1, 0). If the C compiler is not GCC or is | |
571 | an older version of GCC, the value does not matter.]) | |
572 | fi]) | |
97eba8fc BP |
573 | |
574 | dnl OVS_CHECK_POSIX_AIO | |
575 | AC_DEFUN([OVS_CHECK_POSIX_AIO], | |
576 | [AC_SEARCH_LIBS([aio_write], [rt]) | |
577 | AM_CONDITIONAL([HAVE_POSIX_AIO], [test "$ac_cv_search_aio_write" != no])]) | |
ed1be787 BP |
578 | |
579 | dnl OVS_CHECK_INCLUDE_NEXT | |
580 | AC_DEFUN([OVS_CHECK_INCLUDE_NEXT], | |
581 | [AC_REQUIRE([gl_CHECK_NEXT_HEADERS]) | |
582 | gl_CHECK_NEXT_HEADERS([$1])]) | |
aa8ea223 DDP |
583 | |
584 | dnl OVS_CHECK_PRAGMA_MESSAGE | |
585 | AC_DEFUN([OVS_CHECK_PRAGMA_MESSAGE], | |
586 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( | |
587 | [[_Pragma("message(\"Checking for pragma message\")") | |
588 | ]])], | |
589 | [AC_DEFINE(HAVE_PRAGMA_MESSAGE,1,[Define if compiler supports #pragma | |
590 | message directive])]) | |
591 | ]) |