configure.ac 30 KB

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