configure.ac 27 KB

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