configure.ac 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.59])
  4. AC_INIT(bind10-devel, 20100318, 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. # default compiler warning settings
  86. if test "X$GCC" = "Xyes"; then
  87. CXXFLAGS="$CXXFLAGS -g -Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
  88. UNUSED_PARAM_ATTRIBUTE='__attribute__((unused))'
  89. # Certain versions of gcc (g++) have a bug that incorrectly warns about
  90. # the use of anonymous name spaces even if they're closed in a single
  91. # translation unit. For these versions we have to disable -Werror.
  92. werror_ok=0
  93. CXXFLAGS_SAVED="$CXXFLAGS"
  94. CXXFLAGS="$CXXFLAGS -Werror"
  95. AC_MSG_CHECKING(for in-TU anonymous namespace breakage)
  96. AC_TRY_COMPILE([namespace { class Foo {}; }
  97. namespace isc {class Bar {Foo foo_;};} ],,
  98. [AC_MSG_RESULT(no)
  99. werror_ok=1],
  100. [AC_MSG_RESULT(yes)])
  101. CXXFLAGS="$CXXFLAGS_SAVED"
  102. fi
  103. AC_DEFINE_UNQUOTED(UNUSED_PARAM, $UNUSED_PARAM_ATTRIBUTE, Define to compiler keyword indicating a function argument is intentionally unused)
  104. AM_CONDITIONAL(GCC_WERROR_OK, test $werror_ok = 1)
  105. # produce PIC unless we disable shared libraries. need this for python bindings.
  106. if test $enable_shared != "no" -a "X$GCC" = "Xyes"; then
  107. CXXFLAGS="$CXXFLAGS -fPIC"
  108. fi
  109. # Checks for libraries.
  110. AC_SEARCH_LIBS(inet_pton, [nsl])
  111. AC_SEARCH_LIBS(recvfrom, [socket])
  112. # Checks for header files.
  113. # Checks for typedefs, structures, and compiler characteristics.
  114. AC_HEADER_STDBOOL
  115. AC_TYPE_SIZE_T
  116. AC_MSG_CHECKING(for sa_len in struct sockaddr)
  117. AC_TRY_COMPILE([
  118. #include <sys/types.h>
  119. #include <sys/socket.h>],
  120. [struct sockaddr sa; sa.sa_len = 0; return (0);],
  121. [AC_MSG_RESULT(yes)
  122. AC_DEFINE(HAVE_SIN_LEN, 1, Define to 1 if sockaddr_in has a sin_len member)],
  123. AC_MSG_RESULT(no))
  124. AC_ARG_WITH(lcov,
  125. [ --with-lcov[=PROGRAM] enable gtest and coverage target using the specified lcov], lcov="$withval", lcov="no")
  126. AC_ARG_WITH(gtest,
  127. [ --with-gtest=PATH specify a path to gtest header files (PATH/include) and library (PATH/lib)],
  128. gtest_path="$withval", gtest_path="no")
  129. USE_LCOV="no"
  130. if test "$lcov" != "no"; then
  131. # force gtest if not set
  132. if test "$gtest_path" = "no"; then
  133. # AC_MSG_ERROR("lcov needs gtest for test coverage report")
  134. AC_MSG_NOTICE([gtest support is now enabled, because used by coverage tests])
  135. gtest_path="yes"
  136. fi
  137. if test "$lcov" != "yes"; then
  138. LCOV=$lcov
  139. else
  140. AC_PATH_PROG([LCOV], [lcov])
  141. fi
  142. if test -x "${LCOV}"; then
  143. USE_LCOV="yes"
  144. else
  145. AC_MSG_ERROR([Cannot find lcov.])
  146. fi
  147. # is genhtml always in the same directory?
  148. GENHTML=`echo "$LCOV" | sed s/lcov$/genhtml/`
  149. if test ! -x $GENHTML; then
  150. AC_MSG_ERROR([genhtml not found, needed for lcov])
  151. fi
  152. # GCC specific?
  153. CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
  154. LIBS=" $LIBS -lgcov"
  155. AC_SUBST(CPPFLAGS)
  156. AC_SUBST(LIBS)
  157. AC_SUBST(LCOV)
  158. AC_SUBST(GENHTML)
  159. fi
  160. AC_SUBST(USE_LCOV)
  161. AC_ARG_WITH([boost-include],
  162. AC_HELP_STRING([--with-boost-include=PATH],
  163. [specify exact directory for Boost headers]),
  164. [boost_include_path="$withval"])
  165. if test "${boost_include_path}" ; then
  166. BOOST_INCLUDES="-I${boost_include_path}"
  167. CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES"
  168. fi
  169. AC_SUBST(BOOST_INCLUDES)
  170. AC_ARG_WITH([boost-lib],
  171. AC_HELP_STRING([--with-boost-lib=PATH],
  172. [specify exact directory for Boost libraries]),
  173. [if test "$withval" != "yes" -a "$withval" != "no"; then
  174. BOOST_LDFLAGS="-L$withval"
  175. fi])
  176. AC_SUBST(BOOST_LDFLAGS)
  177. # Check availability of the Boost System library
  178. AC_MSG_CHECKING([for boost::system library])
  179. AC_ARG_WITH([boost-system],
  180. AC_HELP_STRING([--with-boost-system],
  181. [specify whether to use the boost system library]),
  182. [with_boost_system="$withval"], [with_boost_system="auto"])
  183. if test "$with_boost_system" != "no"; then
  184. LDFLAGS_SAVED="$LDFLAGS"
  185. LIBS_SAVED="$LIBS"
  186. CPPFLAGS_SAVED="$CPPFLAGS"
  187. CPPFLAGS="$CPPFLAGS -Iext"
  188. for BOOST_TRY_LIB in boost_system boost_system-mt; do
  189. LDFLAGS="$LDFLAGS_SAVED ${BOOST_LDFLAGS}"
  190. LIBS="$LIBS_SAVED -l${BOOST_TRY_LIB}"
  191. AC_TRY_LINK([#include <boost/system/error_code.hpp>],
  192. [ boost::system::error_code error_code;
  193. std::string message(error_code.message());
  194. return 0; ],
  195. [ AC_MSG_RESULT(yes)
  196. BOOST_SYSTEM_LIB="-l${BOOST_TRY_LIB}"
  197. ],[])
  198. if test "X${BOOST_SYSTEM_LIB}" != X; then
  199. break
  200. fi
  201. done
  202. LDFLAGS="$LDFLAGS_SAVED"
  203. CPPFLAGS="$CPPFLAGS_SAVED"
  204. LIBS="$LIBS_SAVED"
  205. fi
  206. if test "X${BOOST_SYSTEM_LIB}" = X; then
  207. AC_MSG_RESULT(no)
  208. if test "$with_boost_system" = "yes"; then
  209. AC_MSG_ERROR([boost system library is requested but not found])
  210. fi
  211. else
  212. AC_DEFINE(HAVE_BOOST_SYSTEM, 1, Define to 1 if boost system library is available)
  213. fi
  214. AM_CONDITIONAL(HAVE_BOOST_SYSTEM, test "X${BOOST_SYSTEM_LIB}" != X)
  215. AC_SUBST(BOOST_SYSTEM_LIB)
  216. # Check availability of the Boost Python library
  217. AC_MSG_CHECKING([for boost::python library])
  218. AC_ARG_WITH([boost-python],
  219. AC_HELP_STRING([--with-boost-python],
  220. [specify whether to use the boost python library]),
  221. [with_boost_python="$withval"], [with_boost_python="auto"])
  222. if test "$with_boost_python" != "no"; then
  223. if test "$with_boost_python" != "auto" -a "X$PYTHON_LIB" = X; then
  224. AC_MSG_ERROR([Boost.Python requested but python library is not available])
  225. fi
  226. LDFLAGS_SAVED="$LDFLAGS"
  227. LIBS_SAVED="$LIBS"
  228. CPPFLAGS_SAVED="$CPPFLAGS"
  229. CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
  230. for BOOST_TRY_LIB in boost_python boost_python-mt; do
  231. LDFLAGS="$LDFLAGS_SAVED ${BOOST_LDFLAGS} ${PYTHON_LDFLAGS}"
  232. LIBS="$LIBS_SAVED -l${BOOST_TRY_LIB} ${PYTHON_LIB}"
  233. AC_TRY_LINK([#include <boost/python/module.hpp>
  234. using namespace boost::python;
  235. BOOST_PYTHON_MODULE(test) { throw "Boost::Python test."; }],
  236. [ return 0; ],
  237. [ AC_MSG_RESULT(yes)
  238. BOOST_PYTHON_LIB="-l${BOOST_TRY_LIB}"
  239. ],[])
  240. if test "X${BOOST_PYTHON_LIB}" != X; then
  241. break
  242. fi
  243. done
  244. LDFLAGS="$LDFLAGS_SAVED"
  245. CPPFLAGS="$CPPFLAGS_SAVED"
  246. LIBS="$LIBS_SAVED"
  247. fi
  248. if test "X${BOOST_PYTHON_LIB}" = X; then
  249. AC_MSG_RESULT(no)
  250. if test "$with_boost_python" = "yes"; then
  251. AC_MSG_ERROR([boost python library is requested but not found])
  252. fi
  253. else
  254. AC_DEFINE(HAVE_BOOST_PYTHON, 1, Define to 1 if boost python library is available)
  255. fi
  256. AM_CONDITIONAL(HAVE_BOOST_PYTHON, test "X${BOOST_PYTHON_LIB}" != X)
  257. AC_SUBST(BOOST_PYTHON_LIB)
  258. #
  259. # Check availability of gtest, which will be used for unit tests.
  260. #
  261. if test "$gtest_path" != "no"
  262. then
  263. if test "$gtest_path" != "yes"; then
  264. GTEST_PATHS=$gtest_path
  265. if test -x "${gtest_path}/bin/gtest-config" ; then
  266. GTEST_CONFIG="${gtest_path}/bin/gtest-config"
  267. fi
  268. else
  269. AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
  270. fi
  271. if test -x "${GTEST_CONFIG}" ; then :
  272. # using cppflags instead of cxxflags
  273. GTEST_INCLUDES=`${GTEST_CONFIG} --cppflags`
  274. GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
  275. GTEST_LDADD=`${GTEST_CONFIG} --libs`
  276. GTEST_FOUND="true"
  277. else
  278. AC_MSG_WARN([Unable to locate Google Test gtest-config.])
  279. if test -z "${GTEST_PATHS}" ; then
  280. GTEST_PATHS="/usr /usr/local"
  281. fi
  282. GTEST_FOUND="false"
  283. fi
  284. if test "${GTEST_FOUND}" != "true"; then
  285. GTEST_FOUND="false"
  286. for dir in $GTEST_PATHS; do
  287. if test -f "$dir/include/gtest/gtest.h"; then
  288. GTEST_INCLUDES="-I$dir/include"
  289. GTEST_LDFLAGS="-L$dir/lib"
  290. GTEST_LDADD="-lgtest"
  291. GTEST_FOUND="true"
  292. break
  293. fi
  294. done
  295. fi
  296. if test "${GTEST_FOUND}" != "true"; then
  297. AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
  298. fi
  299. else
  300. GTEST_INCLUDES=
  301. GTEST_LDFLAGS=
  302. GTEST_LDADD=
  303. fi
  304. AM_CONDITIONAL(HAVE_GTEST, test $gtest_path != "no")
  305. AC_SUBST(GTEST_INCLUDES)
  306. AC_SUBST(GTEST_LDFLAGS)
  307. AC_SUBST(GTEST_LDADD)
  308. PKG_CHECK_MODULES(SQLITE, sqlite3 >= 3.3.9)
  309. # Check for headers from required devel kits.
  310. # boost/shared_ptr.hpp is in ext in svn but not in tarball.
  311. CPPFLAGS_SAVED=$CPPFLAGS
  312. if test "X$BOOST_INCLUDES" = "X"; then
  313. # abs_top_srcdir not defined yet
  314. # so this is only useful to check. We'll replace it after the check.
  315. CPPFLAGS="$CPPFLAGS -Iext"
  316. fi
  317. AC_CHECK_HEADERS([boost/shared_ptr.hpp boost/foreach.hpp],,
  318. AC_MSG_ERROR([Missing required header files.]))
  319. CPPFLAGS=$CPPFLAGS_SAVED
  320. if test "X$BOOST_INCLUDES" = "X"; then
  321. CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext"
  322. fi
  323. AC_ARG_ENABLE(man, [AC_HELP_STRING([--enable-man],
  324. [regenerate man pages [default=no]])] ,enable_man=yes, enable_man=no)
  325. AM_CONDITIONAL(ENABLE_MAN, test x$enable_man != xno)
  326. AC_ARG_ENABLE(install-configurations,
  327. [AC_HELP_STRING([--disable-install-configurations],
  328. [do not install configuration])], install_configurations=$enableval, install_configurations=yes)
  329. AM_CONDITIONAL(INSTALL_CONFIGURATIONS, test x$install_configurations = xyes || test x$install_configurations = xtrue)
  330. AC_CONFIG_FILES([Makefile
  331. src/Makefile
  332. src/bin/Makefile
  333. src/bin/bind10/Makefile
  334. src/bin/bind10/tests/Makefile
  335. src/bin/cmdctl/Makefile
  336. src/bin/cmdctl/tests/Makefile
  337. src/bin/bindctl/Makefile
  338. src/bin/bindctl/tests/Makefile
  339. src/bin/cfgmgr/Makefile
  340. src/bin/host/Makefile
  341. src/bin/loadzone/Makefile
  342. src/bin/msgq/Makefile
  343. src/bin/msgq/tests/Makefile
  344. src/bin/auth/Makefile
  345. src/bin/auth/tests/Makefile
  346. src/bin/xfrin/Makefile
  347. src/bin/xfrin/tests/Makefile
  348. src/bin/xfrout/Makefile
  349. src/bin/xfrout/tests/Makefile
  350. src/bin/usermgr/Makefile
  351. src/lib/Makefile
  352. src/lib/cc/Makefile
  353. src/lib/python/Makefile
  354. src/lib/python/isc/Makefile
  355. src/lib/python/isc/datasrc/Makefile
  356. src/lib/python/isc/cc/Makefile
  357. src/lib/python/isc/cc/tests/Makefile
  358. src/lib/python/isc/config/Makefile
  359. src/lib/python/isc/config/tests/Makefile
  360. src/lib/config/Makefile
  361. src/lib/config/tests/Makefile
  362. src/lib/dns/Makefile
  363. src/lib/dns/tests/Makefile
  364. src/lib/dns/python/Makefile
  365. src/lib/dns-python/Makefile
  366. src/lib/exceptions/Makefile
  367. src/lib/datasrc/Makefile
  368. src/lib/datasrc/tests/Makefile
  369. src/lib/xfr/Makefile
  370. ])
  371. AC_OUTPUT([src/bin/cfgmgr/b10-cfgmgr.py
  372. src/bin/cmdctl/cmdctl.py
  373. src/bin/cmdctl/run_b10-cmdctl.sh
  374. src/bin/cmdctl/tests/cmdctl_test
  375. src/bin/xfrin/tests/xfrin_test
  376. src/bin/xfrin/xfrin.py
  377. src/bin/xfrin/xfrin.spec.pre
  378. src/bin/xfrin/run_b10-xfrin.sh
  379. src/bin/xfrout/xfrout.py
  380. src/bin/xfrout/xfrout.spec.pre
  381. src/bin/xfrout/tests/xfrout_test
  382. src/bin/xfrout/run_b10-xfrout.sh
  383. src/bin/bind10/bind10.py
  384. src/bin/bind10/tests/bind10_test
  385. src/bin/bind10/run_bind10.sh
  386. src/bin/bindctl/run_bindctl.sh
  387. src/bin/bindctl/bindctl-source.py
  388. src/bin/bindctl/tests/bindctl_test
  389. src/bin/loadzone/run_loadzone.sh
  390. src/bin/loadzone/b10-loadzone.py
  391. src/bin/usermgr/run_b10-cmdctl-usermgr.sh
  392. src/bin/usermgr/b10-cmdctl-usermgr.py
  393. src/bin/msgq/msgq.py
  394. src/bin/msgq/tests/msgq_test
  395. src/bin/msgq/run_msgq.sh
  396. src/bin/auth/auth.spec.pre
  397. src/bin/auth/spec_config.h
  398. src/lib/config/tests/data_def_unittests_config.h
  399. src/lib/python/isc/config/tests/config_test
  400. src/lib/python/isc/cc/tests/cc_test
  401. src/lib/dns/python/tests/libdns_python_test
  402. src/lib/dns/gen-rdatacode.py
  403. src/lib/dns/tests/testdata/gen-wiredata.py
  404. ], [
  405. chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
  406. chmod +x src/bin/xfrin/run_b10-xfrin.sh
  407. chmod +x src/bin/xfrout/run_b10-xfrout.sh
  408. chmod +x src/bin/bind10/run_bind10.sh
  409. chmod +x src/bin/cmdctl/tests/cmdctl_test
  410. chmod +x src/bin/xfrin/tests/xfrin_test
  411. chmod +x src/bin/xfrout/tests/xfrout_test
  412. chmod +x src/bin/bindctl/tests/bindctl_test
  413. chmod +x src/bin/bindctl/run_bindctl.sh
  414. chmod +x src/bin/loadzone/run_loadzone.sh
  415. chmod +x src/bin/usermgr/run_b10-cmdctl-usermgr.sh
  416. chmod +x src/bin/msgq/run_msgq.sh
  417. chmod +x src/bin/msgq/tests/msgq_test
  418. chmod +x src/lib/dns/gen-rdatacode.py
  419. chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
  420. chmod +x src/lib/dns/python/tests/libdns_python_test
  421. ])
  422. AC_OUTPUT