configure.ac 14 KB

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