configure.ac 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.59])
  4. AC_INIT(bind10-devel, 20110224, bind10-dev@isc.org)
  5. AC_CONFIG_SRCDIR(README)
  6. AM_INIT_AUTOMAKE
  7. AC_CONFIG_HEADERS([config.h])
  8. # Checks for programs.
  9. AC_PROG_CXX
  10. # Libtool configuration
  11. #
  12. # On FreeBSD (and probably some others), clang++ does not meet an autoconf
  13. # assumption in identifying libtool configuration regarding shared library:
  14. # the configure script will execute "$CC -shared $CFLAGS/$CXXFLAGS -v" and
  15. # expect the output contains -Lxxx or -Ryyy. This is the case for g++, but
  16. # not for clang++, and, as a result, it will cause various errors in linking
  17. # programs or running them with a shared object (such as some of our python
  18. # scripts).
  19. # To work around this problem we define a temporary variable
  20. # "CXX_LIBTOOL_LDFLAGS". It's expected to be defined as, e.g, "-L/usr/lib"
  21. # to temporarily fake the output so that it will be compatible with that of
  22. # g++.
  23. CFLAGS_SAVED=$CFLAGS
  24. CXXFLAGS_SAVED=$CXXFLAGS
  25. CFLAGS="$CFLAGS $CXX_LIBTOOL_LDFLAGS"
  26. CXXFLAGS="$CXXFLAGS $CXX_LIBTOOL_LDFLAGS"
  27. AC_PROG_LIBTOOL
  28. CFLAGS=$CFLAGS_SAVED
  29. CXXFLAGS=$CXXFLAGS_SAVED
  30. # Use C++ language
  31. AC_LANG([C++])
  32. # Identify the compiler: this check must be after AC_PROG_CXX and AC_LANG.
  33. AM_CONDITIONAL(USE_GXX, test "X${GXX}" = "Xyes")
  34. AC_CHECK_DECL([__SUNPRO_CC], [SUNCXX="yes"], [SUNCXX="no"])
  35. AC_CHECK_DECL([__clang__], [CLANGPP="yes"], [CLANGPP="no"])
  36. AM_CONDITIONAL(USE_CLANGPP, test "X${CLANGPP}" = "Xyes")
  37. # Linker options
  38. # check -R rather than gcc specific -rpath to be as portable as possible.
  39. AC_MSG_CHECKING([whether -R flag is available in linker])
  40. LDFLAGS_SAVED="$LDFLAGS"
  41. LDFLAGS="$LDFLAGS -R/usr/lib"
  42. AC_TRY_LINK([],[],
  43. [ AC_MSG_RESULT(yes)
  44. rpath_available=yes
  45. ],[ AC_MSG_RESULT(no)
  46. rpath_available=no
  47. ])
  48. LDFLAGS=$LDFLAGS_SAVED
  49. # allow building programs with static link. we need to make it selective
  50. # because loadable modules cannot be statically linked.
  51. AC_ARG_ENABLE([static-link],
  52. AC_HELP_STRING([--enable-static-link],
  53. [build programs with static link [[default=no]]]),
  54. [enable_static_link=yes], [enable_static_link=no])
  55. AM_CONDITIONAL(USE_STATIC_LINK, test $enable_static_link = yes)
  56. # Check validity about some libtool options
  57. if test $enable_static_link = yes -a $enable_static = no; then
  58. AC_MSG_ERROR([--enable-static-link requires --enable-static])
  59. fi
  60. if test $enable_shared = no; then
  61. AC_MSG_ERROR([BIND 10 requires shared libraries to be built])
  62. fi
  63. AC_ARG_ENABLE(boost-threads,
  64. AC_HELP_STRING([--enable-boost-threads],
  65. [use boost threads. Currently this only means using its locks instead of dummy locks, in the cache and NSAS]),
  66. use_boost_threads=$enableval, use_boost_threads=no)
  67. # allow configuring without setproctitle.
  68. AC_ARG_ENABLE(setproctitle-check,
  69. AC_HELP_STRING([--disable-setproctitle-check],
  70. [do not check for python setproctitle module (used to give nice names to python processes)]),
  71. setproctitle_check=$enableval, setproctitle_check=yes)
  72. # OS dependent configuration
  73. SET_ENV_LIBRARY_PATH=no
  74. ENV_LIBRARY_PATH=LD_LIBRARY_PATH
  75. case "$host" in
  76. *-solaris*)
  77. # Solaris requires special definitions to get some standard libraries
  78. # (e.g. getopt(3)) available with common used header files.
  79. CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
  80. ;;
  81. *-apple-darwin*)
  82. # libtool doesn't work perfectly with Darwin: libtool embeds the
  83. # final install path in dynamic libraries and our loadable python
  84. # modules always refer to that path even if it's loaded within the
  85. # source tree. This prevents pre-install tests from working.
  86. # To work around this problem we explicitly specify paths to dynamic
  87. # libraries when we use them in the source tree.
  88. SET_ENV_LIBRARY_PATH=yes
  89. ENV_LIBRARY_PATH=DYLD_LIBRARY_PATH
  90. ;;
  91. esac
  92. AM_CONDITIONAL(SET_ENV_LIBRARY_PATH, test $SET_ENV_LIBRARY_PATH = yes)
  93. AC_SUBST(SET_ENV_LIBRARY_PATH)
  94. AC_SUBST(ENV_LIBRARY_PATH)
  95. m4_define([_AM_PYTHON_INTERPRETER_LIST], [python python3 python3.1])
  96. AC_ARG_WITH([pythonpath],
  97. AC_HELP_STRING([--with-pythonpath=PATH],
  98. [specify an absolute path to python executable when automatic version check (incorrectly) fails]),
  99. [python_path="$withval"], [python_path="auto"])
  100. if test "$python_path" = auto; then
  101. AM_PATH_PYTHON([3.1])
  102. else
  103. # Older versions of automake can't handle python3 well. This is an
  104. # in-house workaround for them.
  105. PYTHON=$python_path
  106. AC_SUBST(PYTHON)
  107. PYTHON_PREFIX='${prefix}'
  108. AC_SUBST(PYTHON_PREFIX)
  109. PYTHON_EXEC_PREFIX='$(exec_prefix)'
  110. AC_SUBST(PYTHON_EXEC_PREFIX)
  111. PYTHON_VERSION=[`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"`]
  112. if test `echo "$PYTHON_VERSION >= 3.1" | bc` != 1 ; then
  113. AC_MSG_ERROR(["Python version too old: $PYTHON_VERSION, need 3.1 or higher"])
  114. fi
  115. AC_SUBST(PYTHON_VERSION)
  116. PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
  117. AC_SUBST(PYTHON_PLATFORM)
  118. pythondir='${prefix}/lib/python'$PYTHON_VERSION'/site-packages'
  119. AC_SUBST(pythondir)
  120. pkgpythondir='${pythondir}/'$PACKAGE
  121. AC_SUBST(pkgpythondir)
  122. pyexecdir='${exec_prefix}/lib/python'$PYTHON_VERSION'/site-packages'
  123. AC_SUBST(pyexecdir)
  124. pkgpyexecdir='${pyexecdir}/'$PACKAGE
  125. AC_SUBST(pkgpyexecdir)
  126. fi
  127. # Check for python development environments
  128. if test -x ${PYTHON}-config; then
  129. PYTHON_INCLUDES=`${PYTHON}-config --includes`
  130. for flag in `${PYTHON}-config --ldflags`; do
  131. # add any '-L..." flags to PYTHON_LDFLAGS
  132. flag=`echo $flag | sed -ne 's/^\(\-L.*\)$/\1/p'`
  133. if test "X${flag}" != X; then
  134. PYTHON_LDFLAGS="$PYTHON_LDFLAGS ${flag}"
  135. fi
  136. done
  137. # on some platforms, ${PYTHON}-config --ldflags doesn't provide a -L
  138. # option while having the library under a non trivial directory.
  139. # as a workaround we try the "lib" sub directory under the common
  140. # prefix for this python.
  141. if test -z "${PYTHON_LDFLAGS}"; then
  142. PYTHON_LDFLAGS="-L`${PYTHON}-config --prefix`/lib"
  143. fi
  144. else
  145. if test "X$PYTHON_INCLUDES" = X -o "X$PYTHON_LDFLAGS" = X; then
  146. AC_MSG_WARN([${PYTHON}-config does not exist or is not executable, so we could not detect python development environment. Your system may require an additional package (e.g. "python3-dev"). Alternatively, if you are sure you have python headers and libraries, define PYTHON_INCLUDES and PYTHON_LDFLAGS and run this script.])
  147. fi
  148. fi
  149. # Some OSes including NetBSD don't install libpython.so in a well known path.
  150. # To avoid requiring dynamic library path with our python wrapper loadable
  151. # modules, we embed the path to the modules when possible. We do this even
  152. # when the path is known in the common operational environment (e.g. when
  153. # it's stored in a common "hint" file) for simplicity.
  154. if test $rpath_available = yes; then
  155. python_rpath=
  156. for flag in ${PYTHON_LDFLAGS}; do
  157. python_rpath="${python_rpath} `echo $flag | sed -ne 's/^\(\-L\)/-R/p'`"
  158. done
  159. PYTHON_LDFLAGS="${PYTHON_LDFLAGS} ${python_rpath}"
  160. fi
  161. AC_SUBST(PYTHON_INCLUDES)
  162. AC_SUBST(PYTHON_LDFLAGS)
  163. CPPFLAGS_SAVED="$CPPFLAGS"
  164. CPPFLAGS="$CPPFLAGS ${PYTHON_INCLUDES}"
  165. AC_CHECK_HEADERS([Python.h],, AC_MSG_ERROR([Missing Python.h]))
  166. CPPFLAGS="$CPPFLAGS_SAVED"
  167. # Check for python library. Needed for Python-wrapper libraries.
  168. LDFLAGS_SAVED="$LDFLAGS"
  169. LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
  170. python_bin="python${PYTHON_VERSION}"
  171. AC_CHECK_LIB($python_bin, main, python_lib=$python_bin, python_lib=no)
  172. if test $python_lib != "no"; then
  173. PYTHON_LIB="-l$python_lib"
  174. fi
  175. AC_SUBST(PYTHON_LIB)
  176. LDFLAGS=$LDFLAGS_SAVED
  177. # Check for the setproctitle module
  178. if test "$setproctitle_check" = "yes" ; then
  179. AC_MSG_CHECKING(for setproctitle module)
  180. if "$PYTHON" -c 'import setproctitle' 2>/dev/null ; then
  181. AC_MSG_RESULT(ok)
  182. else
  183. AC_MSG_RESULT(missing)
  184. AC_MSG_WARN([Missing setproctitle python module.
  185. Use --disable-setproctitle-check to skip this check.
  186. In this case we will continue, but naming of python processes will not work.])
  187. fi
  188. fi
  189. # TODO: check for _sqlite3.py module
  190. # Compiler dependent settings: define some mandatory CXXFLAGS here.
  191. # We also use a separate variable B10_CXXFLAGS. This will (and should) be
  192. # used as the default value for each specific AM_CXXFLAGS:
  193. # AM_CXXFLAGS = $(B10_CXXFLAGS)
  194. # AM_CXXFLAGS += ... # add module specific flags
  195. # We need this so that we can disable some specific compiler warnings per
  196. # module basis; since AM_CXXFLAGS are placed before CXXFLAGS, and since
  197. # gcc's -Wno-XXX option must be specified after -Wall or -Wextra, we cannot
  198. # specify the default warning flags in CXXFLAGS and let specific modules
  199. # "override" the default.
  200. # This may be used to try linker flags.
  201. AC_DEFUN([BIND10_CXX_TRY_FLAG], [
  202. AC_MSG_CHECKING([whether $CXX supports $1])
  203. bind10_save_CXXFLAGS="$CXXFLAGS"
  204. CXXFLAGS="$CXXFLAGS $1"
  205. AC_LINK_IFELSE([int main(void){ return 0;} ],
  206. [bind10_cxx_flag=yes], [bind10_cxx_flag=no])
  207. CXXFLAGS="$bind10_save_CXXFLAGS"
  208. if test "x$bind10_cxx_flag" = "xyes"; then
  209. ifelse([$2], , :, [$2])
  210. else
  211. ifelse([$3], , :, [$3])
  212. fi
  213. AC_MSG_RESULT([$bind10_cxx_flag])
  214. ])
  215. werror_ok=0
  216. # SunStudio compiler requires special compiler options for boost
  217. # (http://blogs.sun.com/sga/entry/boost_mini_howto)
  218. if test "$SUNCXX" = "yes"; then
  219. CXXFLAGS="$CXXFLAGS -library=stlport4 -features=tmplife -features=tmplrefstatic"
  220. MULTITHREADING_FLAG="-mt"
  221. fi
  222. BIND10_CXX_TRY_FLAG(-Wno-missing-field-initializers,
  223. [WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG="-Wno-missing-field-initializers"])
  224. AC_SUBST(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG)
  225. # gcc specific settings:
  226. if test "X$GXX" = "Xyes"; then
  227. B10_CXXFLAGS="-Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
  228. case "$host" in
  229. *-solaris*)
  230. MULTITHREADING_FLAG=-pthreads
  231. ;;
  232. *)
  233. MULTITHREADING_FLAG=-pthread
  234. ;;
  235. esac
  236. # Certain versions of gcc (g++) have a bug that incorrectly warns about
  237. # the use of anonymous name spaces even if they're closed in a single
  238. # translation unit. For these versions we have to disable -Werror.
  239. CXXFLAGS_SAVED="$CXXFLAGS"
  240. CXXFLAGS="$CXXFLAGS $B10_CXXFLAGS -Werror"
  241. AC_MSG_CHECKING(for in-TU anonymous namespace breakage)
  242. AC_TRY_COMPILE([namespace { class Foo {}; }
  243. namespace isc {class Bar {Foo foo_;};} ],,
  244. [AC_MSG_RESULT(no)
  245. werror_ok=1
  246. B10_CXXFLAGS="$B10_CXXFLAGS -Werror"],
  247. [AC_MSG_RESULT(yes)])
  248. CXXFLAGS="$CXXFLAGS_SAVED"
  249. fi dnl GXX = yes
  250. AM_CONDITIONAL(GCC_WERROR_OK, test $werror_ok = 1)
  251. # produce PIC unless we disable shared libraries. need this for python bindings.
  252. if test $enable_shared != "no" -a "X$GXX" = "Xyes"; then
  253. B10_CXXFLAGS="$B10_CXXFLAGS -fPIC"
  254. fi
  255. AC_SUBST(B10_CXXFLAGS)
  256. # Checks for libraries.
  257. AC_SEARCH_LIBS(inet_pton, [nsl])
  258. AC_SEARCH_LIBS(recvfrom, [socket])
  259. AC_SEARCH_LIBS(nanosleep, [rt])
  260. # Checks for header files.
  261. # Checks for typedefs, structures, and compiler characteristics.
  262. AC_HEADER_STDBOOL
  263. AC_TYPE_SIZE_T
  264. AC_MSG_CHECKING(for sa_len in struct sockaddr)
  265. AC_TRY_COMPILE([
  266. #include <sys/types.h>
  267. #include <sys/socket.h>],
  268. [struct sockaddr sa; sa.sa_len = 0; return (0);],
  269. [AC_MSG_RESULT(yes)
  270. AC_DEFINE(HAVE_SA_LEN, 1, [Define to 1 if sockaddr has a sa_len member, and corresponding sin_len and sun_len])],
  271. AC_MSG_RESULT(no))
  272. AC_ARG_WITH(pycoverage,
  273. [ --with-pycoverage[=PROGRAM] enable python code coverage using the specified coverage], pycoverage="$withval", pycoverage="no")
  274. if test "$pycoverage" = "no" ; then
  275. # just run the tests normally with python
  276. PYCOVERAGE_RUN="${PYTHON}"
  277. USE_PYCOVERAGE="no"
  278. elif test "$pycoverage" = "yes" ; then
  279. PYCOVERAGE="coverage"
  280. PYCOVERAGE_RUN="${PYCOVERAGE} run --branch --append"
  281. USE_PYCOVERAGE="yes"
  282. else
  283. PYCOVERAGE="$pycoverage"
  284. PYCOVERAGE_RUN="${PYCOVERAGE} run --branch --append"
  285. USE_PYCOVERAGE="yes"
  286. fi
  287. AM_CONDITIONAL(ENABLE_PYTHON_COVERAGE, test x$USE_PYCOVERAGE != xno)
  288. AC_SUBST(PYCOVERAGE)
  289. AC_SUBST(PYCOVERAGE_RUN)
  290. AC_SUBST(USE_PYCOVERAGE)
  291. AC_ARG_WITH(lcov,
  292. [ --with-lcov[=PROGRAM] enable gtest and coverage target using the specified lcov], lcov="$withval", lcov="no")
  293. AC_ARG_WITH(gtest,
  294. [ --with-gtest=PATH specify a path to gtest header files (PATH/include) and library (PATH/lib)],
  295. gtest_path="$withval", gtest_path="no")
  296. USE_LCOV="no"
  297. if test "$lcov" != "no"; then
  298. # force gtest if not set
  299. if test "$gtest_path" = "no"; then
  300. # AC_MSG_ERROR("lcov needs gtest for test coverage report")
  301. AC_MSG_NOTICE([gtest support is now enabled, because used by coverage tests])
  302. gtest_path="yes"
  303. fi
  304. if test "$lcov" != "yes"; then
  305. LCOV=$lcov
  306. else
  307. AC_PATH_PROG([LCOV], [lcov])
  308. fi
  309. if test -x "${LCOV}"; then
  310. USE_LCOV="yes"
  311. else
  312. AC_MSG_ERROR([Cannot find lcov.])
  313. fi
  314. # is genhtml always in the same directory?
  315. GENHTML=`echo "$LCOV" | sed s/lcov$/genhtml/`
  316. if test ! -x $GENHTML; then
  317. AC_MSG_ERROR([genhtml not found, needed for lcov])
  318. fi
  319. # GCC specific?
  320. CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
  321. LIBS=" $LIBS -lgcov"
  322. AC_SUBST(CPPFLAGS)
  323. AC_SUBST(LIBS)
  324. AC_SUBST(LCOV)
  325. AC_SUBST(GENHTML)
  326. fi
  327. AC_SUBST(USE_LCOV)
  328. #
  329. # Configure Boost header path
  330. #
  331. # If explicitly specified, use it.
  332. AC_ARG_WITH([boost-include],
  333. AC_HELP_STRING([--with-boost-include=PATH],
  334. [specify exact directory for Boost headers]),
  335. [boost_include_path="$withval"])
  336. # If not specified, try some common paths.
  337. if test -z "$with_boost_include"; then
  338. boostdirs="/usr/local /usr/pkg /opt /opt/local"
  339. for d in $boostdirs
  340. do
  341. if test -f $d/include/boost/shared_ptr.hpp; then
  342. boost_include_path=$d/include
  343. break
  344. fi
  345. done
  346. fi
  347. CPPFLAGS_SAVES="$CPPFLAGS"
  348. if test "${boost_include_path}" ; then
  349. BOOST_INCLUDES="-I${boost_include_path}"
  350. CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES"
  351. fi
  352. AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/foreach.hpp boost/interprocess/sync/interprocess_upgradable_mutex.hpp boost/date_time/posix_time/posix_time_types.hpp boost/bind.hpp boost/function.hpp],,
  353. AC_MSG_ERROR([Missing required header files.]))
  354. CPPFLAGS="$CPPFLAGS_SAVES"
  355. AC_SUBST(BOOST_INCLUDES)
  356. if test "${use_boost_threads}" = "yes" ; then
  357. AC_DEFINE([USE_BOOST_THREADS], [], [Use boost threads])
  358. # Using boost::mutex can result in requiring libboost_thread with older
  359. # versions of Boost. We'd like to avoid relying on a compiled Boost library
  360. # whenever possible, so we need to check for it step by step.
  361. #
  362. # NOTE: another fix of this problem is to simply require newer versions of
  363. # boost. If we choose that solution we should simplify the following tricky
  364. # checks accordingly and all Makefile.am's that refer to NEED_LIBBOOST_THREAD.
  365. AC_MSG_CHECKING(for boost::mutex)
  366. CPPFLAGS_SAVES="$CPPFLAGS"
  367. LIBS_SAVES="$LIBS"
  368. CPPFLAGS="$BOOST_INCLUDES $CPPFLAGS $MULTITHREADING_FLAG"
  369. need_libboost_thread=0
  370. need_sunpro_workaround=0
  371. AC_TRY_LINK([
  372. #include <boost/thread.hpp>
  373. ],[
  374. boost::mutex m;
  375. ],
  376. [ AC_MSG_RESULT(yes (without libboost_thread)) ],
  377. # there is one specific problem with SunStudio 5.10
  378. # where including boost/thread causes a compilation failure
  379. # There is a workaround in boost but it checks the version not being 5.10
  380. # This will probably be fixed in the future, in which case this
  381. # is only a temporary workaround
  382. [ AC_TRY_LINK([
  383. #if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
  384. #undef __SUNPRO_CC
  385. #define __SUNPRO_CC 0x5090
  386. #endif
  387. #include <boost/thread.hpp>
  388. ],[
  389. boost::mutex m;
  390. ],
  391. [ AC_MSG_RESULT(yes (with SUNOS workaround))
  392. need_sunpro_workaround=1 ],
  393. [ LIBS=" $LIBS -lboost_thread"
  394. AC_TRY_LINK([
  395. #include <boost/thread.hpp>
  396. ],[
  397. boost::mutex m;
  398. ],
  399. [ AC_MSG_RESULT(yes (with libboost_thread))
  400. need_libboost_thread=1 ],
  401. [ AC_MSG_RESULT(no)
  402. AC_MSG_ERROR([boost::mutex cannot be linked in this build environment.
  403. Perhaps you are using an older version of Boost that requires libboost_thread for the mutex support, which does not appear to be available.
  404. You may want to check the availability of the library or to upgrade Boost.])
  405. ])])])
  406. CPPFLAGS="$CPPFLAGS_SAVES"
  407. LIBS="$LIBS_SAVES"
  408. AM_CONDITIONAL(NEED_LIBBOOST_THREAD, test $need_libboost_thread = 1)
  409. if test $need_sunpro_workaround = 1; then
  410. AC_DEFINE([NEED_SUNPRO_WORKAROUND], [], [Need boost sunstudio workaround])
  411. fi
  412. else
  413. AM_CONDITIONAL(NEED_LIBBOOST_THREAD, test "${use_boost_threads}" = "yes")
  414. fi
  415. #
  416. # Check availability of gtest, which will be used for unit tests.
  417. #
  418. if test "$gtest_path" != "no"
  419. then
  420. if test "$gtest_path" != "yes"; then
  421. GTEST_PATHS=$gtest_path
  422. if test -x "${gtest_path}/bin/gtest-config" ; then
  423. GTEST_CONFIG="${gtest_path}/bin/gtest-config"
  424. fi
  425. else
  426. AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
  427. fi
  428. if test -x "${GTEST_CONFIG}" ; then :
  429. # using cppflags instead of cxxflags
  430. GTEST_INCLUDES=`${GTEST_CONFIG} --cppflags`
  431. GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
  432. GTEST_LDADD=`${GTEST_CONFIG} --libs`
  433. GTEST_FOUND="true"
  434. else
  435. AC_MSG_WARN([Unable to locate Google Test gtest-config.])
  436. if test -z "${GTEST_PATHS}" ; then
  437. GTEST_PATHS="/usr /usr/local"
  438. fi
  439. GTEST_FOUND="false"
  440. fi
  441. if test "${GTEST_FOUND}" != "true"; then
  442. GTEST_FOUND="false"
  443. for dir in $GTEST_PATHS; do
  444. if test -f "$dir/include/gtest/gtest.h"; then
  445. GTEST_INCLUDES="-I$dir/include"
  446. GTEST_LDFLAGS="-L$dir/lib"
  447. GTEST_LDADD="-lgtest"
  448. GTEST_FOUND="true"
  449. break
  450. fi
  451. done
  452. fi
  453. if test "${GTEST_FOUND}" != "true"; then
  454. AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
  455. fi
  456. else
  457. GTEST_INCLUDES=
  458. GTEST_LDFLAGS=
  459. GTEST_LDADD=
  460. fi
  461. AM_CONDITIONAL(HAVE_GTEST, test $gtest_path != "no")
  462. AC_SUBST(GTEST_INCLUDES)
  463. AC_SUBST(GTEST_LDFLAGS)
  464. AC_SUBST(GTEST_LDADD)
  465. dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
  466. AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes, no)
  467. if test "x$HAVE_PKG_CONFIG" = "xno" ; then
  468. AC_MSG_ERROR(Please install pkg-config)
  469. fi
  470. PKG_CHECK_MODULES(SQLITE, sqlite3 >= 3.3.9, enable_features="$enable_features SQLite3")
  471. # I can't get some of the #include <asio.hpp> right without this
  472. # TODO: find the real cause of asio/boost wanting pthreads
  473. # (this currently only occurs for src/lib/cc/session_unittests)
  474. PTHREAD_LDFLAGS=
  475. AC_CHECK_LIB(pthread, pthread_create,[ PTHREAD_LDFLAGS=-lpthread ], [])
  476. AC_SUBST(PTHREAD_LDFLAGS)
  477. AC_SUBST(MULTITHREADING_FLAG)
  478. #
  479. # ASIO: we extensively use it as the C++ event management module.
  480. #
  481. # Use local ASIO headers from ext
  482. #
  483. CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/asio"
  484. #
  485. # Use our 'coroutine' header from ext
  486. CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/coroutine"
  487. #
  488. # Disable threads: Currently we don't use them.
  489. CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_THREADS=1"
  490. #
  491. # kqueue portability: ASIO uses kqueue by default if it's available (it's
  492. # generally available in BSD variants). Unfortunately, some public
  493. # implementation of kqueue forces a conversion from a pointer to an integer,
  494. # which is prohibited in C++ unless reinterpret_cast, C++'s most evil beast
  495. # (and ASIO doesn't use it anyway) is used. This will cause build error for
  496. # some of our C++ files including ASIO header files. The following check
  497. # detects such cases and tells ASIO not to use kqueue if so.
  498. AC_CHECK_FUNC(kqueue, ac_cv_have_kqueue=yes, ac_cv_have_kqueue=no)
  499. if test "X$ac_cv_have_kqueue" = "Xyes"; then
  500. AC_MSG_CHECKING([whether kqueue EV_SET compiles in C++])
  501. AC_TRY_COMPILE([
  502. #include <sys/types.h>
  503. #include <sys/param.h>
  504. #include <sys/event.h>],
  505. [char* udata;
  506. EV_SET(NULL, 0, 0, 0, 0, 0, udata);],
  507. [AC_MSG_RESULT(yes)],
  508. [AC_MSG_RESULT([no, disable kqueue for ASIO])
  509. CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_KQUEUE=1"
  510. ])
  511. fi
  512. # /dev/poll issue: ASIO uses /dev/poll by default if it's available (generally
  513. # the case with Solaris). Unfortunately its /dev/poll specific code would
  514. # trigger the gcc's "missing-field-initializers" warning, which would
  515. # subsequently make the build fail with -Werror. Further, older versions of
  516. # gcc don't provide an option to selectively suppress this warning.
  517. # So, for the moment, we simply disable the use of /dev/poll. Unless we
  518. # implement recursive DNS server with randomized ports, we don't need the
  519. # scalability that /dev/poll can provide, so this decision wouldn't affect
  520. # run time performance. Hopefully we can find a better solution or the ASIO
  521. # code will be updated by the time we really need it.
  522. AC_CHECK_HEADERS(sys/devpoll.h, ac_cv_have_devpoll=yes, ac_cv_have_devpoll=no)
  523. if test "X$ac_cv_have_devpoll" = "Xyes" -a "X$GXX" = "Xyes"; then
  524. CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_DEV_POLL=1"
  525. fi
  526. AC_ARG_ENABLE(man, [AC_HELP_STRING([--enable-man],
  527. [regenerate man pages [default=no]])], enable_man=yes, enable_man=no)
  528. AM_CONDITIONAL(ENABLE_MAN, test x$enable_man != xno)
  529. AC_ARG_ENABLE(install-configurations,
  530. [AC_HELP_STRING([--disable-install-configurations],
  531. [do not install configuration])], install_configurations=$enableval, install_configurations=yes)
  532. AM_CONDITIONAL(INSTALL_CONFIGURATIONS, test x$install_configurations = xyes || test x$install_configurations = xtrue)
  533. AC_CONFIG_FILES([Makefile
  534. doc/Makefile
  535. doc/guide/Makefile
  536. src/Makefile
  537. src/bin/Makefile
  538. src/bin/bind10/Makefile
  539. src/bin/bind10/tests/Makefile
  540. src/bin/cmdctl/Makefile
  541. src/bin/cmdctl/tests/Makefile
  542. src/bin/bindctl/Makefile
  543. src/bin/bindctl/tests/Makefile
  544. src/bin/cfgmgr/Makefile
  545. src/bin/cfgmgr/tests/Makefile
  546. src/bin/host/Makefile
  547. src/bin/loadzone/Makefile
  548. src/bin/loadzone/tests/correct/Makefile
  549. src/bin/loadzone/tests/error/Makefile
  550. src/bin/msgq/Makefile
  551. src/bin/msgq/tests/Makefile
  552. src/bin/auth/Makefile
  553. src/bin/auth/tests/Makefile
  554. src/bin/auth/benchmarks/Makefile
  555. src/bin/resolver/Makefile
  556. src/bin/resolver/tests/Makefile
  557. src/bin/xfrin/Makefile
  558. src/bin/xfrin/tests/Makefile
  559. src/bin/xfrout/Makefile
  560. src/bin/xfrout/tests/Makefile
  561. src/bin/zonemgr/Makefile
  562. src/bin/zonemgr/tests/Makefile
  563. src/bin/stats/Makefile
  564. src/bin/stats/tests/Makefile
  565. src/bin/stats/tests/isc/Makefile
  566. src/bin/stats/tests/isc/cc/Makefile
  567. src/bin/stats/tests/isc/config/Makefile
  568. src/bin/stats/tests/isc/util/Makefile
  569. src/bin/stats/tests/testdata/Makefile
  570. src/bin/usermgr/Makefile
  571. src/bin/tests/Makefile
  572. src/lib/Makefile
  573. src/lib/asiolink/Makefile
  574. src/lib/asiolink/tests/Makefile
  575. src/lib/bench/Makefile
  576. src/lib/bench/example/Makefile
  577. src/lib/bench/tests/Makefile
  578. src/lib/cc/Makefile
  579. src/lib/cc/tests/Makefile
  580. src/lib/python/Makefile
  581. src/lib/python/isc/Makefile
  582. src/lib/python/isc/util/Makefile
  583. src/lib/python/isc/util/tests/Makefile
  584. src/lib/python/isc/datasrc/Makefile
  585. src/lib/python/isc/datasrc/tests/Makefile
  586. src/lib/python/isc/cc/Makefile
  587. src/lib/python/isc/cc/tests/Makefile
  588. src/lib/python/isc/config/Makefile
  589. src/lib/python/isc/config/tests/Makefile
  590. src/lib/python/isc/log/Makefile
  591. src/lib/python/isc/log/tests/Makefile
  592. src/lib/python/isc/net/Makefile
  593. src/lib/python/isc/net/tests/Makefile
  594. src/lib/python/isc/notify/Makefile
  595. src/lib/python/isc/notify/tests/Makefile
  596. src/lib/config/Makefile
  597. src/lib/config/tests/Makefile
  598. src/lib/config/tests/testdata/Makefile
  599. src/lib/dns/Makefile
  600. src/lib/dns/tests/Makefile
  601. src/lib/dns/tests/testdata/Makefile
  602. src/lib/dns/python/Makefile
  603. src/lib/dns/python/tests/Makefile
  604. src/lib/exceptions/Makefile
  605. src/lib/exceptions/tests/Makefile
  606. src/lib/datasrc/Makefile
  607. src/lib/datasrc/tests/Makefile
  608. src/lib/xfr/Makefile
  609. src/lib/log/Makefile
  610. src/lib/log/compiler/Makefile
  611. src/lib/log/tests/Makefile
  612. src/lib/resolve/Makefile
  613. src/lib/resolve/tests/Makefile
  614. src/lib/testutils/Makefile
  615. src/lib/testutils/testdata/Makefile
  616. src/lib/nsas/Makefile
  617. src/lib/nsas/tests/Makefile
  618. src/lib/cache/Makefile
  619. src/lib/cache/tests/Makefile
  620. ])
  621. AC_OUTPUT([doc/version.ent
  622. src/bin/cfgmgr/b10-cfgmgr.py
  623. src/bin/cfgmgr/tests/b10-cfgmgr_test.py
  624. src/bin/cmdctl/cmdctl.py
  625. src/bin/cmdctl/run_b10-cmdctl.sh
  626. src/bin/cmdctl/tests/cmdctl_test
  627. src/bin/cmdctl/cmdctl.spec.pre
  628. src/bin/xfrin/tests/xfrin_test
  629. src/bin/xfrin/xfrin.py
  630. src/bin/xfrin/run_b10-xfrin.sh
  631. src/bin/xfrout/xfrout.py
  632. src/bin/xfrout/xfrout.spec.pre
  633. src/bin/xfrout/tests/xfrout_test
  634. src/bin/xfrout/run_b10-xfrout.sh
  635. src/bin/resolver/resolver.spec.pre
  636. src/bin/resolver/spec_config.h.pre
  637. src/bin/zonemgr/zonemgr.py
  638. src/bin/zonemgr/zonemgr.spec.pre
  639. src/bin/zonemgr/tests/zonemgr_test
  640. src/bin/zonemgr/run_b10-zonemgr.sh
  641. src/bin/stats/stats.py
  642. src/bin/stats/stats_stub.py
  643. src/bin/stats/stats.spec.pre
  644. src/bin/stats/run_b10-stats.sh
  645. src/bin/stats/run_b10-stats_stub.sh
  646. src/bin/stats/tests/stats_test
  647. src/bin/bind10/bind10.py
  648. src/bin/bind10/tests/bind10_test
  649. src/bin/bind10/run_bind10.sh
  650. src/bin/bindctl/run_bindctl.sh
  651. src/bin/bindctl/bindctl-source.py
  652. src/bin/bindctl/tests/bindctl_test
  653. src/bin/loadzone/run_loadzone.sh
  654. src/bin/loadzone/tests/correct/correct_test.sh
  655. src/bin/loadzone/tests/error/error_test.sh
  656. src/bin/loadzone/b10-loadzone.py
  657. src/bin/usermgr/run_b10-cmdctl-usermgr.sh
  658. src/bin/usermgr/b10-cmdctl-usermgr.py
  659. src/bin/msgq/msgq.py
  660. src/bin/msgq/tests/msgq_test
  661. src/bin/msgq/run_msgq.sh
  662. src/bin/auth/auth.spec.pre
  663. src/bin/auth/spec_config.h.pre
  664. src/bin/tests/process_rename_test.py
  665. src/lib/config/tests/data_def_unittests_config.h
  666. src/lib/python/isc/config/tests/config_test
  667. src/lib/python/isc/cc/tests/cc_test
  668. src/lib/python/isc/log/tests/log_test
  669. src/lib/python/isc/notify/tests/notify_out_test
  670. src/lib/dns/gen-rdatacode.py
  671. src/lib/python/bind10_config.py
  672. src/lib/dns/tests/testdata/gen-wiredata.py
  673. src/lib/cc/session_config.h.pre
  674. src/lib/cc/tests/session_unittests_config.h
  675. src/lib/log/tests/run_time_init_test.sh
  676. ], [
  677. chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
  678. chmod +x src/bin/xfrin/run_b10-xfrin.sh
  679. chmod +x src/bin/xfrout/run_b10-xfrout.sh
  680. chmod +x src/bin/zonemgr/run_b10-zonemgr.sh
  681. chmod +x src/bin/stats/tests/stats_test
  682. chmod +x src/bin/stats/run_b10-stats.sh
  683. chmod +x src/bin/stats/run_b10-stats_stub.sh
  684. chmod +x src/bin/bind10/run_bind10.sh
  685. chmod +x src/bin/cmdctl/tests/cmdctl_test
  686. chmod +x src/bin/xfrin/tests/xfrin_test
  687. chmod +x src/bin/xfrout/tests/xfrout_test
  688. chmod +x src/bin/zonemgr/tests/zonemgr_test
  689. chmod +x src/bin/bindctl/tests/bindctl_test
  690. chmod +x src/bin/bindctl/run_bindctl.sh
  691. chmod +x src/bin/loadzone/run_loadzone.sh
  692. chmod +x src/bin/loadzone/tests/correct/correct_test.sh
  693. chmod +x src/bin/loadzone/tests/error/error_test.sh
  694. chmod +x src/bin/usermgr/run_b10-cmdctl-usermgr.sh
  695. chmod +x src/bin/msgq/run_msgq.sh
  696. chmod +x src/bin/msgq/tests/msgq_test
  697. chmod +x src/lib/dns/gen-rdatacode.py
  698. chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
  699. chmod +x src/lib/log/tests/run_time_init_test.sh
  700. ])
  701. AC_OUTPUT
  702. dnl Print the results
  703. dnl
  704. cat > config.report << END
  705. BIND 10 source configure results:
  706. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  707. Package:
  708. Name: $PACKAGE_NAME
  709. Version: $PACKAGE_VERSION
  710. C++ Compiler: $CXX
  711. Flags:
  712. DEFS: $DEFS
  713. CPPFLAGS: $CPPFLAGS
  714. CXXFLAGS: $CXXFLAGS
  715. B10_CXXFLAGS: $B10_CXXFLAGS
  716. dnl includes too
  717. Python: ${PYTHON_INCLUDES}
  718. ${PYTHON_LDFLAGS}
  719. ${PYTHON_LIB}
  720. Boost: ${BOOST_INCLUDES}
  721. SQLite: $SQLITE_CFLAGS
  722. $SQLITE_LIBS
  723. Features:
  724. $enable_features
  725. Developer:
  726. Google Tests: $gtest_path
  727. C++ Code Coverage: $USE_LCOV
  728. Python Code Coverage: $USE_PYCOVERAGE
  729. Generate Manuals: $enable_man
  730. END
  731. cat config.report
  732. cat <<EOF
  733. Now you can type "make" to build BIND 10
  734. EOF