configure.ac 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.59])
  4. AC_INIT(bind10-devel, 20100602, 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_CC
  11. AC_PROG_LIBTOOL
  12. # Use C++ language
  13. AC_LANG_CPLUSPLUS
  14. m4_define([_AM_PYTHON_INTERPRETER_LIST], [python python3 python3.1])
  15. AC_ARG_WITH([pythonpath],
  16. AC_HELP_STRING([--with-pythonpath=PATH],
  17. [specify an absolute path to python executable when automatic version check (incorrectly) fails]),
  18. [python_path="$withval"], [python_path="auto"])
  19. if test "$python_path" = auto; then
  20. AM_PATH_PYTHON([3.1])
  21. else
  22. # Older versions of automake can't handle python3 well. This is an
  23. # in-house workaround for them.
  24. PYTHON=$python_path
  25. AC_SUBST(PYTHON)
  26. PYTHON_PREFIX='${prefix}'
  27. AC_SUBST(PYTHON_PREFIX)
  28. PYTHON_EXEC_PREFIX='$(exec_prefix)'
  29. AC_SUBST(PYTHON_EXEC_PREFIX)
  30. PYTHON_VERSION=[`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"`]
  31. if test `echo "$PYTHON_VERSION >= 3.1" | bc` != 1 ; then
  32. AC_MSG_ERROR(["Python version too old: $PYTHON_VERSION, need 3.1 or higher"])
  33. fi
  34. AC_SUBST(PYTHON_VERSION)
  35. PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
  36. AC_SUBST(PYTHON_PLATFORM)
  37. pythondir='${prefix}/lib/python'$PYTHON_VERSION'/site-packages'
  38. AC_SUBST(pythondir)
  39. pkgpythondir='${pythondir}/'$PACKAGE
  40. AC_SUBST(pkgpythondir)
  41. pyexecdir='${exec_prefix}/lib/python'$PYTHON_VERSION'/site-packages'
  42. AC_SUBST(pyexecdir)
  43. pkgpyexecdir='${pyexecdir}/'$PACKAGE
  44. AC_SUBST(pkgpyexecdir)
  45. fi
  46. # Check for python development environments
  47. if test -x ${PYTHON}-config; then
  48. PYTHON_INCLUDES=`${PYTHON}-config --includes`
  49. for flag in `${PYTHON}-config --ldflags`; do
  50. # add any '-L..." flags to PYTHON_LDFLAGS
  51. flag=`echo $flag | sed -ne 's/^\(\-L.*\)$/\1/p'`
  52. if test "X${flag}" != X; then
  53. PYTHON_LDFLAGS="$PYTHON_LDFLAGS ${flag}"
  54. fi
  55. done
  56. # on some platforms, ${PYTHON}-config --ldflags doesn't provide a -L
  57. # option while having the library under a non trivial directory.
  58. # as a workaround we try the "lib" sub directory under the common
  59. # prefix for this python.
  60. if test -z "${PYTHON_LDFLAGS}"; then
  61. PYTHON_LDFLAGS="-L`${PYTHON}-config --prefix`/lib"
  62. fi
  63. else
  64. if test "X$PYTHON_INCLUDES" = X -o "X$PYTHON_LDFLAGS" = X; then
  65. 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.])
  66. fi
  67. fi
  68. AC_SUBST(PYTHON_INCLUDES)
  69. AC_SUBST(PYTHON_LDFLAGS)
  70. CPPFLAGS_SAVED="$CPPFLAGS"
  71. CPPFLAGS="$CPPFLAGS ${PYTHON_INCLUDES}"
  72. AC_CHECK_HEADERS([Python.h],, AC_MSG_ERROR([Missing Python.h]))
  73. CPPFLAGS="$CPPFLAGS_SAVED"
  74. # Check for python library (not absolutely mandatory, but needed for
  75. # Boost.Python when we use it. See below.)
  76. LDFLAGS_SAVED="$LDFLAGS"
  77. LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
  78. python_bin="python${PYTHON_VERSION}"
  79. AC_CHECK_LIB($python_bin, main, python_lib=$python_bin, python_lib=no)
  80. if test $python_lib != "no"; then
  81. PYTHON_LIB="-l$python_lib"
  82. fi
  83. AC_SUBST(PYTHON_LIB)
  84. # TODO: check for _sqlite3.py module
  85. #
  86. # B10_CXXFLAGS is the default C++ compiler flags. This will (and should) be
  87. # used as the default value for each specifc AM_CXXFLAGS:
  88. # AM_CXXFLAGS = $(B10_CXXFLAGS)
  89. # AM_CXXFLAGS += ... # add module specific flags
  90. # We need this so that we can disable some specific compiler warnings per
  91. # module basis; since AM_CXXFLAGS are placed before CXXFLAGS, and since
  92. # gcc's -Wno-XXX option must be specified after -Wall or -Wextra, we cannot
  93. # specify the default warning flags in CXXFLAGS and let specific modules
  94. # "override" the default.
  95. #
  96. B10_CXXFLAGS=
  97. if test "X$GCC" = "Xyes"; then
  98. B10_CXXFLAGS="-g -Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
  99. UNUSED_PARAM_ATTRIBUTE='__attribute__((unused))'
  100. # Certain versions of gcc (g++) have a bug that incorrectly warns about
  101. # the use of anonymous name spaces even if they're closed in a single
  102. # translation unit. For these versions we have to disable -Werror.
  103. werror_ok=0
  104. CXXFLAGS_SAVED="$CXXFLAGS"
  105. CXXFLAGS="$CXXFLAGS $B10_CXXFLAGS -Werror"
  106. AC_MSG_CHECKING(for in-TU anonymous namespace breakage)
  107. AC_TRY_COMPILE([namespace { class Foo {}; }
  108. namespace isc {class Bar {Foo foo_;};} ],,
  109. [AC_MSG_RESULT(no)
  110. werror_ok=1
  111. B10_CXXFLAGS="$B10_CXXFLAGS -Werror"],
  112. [AC_MSG_RESULT(yes)])
  113. CXXFLAGS="$CXXFLAGS_SAVED"
  114. fi dnl GCC = yes
  115. AM_CONDITIONAL(GCC_WERROR_OK, test $werror_ok = 1)
  116. AC_DEFINE_UNQUOTED(UNUSED_PARAM, $UNUSED_PARAM_ATTRIBUTE, Define to compiler keyword indicating a function argument is intentionally unused)
  117. # produce PIC unless we disable shared libraries. need this for python bindings.
  118. if test $enable_shared != "no" -a "X$GCC" = "Xyes"; then
  119. B10_CXXFLAGS="$B10_CXXFLAGS -fPIC"
  120. fi
  121. AC_SUBST(B10_CXXFLAGS)
  122. # Checks for libraries.
  123. AC_SEARCH_LIBS(inet_pton, [nsl])
  124. AC_SEARCH_LIBS(recvfrom, [socket])
  125. # Checks for header files.
  126. # Checks for typedefs, structures, and compiler characteristics.
  127. AC_HEADER_STDBOOL
  128. AC_TYPE_SIZE_T
  129. AC_MSG_CHECKING(for sa_len in struct sockaddr)
  130. AC_TRY_COMPILE([
  131. #include <sys/types.h>
  132. #include <sys/socket.h>],
  133. [struct sockaddr sa; sa.sa_len = 0; return (0);],
  134. [AC_MSG_RESULT(yes)
  135. AC_DEFINE(HAVE_SA_LEN, 1, [Define to 1 if sockaddr has a sa_len member, and corresponding sin_len and sun_len])],
  136. AC_MSG_RESULT(no))
  137. AC_ARG_WITH(lcov,
  138. [ --with-lcov[=PROGRAM] enable gtest and coverage target using the specified lcov], lcov="$withval", lcov="no")
  139. AC_ARG_WITH(gtest,
  140. [ --with-gtest=PATH specify a path to gtest header files (PATH/include) and library (PATH/lib)],
  141. gtest_path="$withval", gtest_path="no")
  142. USE_LCOV="no"
  143. if test "$lcov" != "no"; then
  144. # force gtest if not set
  145. if test "$gtest_path" = "no"; then
  146. # AC_MSG_ERROR("lcov needs gtest for test coverage report")
  147. AC_MSG_NOTICE([gtest support is now enabled, because used by coverage tests])
  148. gtest_path="yes"
  149. fi
  150. if test "$lcov" != "yes"; then
  151. LCOV=$lcov
  152. else
  153. AC_PATH_PROG([LCOV], [lcov])
  154. fi
  155. if test -x "${LCOV}"; then
  156. USE_LCOV="yes"
  157. else
  158. AC_MSG_ERROR([Cannot find lcov.])
  159. fi
  160. # is genhtml always in the same directory?
  161. GENHTML=`echo "$LCOV" | sed s/lcov$/genhtml/`
  162. if test ! -x $GENHTML; then
  163. AC_MSG_ERROR([genhtml not found, needed for lcov])
  164. fi
  165. # GCC specific?
  166. CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
  167. LIBS=" $LIBS -lgcov"
  168. AC_SUBST(CPPFLAGS)
  169. AC_SUBST(LIBS)
  170. AC_SUBST(LCOV)
  171. AC_SUBST(GENHTML)
  172. fi
  173. AC_SUBST(USE_LCOV)
  174. AC_ARG_WITH([boost-include],
  175. AC_HELP_STRING([--with-boost-include=PATH],
  176. [specify exact directory for Boost headers]),
  177. [boost_include_path="$withval"])
  178. if test "${boost_include_path}" ; then
  179. BOOST_INCLUDES="-I${boost_include_path}"
  180. CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES"
  181. fi
  182. AC_SUBST(BOOST_INCLUDES)
  183. AC_ARG_WITH([boost-lib],
  184. AC_HELP_STRING([--with-boost-lib=PATH],
  185. [specify exact directory for Boost libraries]),
  186. [if test "$withval" != "yes" -a "$withval" != "no"; then
  187. BOOST_LDFLAGS="-L$withval"
  188. fi])
  189. AC_SUBST(BOOST_LDFLAGS)
  190. # Check availability of the Boost Python library
  191. #
  192. # Check availability of gtest, which will be used for unit tests.
  193. #
  194. if test "$gtest_path" != "no"
  195. then
  196. if test "$gtest_path" != "yes"; then
  197. GTEST_PATHS=$gtest_path
  198. if test -x "${gtest_path}/bin/gtest-config" ; then
  199. GTEST_CONFIG="${gtest_path}/bin/gtest-config"
  200. fi
  201. else
  202. AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
  203. fi
  204. if test -x "${GTEST_CONFIG}" ; then :
  205. # using cppflags instead of cxxflags
  206. GTEST_INCLUDES=`${GTEST_CONFIG} --cppflags`
  207. GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
  208. GTEST_LDADD=`${GTEST_CONFIG} --libs`
  209. GTEST_FOUND="true"
  210. else
  211. AC_MSG_WARN([Unable to locate Google Test gtest-config.])
  212. if test -z "${GTEST_PATHS}" ; then
  213. GTEST_PATHS="/usr /usr/local"
  214. fi
  215. GTEST_FOUND="false"
  216. fi
  217. if test "${GTEST_FOUND}" != "true"; then
  218. GTEST_FOUND="false"
  219. for dir in $GTEST_PATHS; do
  220. if test -f "$dir/include/gtest/gtest.h"; then
  221. GTEST_INCLUDES="-I$dir/include"
  222. GTEST_LDFLAGS="-L$dir/lib"
  223. GTEST_LDADD="-lgtest"
  224. GTEST_FOUND="true"
  225. break
  226. fi
  227. done
  228. fi
  229. if test "${GTEST_FOUND}" != "true"; then
  230. AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
  231. fi
  232. else
  233. GTEST_INCLUDES=
  234. GTEST_LDFLAGS=
  235. GTEST_LDADD=
  236. fi
  237. AM_CONDITIONAL(HAVE_GTEST, test $gtest_path != "no")
  238. AC_SUBST(GTEST_INCLUDES)
  239. AC_SUBST(GTEST_LDFLAGS)
  240. AC_SUBST(GTEST_LDADD)
  241. PKG_CHECK_MODULES(SQLITE, sqlite3 >= 3.3.9, enable_features="$enable_features SQLite3")
  242. # I can't get some of the #include <asio.hpp> right without this
  243. # TODO: find the real cause of asio/boost wanting pthreads
  244. # (this currently only occurs for src/lib/cc/session_unittests)
  245. PTHREAD_LDFLAGS=
  246. AC_CHECK_LIB(pthread, pthread_create,[ PTHREAD_LDFLAGS=-lpthread ], [])
  247. AC_SUBST(PTHREAD_LDFLAGS)
  248. #
  249. # ASIO: we extensively use it as the C++ event management module.
  250. #
  251. # Use local ASIO headers from ext
  252. #
  253. CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/asio"
  254. #
  255. # kqueue portability: ASIO uses kqueue by default if it's available (it's
  256. # generally available in BSD variants). Unfortunately, some public
  257. # implementation of kqueue forces a conversion from a pointer to an integer,
  258. # which is prohibited in C++ unless reinterpret_cast, C++'s most evil beast
  259. # (and ASIO doesn't use it anyway) is used. This will cause build error for
  260. # some of our C++ files including ASIO header files. The following check
  261. # detects such cases and tells ASIO not to use kqueue if so.
  262. AC_CHECK_FUNC(kqueue, ac_cv_have_kqueue=yes, ac_cv_have_kqueue=no)
  263. if test "X$ac_cv_have_kqueue" = "Xyes"; then
  264. AC_MSG_CHECKING([whether kqueue EV_SET compiles in C++])
  265. AC_TRY_COMPILE([
  266. #include <sys/types.h>
  267. #include <sys/param.h>
  268. #include <sys/event.h>],
  269. [char* udata;
  270. EV_SET(NULL, 0, 0, 0, 0, 0, udata);],
  271. [AC_MSG_RESULT(yes)],
  272. [AC_MSG_RESULT([no, disable kqueue for ASIO])
  273. CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_KQUEUE=1"
  274. ])
  275. fi
  276. # /dev/poll issue: ASIO uses /dev/poll by default if it's available (generally
  277. # the case with Solaris). Unfortunately its /dev/poll specific code would
  278. # trigger the gcc's "missing-field-initializers" warning, which would
  279. # subsequently make the build fail with -Werror. Further, older versions of
  280. # gcc don't provide an option to selectively suppress this warning.
  281. # So, for the moment, we simply disable the use of /dev/poll. Unless we
  282. # implement recursive DNS server with randomized ports, we don't need the
  283. # scalability that /dev/poll can provide, so this decision wouldn't affect
  284. # run time performance. Hpefully we can find a better solution or the ASIO
  285. # code will be updated by the time we really need it.
  286. AC_CHECK_HEADERS(sys/devpoll.h, ac_cv_have_devpoll=yes, ac_cv_have_devpoll=no)
  287. if test "X$ac_cv_have_devpoll" = "Xyes" -a "X$GCC" = "Xyes"; then
  288. CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_DEV_POLL=1"
  289. fi
  290. # Check for headers from required devel kits.
  291. AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/foreach.hpp],,
  292. AC_MSG_ERROR([Missing required header files.]))
  293. AC_ARG_ENABLE(man, [AC_HELP_STRING([--enable-man],
  294. [regenerate man pages [default=no]])] ,enable_man=yes, enable_man=no)
  295. AM_CONDITIONAL(ENABLE_MAN, test x$enable_man != xno)
  296. AC_ARG_ENABLE(install-configurations,
  297. [AC_HELP_STRING([--disable-install-configurations],
  298. [do not install configuration])], install_configurations=$enableval, install_configurations=yes)
  299. AM_CONDITIONAL(INSTALL_CONFIGURATIONS, test x$install_configurations = xyes || test x$install_configurations = xtrue)
  300. AC_CONFIG_FILES([Makefile
  301. src/Makefile
  302. src/bin/Makefile
  303. src/bin/bind10/Makefile
  304. src/bin/bind10/tests/Makefile
  305. src/bin/cmdctl/Makefile
  306. src/bin/cmdctl/tests/Makefile
  307. src/bin/bindctl/Makefile
  308. src/bin/bindctl/tests/Makefile
  309. src/bin/cfgmgr/Makefile
  310. src/bin/host/Makefile
  311. src/bin/loadzone/Makefile
  312. src/bin/msgq/Makefile
  313. src/bin/msgq/tests/Makefile
  314. src/bin/auth/Makefile
  315. src/bin/auth/tests/Makefile
  316. src/bin/xfrin/Makefile
  317. src/bin/xfrin/tests/Makefile
  318. src/bin/xfrout/Makefile
  319. src/bin/xfrout/tests/Makefile
  320. src/bin/usermgr/Makefile
  321. src/lib/Makefile
  322. src/lib/cc/Makefile
  323. src/lib/python/Makefile
  324. src/lib/python/isc/Makefile
  325. src/lib/python/isc/datasrc/Makefile
  326. src/lib/python/isc/cc/Makefile
  327. src/lib/python/isc/cc/tests/Makefile
  328. src/lib/python/isc/config/Makefile
  329. src/lib/python/isc/config/tests/Makefile
  330. src/lib/config/Makefile
  331. src/lib/config/tests/Makefile
  332. src/lib/dns/Makefile
  333. src/lib/dns/tests/Makefile
  334. src/lib/dns/python/Makefile
  335. src/lib/dns/python/tests/Makefile
  336. src/lib/exceptions/Makefile
  337. src/lib/datasrc/Makefile
  338. src/lib/datasrc/tests/Makefile
  339. src/lib/xfr/Makefile
  340. ])
  341. AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
  342. src/bin/cmdctl/cmdctl.py
  343. src/bin/cmdctl/run_b10-cmdctl.sh
  344. src/bin/cmdctl/tests/cmdctl_test
  345. src/bin/xfrin/tests/xfrin_test
  346. src/bin/xfrin/xfrin.py
  347. src/bin/xfrin/xfrin.spec.pre
  348. src/bin/xfrin/run_b10-xfrin.sh
  349. src/bin/xfrout/xfrout.py
  350. src/bin/xfrout/xfrout.spec.pre
  351. src/bin/xfrout/tests/xfrout_test
  352. src/bin/xfrout/run_b10-xfrout.sh
  353. src/bin/bind10/bind10.py
  354. src/bin/bind10/tests/bind10_test
  355. src/bin/bind10/run_bind10.sh
  356. src/bin/bindctl/run_bindctl.sh
  357. src/bin/bindctl/bindctl-source.py
  358. src/bin/bindctl/tests/bindctl_test
  359. src/bin/loadzone/run_loadzone.sh
  360. src/bin/loadzone/b10-loadzone.py
  361. src/bin/usermgr/run_b10-cmdctl-usermgr.sh
  362. src/bin/usermgr/b10-cmdctl-usermgr.py
  363. src/bin/msgq/msgq.py
  364. src/bin/msgq/tests/msgq_test
  365. src/bin/msgq/run_msgq.sh
  366. src/bin/auth/auth.spec.pre
  367. src/bin/auth/spec_config.h.pre
  368. src/lib/config/tests/data_def_unittests_config.h
  369. src/lib/python/isc/config/tests/config_test
  370. src/lib/python/isc/cc/tests/cc_test
  371. src/lib/dns/python/tests/libdns_python_test
  372. src/lib/dns/gen-rdatacode.py
  373. src/lib/python/bind10_config.py
  374. src/lib/dns/tests/testdata/gen-wiredata.py
  375. src/lib/cc/session_config.h.pre
  376. ], [
  377. chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
  378. chmod +x src/bin/xfrin/run_b10-xfrin.sh
  379. chmod +x src/bin/xfrout/run_b10-xfrout.sh
  380. chmod +x src/bin/bind10/run_bind10.sh
  381. chmod +x src/bin/cmdctl/tests/cmdctl_test
  382. chmod +x src/bin/xfrin/tests/xfrin_test
  383. chmod +x src/bin/xfrout/tests/xfrout_test
  384. chmod +x src/bin/bindctl/tests/bindctl_test
  385. chmod +x src/bin/bindctl/run_bindctl.sh
  386. chmod +x src/bin/loadzone/run_loadzone.sh
  387. chmod +x src/bin/usermgr/run_b10-cmdctl-usermgr.sh
  388. chmod +x src/bin/msgq/run_msgq.sh
  389. chmod +x src/bin/msgq/tests/msgq_test
  390. chmod +x src/lib/dns/gen-rdatacode.py
  391. chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
  392. chmod +x src/lib/dns/python/tests/libdns_python_test
  393. ])
  394. AC_OUTPUT
  395. dnl Print the results
  396. dnl
  397. cat > config.report << END
  398. BIND 10 source configure results:
  399. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  400. Package:
  401. Name: $PACKAGE_NAME
  402. Version: $PACKAGE_VERSION
  403. Flags:
  404. DEFS: $DEFS
  405. CPPFLAGS: $CPPFLAGS
  406. CFLAGS: $CFLAGS
  407. CXXFLAGS: $CXXFLAGS
  408. B10_CXXFLAGS: $B10_CXXFLAGS
  409. dnl includes too
  410. Boost Python: $BOOST_PYTHON_LIB
  411. SQLite: $SQLITE_CFLAGS
  412. $SQLITE_LIBS
  413. Features:
  414. $enable_features
  415. Developer:
  416. Google Tests: $gtest_path
  417. Code Coverage: $USE_LCOV
  418. Generate Manuals: $enable_man
  419. END
  420. cat config.report
  421. cat <<EOF
  422. Now you can type "make" to build BIND 10
  423. EOF