PageRenderTime 79ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/m4/openvswitch.m4

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