configure.ac 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.59])
  4. AC_INIT(bind10-devel, 20120127, bind10-dev@isc.org)
  5. AC_CONFIG_SRCDIR(README)
  6. AM_INIT_AUTOMAKE
  7. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])dnl be backward compatible
  8. AC_CONFIG_HEADERS([config.h])
  9. # Checks for programs.
  10. AC_PROG_CXX
  11. # Libtool configuration
  12. #
  13. # libtool cannot handle spaces in paths, so exit early if there is one
  14. if [ test `echo $PWD | grep -c ' '` != "0" ]; then
  15. AC_MSG_ERROR([BIND 10 cannot be built in a directory that contains spaces, because of libtool limitations. Please change the directory name, or use a symbolic link that does not contain spaces.])
  16. fi
  17. # On FreeBSD (and probably some others), clang++ does not meet an autoconf
  18. # assumption in identifying libtool configuration regarding shared library:
  19. # the configure script will execute "$CC -shared $CFLAGS/$CXXFLAGS -v" and
  20. # expect the output contains -Lxxx or -Ryyy. This is the case for g++, but
  21. # not for clang++, and, as a result, it will cause various errors in linking
  22. # programs or running them with a shared object (such as some of our python
  23. # scripts).
  24. # To work around this problem we define a temporary variable
  25. # "CXX_LIBTOOL_LDFLAGS". It's expected to be defined as, e.g, "-L/usr/lib"
  26. # to temporarily fake the output so that it will be compatible with that of
  27. # g++.
  28. CFLAGS_SAVED=$CFLAGS
  29. CXXFLAGS_SAVED=$CXXFLAGS
  30. CFLAGS="$CFLAGS $CXX_LIBTOOL_LDFLAGS"
  31. CXXFLAGS="$CXXFLAGS $CXX_LIBTOOL_LDFLAGS"
  32. AC_PROG_LIBTOOL
  33. CFLAGS=$CFLAGS_SAVED
  34. CXXFLAGS=$CXXFLAGS_SAVED
  35. # Use C++ language
  36. AC_LANG([C++])
  37. # Identify the compiler: this check must be after AC_PROG_CXX and AC_LANG.
  38. AM_CONDITIONAL(USE_GXX, test "X${GXX}" = "Xyes")
  39. AC_CHECK_DECL([__SUNPRO_CC], [SUNCXX="yes"], [SUNCXX="no"])
  40. AC_CHECK_DECL([__clang__], [CLANGPP="yes"], [CLANGPP="no"])
  41. AM_CONDITIONAL(USE_CLANGPP, test "X${CLANGPP}" = "Xyes")
  42. # Linker options
  43. # check -R and -Wl,-R rather than gcc specific -rpath to be as portable
  44. # as possible.
  45. AC_MSG_CHECKING([whether -R flag is available in linker])
  46. LDFLAGS_SAVED="$LDFLAGS"
  47. LDFLAGS="$LDFLAGS -R/usr/lib"
  48. AC_TRY_LINK([],[],
  49. [ AC_MSG_RESULT(yes)
  50. rpath_flag=-R
  51. ],[ AC_MSG_RESULT(no)
  52. AC_MSG_CHECKING([whether -Wl,-R flag is available in linker])
  53. LDFLAGS="$LDFLAGS_SAVED -Wl,-R"
  54. AC_TRY_LINK([], [],
  55. [ AC_MSG_RESULT(yes)
  56. rpath_flag=-Wl,-R
  57. ],[ AC_MSG_RESULT(no)
  58. rpath_flag=no
  59. ])
  60. ])
  61. LDFLAGS=$LDFLAGS_SAVED
  62. # allow building programs with static link. we need to make it selective
  63. # because loadable modules cannot be statically linked.
  64. AC_ARG_ENABLE([static-link],
  65. AC_HELP_STRING([--enable-static-link],
  66. [build programs with static link [[default=no]]]),
  67. [enable_static_link=yes], [enable_static_link=no])
  68. AM_CONDITIONAL(USE_STATIC_LINK, test $enable_static_link = yes)
  69. # Check validity about some libtool options
  70. if test $enable_static_link = yes -a $enable_static = no; then
  71. AC_MSG_ERROR([--enable-static-link requires --enable-static])
  72. fi
  73. if test $enable_shared = no; then
  74. AC_MSG_ERROR([BIND 10 requires shared libraries to be built])
  75. fi
  76. AC_ARG_ENABLE(boost-threads,
  77. AC_HELP_STRING([--enable-boost-threads],
  78. [use boost threads. Currently this only means using its locks instead of dummy locks, in the cache and NSAS]),
  79. use_boost_threads=$enableval, use_boost_threads=no)
  80. # allow configuring without setproctitle.
  81. AC_ARG_ENABLE(setproctitle-check,
  82. AC_HELP_STRING([--disable-setproctitle-check],
  83. [do not check for python setproctitle module (used to give nice names to python processes)]),
  84. setproctitle_check=$enableval, setproctitle_check=yes)
  85. # OS dependent configuration
  86. SET_ENV_LIBRARY_PATH=no
  87. ENV_LIBRARY_PATH=LD_LIBRARY_PATH
  88. case "$host" in
  89. *-solaris*)
  90. # Solaris requires special definitions to get some standard libraries
  91. # (e.g. getopt(3)) available with common used header files.
  92. CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
  93. # "now" binding is necessary to prevent deadlocks in C++ static initialization code
  94. LDFLAGS="$LDFLAGS -z now"
  95. ;;
  96. *-apple-darwin*)
  97. # Starting with OSX 10.7 (Lion) we must choose which IPv6 API to use
  98. # (RFC2292 or RFC3542).
  99. CPPFLAGS="$CPPFLAGS -D__APPLE_USE_RFC_3542"
  100. # libtool doesn't work perfectly with Darwin: libtool embeds the
  101. # final install path in dynamic libraries and our loadable python
  102. # modules always refer to that path even if it's loaded within the
  103. # source tree. This prevents pre-install tests from working.
  104. # To work around this problem we explicitly specify paths to dynamic
  105. # libraries when we use them in the source tree.
  106. SET_ENV_LIBRARY_PATH=yes
  107. ENV_LIBRARY_PATH=DYLD_LIBRARY_PATH
  108. ;;
  109. *-freebsd*)
  110. SET_ENV_LIBRARY_PATH=yes
  111. ;;
  112. *-netbsd*)
  113. SET_ENV_LIBRARY_PATH=yes
  114. ;;
  115. esac
  116. AM_CONDITIONAL(SET_ENV_LIBRARY_PATH, test $SET_ENV_LIBRARY_PATH = yes)
  117. AC_SUBST(SET_ENV_LIBRARY_PATH)
  118. AC_SUBST(ENV_LIBRARY_PATH)
  119. m4_define([_AM_PYTHON_INTERPRETER_LIST], [python python3 python3.1 python3.2])
  120. AC_ARG_WITH([pythonpath],
  121. AC_HELP_STRING([--with-pythonpath=PATH],
  122. [specify an absolute path to python executable when automatic version check (incorrectly) fails]),
  123. [python_path="$withval"], [python_path="auto"])
  124. if test "$python_path" = auto; then
  125. AM_PATH_PYTHON([3.1])
  126. else
  127. # Older versions of automake can't handle python3 well. This is an
  128. # in-house workaround for them.
  129. PYTHON=$python_path
  130. AC_SUBST(PYTHON)
  131. PYTHON_PREFIX='${prefix}'
  132. AC_SUBST(PYTHON_PREFIX)
  133. PYTHON_EXEC_PREFIX='$(exec_prefix)'
  134. AC_SUBST(PYTHON_EXEC_PREFIX)
  135. PYTHON_VERSION=[`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"`]
  136. if test `echo "$PYTHON_VERSION >= 3.1" | bc` != 1 ; then
  137. AC_MSG_ERROR(["Python version too old: $PYTHON_VERSION, need 3.1 or higher"])
  138. fi
  139. AC_SUBST(PYTHON_VERSION)
  140. PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
  141. AC_SUBST(PYTHON_PLATFORM)
  142. pythondir='${prefix}/lib/python'$PYTHON_VERSION'/site-packages'
  143. AC_SUBST(pythondir)
  144. pkgpythondir='${pythondir}/'$PACKAGE
  145. AC_SUBST(pkgpythondir)
  146. pyexecdir='${exec_prefix}/lib/python'$PYTHON_VERSION'/site-packages'
  147. AC_SUBST(pyexecdir)
  148. pkgpyexecdir='${pyexecdir}/'$PACKAGE
  149. AC_SUBST(pkgpyexecdir)
  150. fi
  151. # We need to store the default pyexecdir in a separate variable so that
  152. # we can specify in Makefile.am the install directory of various BIND 10
  153. # python scripts and loadable modules; in Makefile.am we cannot replace
  154. # $(pyexecdir) using itself, e.g, this doesn't work:
  155. # pyexecdir = $(pyexecdir)/isc/some_module
  156. # The separate variable makes this setup possible as follows:
  157. # pyexecdir = $(PYTHON_SITEPKG_DIR)/isc/some_module
  158. PYTHON_SITEPKG_DIR=${pyexecdir}
  159. AC_SUBST(PYTHON_SITEPKG_DIR)
  160. # This will be commonly used in various Makefile.am's that need to generate
  161. # python log messages.
  162. PYTHON_LOGMSGPKG_DIR="\$(top_builddir)/src/lib/python/isc/log_messages"
  163. AC_SUBST(PYTHON_LOGMSGPKG_DIR)
  164. # This is python package paths commonly used in python tests. See
  165. # README of log_messages for why it's included.
  166. COMMON_PYTHON_PATH="\$(abs_top_builddir)/src/lib/python/isc/log_messages:\$(abs_top_srcdir)/src/lib/python:\$(abs_top_builddir)/src/lib/python"
  167. AC_SUBST(COMMON_PYTHON_PATH)
  168. # Check for python development environments
  169. if test -x ${PYTHON}-config; then
  170. PYTHON_INCLUDES=`${PYTHON}-config --includes`
  171. for flag in `${PYTHON}-config --ldflags`; do
  172. # add any '-L..." flags to PYTHON_LDFLAGS
  173. flag=`echo $flag | sed -ne 's/^\(\-L.*\)$/\1/p'`
  174. if test "X${flag}" != X; then
  175. PYTHON_LDFLAGS="$PYTHON_LDFLAGS ${flag}"
  176. fi
  177. done
  178. # on some platforms, ${PYTHON}-config --ldflags doesn't provide a -L
  179. # option while having the library under a non trivial directory.
  180. # as a workaround we try the "lib" sub directory under the common
  181. # prefix for this python.
  182. if test -z "${PYTHON_LDFLAGS}"; then
  183. PYTHON_LDFLAGS="-L`${PYTHON}-config --prefix`/lib"
  184. fi
  185. else
  186. if test "X$PYTHON_INCLUDES" = X -o "X$PYTHON_LDFLAGS" = X; then
  187. 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.])
  188. fi
  189. fi
  190. # Some OSes including NetBSD don't install libpython.so in a well known path.
  191. # To avoid requiring dynamic library path with our python wrapper loadable
  192. # modules, we embed the path to the modules when possible. We do this even
  193. # when the path is known in the common operational environment (e.g. when
  194. # it's stored in a common "hint" file) for simplicity.
  195. if test $rpath_flag != no; then
  196. python_rpath=
  197. for flag in ${PYTHON_LDFLAGS}; do
  198. python_rpath="${python_rpath} `echo $flag | sed -ne "s/^\(\-L\)/${rpath_flag}/p"`"
  199. done
  200. PYTHON_LDFLAGS="${PYTHON_LDFLAGS} ${python_rpath}"
  201. fi
  202. AC_SUBST(PYTHON_INCLUDES)
  203. AC_SUBST(PYTHON_LDFLAGS)
  204. CPPFLAGS_SAVED="$CPPFLAGS"
  205. CPPFLAGS="$CPPFLAGS ${PYTHON_INCLUDES}"
  206. AC_CHECK_HEADERS([Python.h],, AC_MSG_ERROR([Missing Python.h]))
  207. CPPFLAGS="$CPPFLAGS_SAVED"
  208. # Check for python library. Needed for Python-wrapper libraries.
  209. LDFLAGS_SAVED="$LDFLAGS"
  210. LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
  211. python_bin="python${PYTHON_VERSION}"
  212. AC_CHECK_LIB($python_bin, main, python_lib=$python_bin, python_lib=no)
  213. if test $python_lib != "no"; then
  214. PYTHON_LIB="-l$python_lib"
  215. fi
  216. AC_SUBST(PYTHON_LIB)
  217. LDFLAGS=$LDFLAGS_SAVED
  218. # Check for the setproctitle module
  219. if test "$setproctitle_check" = "yes" ; then
  220. AC_MSG_CHECKING(for setproctitle module)
  221. if "$PYTHON" -c 'import setproctitle' 2>/dev/null ; then
  222. AC_MSG_RESULT(ok)
  223. else
  224. AC_MSG_RESULT(missing)
  225. AC_MSG_WARN([Missing setproctitle python module.
  226. Use --disable-setproctitle-check to skip this check.
  227. In this case we will continue, but naming of python processes will not work.])
  228. fi
  229. fi
  230. # TODO: check for _sqlite3.py module
  231. # Compiler dependent settings: define some mandatory CXXFLAGS here.
  232. # We also use a separate variable B10_CXXFLAGS. This will (and should) be
  233. # used as the default value for each specific AM_CXXFLAGS:
  234. # AM_CXXFLAGS = $(B10_CXXFLAGS)
  235. # AM_CXXFLAGS += ... # add module specific flags
  236. # We need this so that we can disable some specific compiler warnings per
  237. # module basis; since AM_CXXFLAGS are placed before CXXFLAGS, and since
  238. # gcc's -Wno-XXX option must be specified after -Wall or -Wextra, we cannot
  239. # specify the default warning flags in CXXFLAGS and let specific modules
  240. # "override" the default.
  241. # This may be used to try linker flags.
  242. AC_DEFUN([BIND10_CXX_TRY_FLAG], [
  243. AC_MSG_CHECKING([whether $CXX supports $1])
  244. bind10_save_CXXFLAGS="$CXXFLAGS"
  245. CXXFLAGS="$CXXFLAGS $1"
  246. AC_LINK_IFELSE([int main(void){ return 0;}],
  247. [bind10_cxx_flag=yes], [bind10_cxx_flag=no])
  248. CXXFLAGS="$bind10_save_CXXFLAGS"
  249. if test "x$bind10_cxx_flag" = "xyes"; then
  250. ifelse([$2], , :, [$2])
  251. else
  252. ifelse([$3], , :, [$3])
  253. fi
  254. AC_MSG_RESULT([$bind10_cxx_flag])
  255. ])
  256. # SunStudio compiler requires special compiler options for boost
  257. # (http://blogs.sun.com/sga/entry/boost_mini_howto)
  258. if test "$SUNCXX" = "yes"; then
  259. CXXFLAGS="$CXXFLAGS -library=stlport4 -features=tmplife -features=tmplrefstatic"
  260. MULTITHREADING_FLAG="-mt"
  261. fi
  262. BIND10_CXX_TRY_FLAG([-Wno-missing-field-initializers],
  263. [WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG="-Wno-missing-field-initializers"])
  264. AC_SUBST(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG)
  265. # gcc specific settings:
  266. if test "X$GXX" = "Xyes"; then
  267. B10_CXXFLAGS="-Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
  268. case "$host" in
  269. *-solaris*)
  270. MULTITHREADING_FLAG=-pthreads
  271. # In Solaris, IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT need -Wno-missing-braces
  272. B10_CXXFLAGS="$B10_CXXFLAGS -Wno-missing-braces"
  273. ;;
  274. *)
  275. MULTITHREADING_FLAG=-pthread
  276. ;;
  277. esac
  278. # Don't use -Werror if configured not to
  279. AC_ARG_WITH(werror,
  280. AC_HELP_STRING([--with-werror], [Compile using -Werror (default=yes)]),
  281. [
  282. case "${withval}" in
  283. yes) with_werror=1 ;;
  284. no) with_werror=0 ;;
  285. *) AC_MSG_ERROR(bad value ${withval} for --with-werror) ;;
  286. esac],
  287. [with_werror=1])
  288. werror_ok=0
  289. # Certain versions of gcc (g++) have a bug that incorrectly warns about
  290. # the use of anonymous name spaces even if they're closed in a single
  291. # translation unit. For these versions we have to disable -Werror.
  292. if test $with_werror = 1; then
  293. CXXFLAGS_SAVED="$CXXFLAGS"
  294. CXXFLAGS="$CXXFLAGS $B10_CXXFLAGS -Werror"
  295. AC_MSG_CHECKING(for in-TU anonymous namespace breakage)
  296. AC_TRY_COMPILE([namespace { class Foo {}; }
  297. namespace isc {class Bar {Foo foo_;};} ],,
  298. [AC_MSG_RESULT(no)
  299. werror_ok=1
  300. B10_CXXFLAGS="$B10_CXXFLAGS -Werror"],
  301. [AC_MSG_RESULT(yes)])
  302. CXXFLAGS="$CXXFLAGS_SAVED"
  303. fi
  304. # Python 3.2 has an unused parameter in one of its headers. This
  305. # has been reported, but not fixed as of yet, so we check if we need
  306. # to set -Wno-unused-parameter.
  307. if test $werror_ok = 1; then
  308. CPPFLAGS_SAVED="$CPPFLAGS"
  309. CPPFLAGS=${PYTHON_INCLUDES}
  310. CXXFLAGS_SAVED="$CXXFLAGS"
  311. CXXFLAGS="$CXXFLAGS $B10_CXXFLAGS -Werror"
  312. AC_MSG_CHECKING([whether we need -Wno-unused-parameter for python])
  313. AC_TRY_COMPILE(
  314. [#include <Python.h>],
  315. [],
  316. [AC_MSG_RESULT(no)],
  317. [
  318. CXXFLAGS="$CXXFLAGS -Wno-unused-parameter"
  319. AC_TRY_COMPILE([#include <Python.h>],
  320. [],
  321. [AC_MSG_RESULT(yes)
  322. PYTHON_CXXFLAGS="${PYTHON_CXXFLAGS} -Wno-unused-parameter"
  323. AC_SUBST(PYTHON_CXXFLAGS)
  324. ],
  325. [AC_MSG_ERROR([Can't compile against Python.h])]
  326. )
  327. ]
  328. )
  329. CXXFLAGS="$CXXFLAGS_SAVED"
  330. CPPFLAGS="$CPPFLAGS_SAVED"
  331. fi
  332. fi dnl GXX = yes
  333. AM_CONDITIONAL(GCC_WERROR_OK, test $werror_ok = 1)
  334. # produce PIC unless we disable shared libraries. need this for python bindings.
  335. if test $enable_shared != "no" -a "X$GXX" = "Xyes"; then
  336. B10_CXXFLAGS="$B10_CXXFLAGS -fPIC"
  337. fi
  338. AC_SUBST(B10_CXXFLAGS)
  339. # Checks for libraries.
  340. AC_SEARCH_LIBS(inet_pton, [nsl])
  341. AC_SEARCH_LIBS(recvfrom, [socket])
  342. AC_SEARCH_LIBS(nanosleep, [rt])
  343. # Checks for header files.
  344. # Checks for typedefs, structures, and compiler characteristics.
  345. AC_HEADER_STDBOOL
  346. AC_TYPE_SIZE_T
  347. # Detect OS type (it may be used to do OS-specific things, e.g.
  348. # interface detection in DHCP)
  349. AC_MSG_CHECKING(OS family)
  350. system=`uname -s`
  351. case $system in
  352. Linux)
  353. OS_TYPE="Linux"
  354. CPPFLAGS="$CPPFLAGS -DOS_LINUX"
  355. ;;
  356. Darwin | FreeBSD | NetBSD | OpenBSD)
  357. OS_TYPE="BSD"
  358. CPPFLAGS="$CPPFLAGS -DOS_BSD"
  359. ;;
  360. Solaris)
  361. OS_TYPE="Solaris"
  362. CPPFLAGS="$CPPFLAGS -DOS_SOLARIS"
  363. ;;
  364. *)
  365. OS_TYPE="Unknown"
  366. AC_MSG_WARN("Unsupported OS: uname returned $system")
  367. ;;
  368. esac
  369. AC_MSG_RESULT($OS_TYPE)
  370. AM_CONDITIONAL(OS_LINUX, test $OS_TYPE = Linux)
  371. AM_COND_IF([OS_LINUX], [AC_DEFINE([OS_LINUX], [1], [Running on Linux?])])
  372. AM_CONDITIONAL(OS_BSD, test $OS_TYPE = BSD)
  373. AM_COND_IF([OS_BSD], [AC_DEFINE([OS_BSD], [1], [Running on BSD?])])
  374. AM_CONDITIONAL(OS_SOLARIS, test $OS_TYPE = Solaris)
  375. AM_COND_IF([OS_SOLARIS], [AC_DEFINE([OS_SOLARIS], [1], [Running on Solaris?])])
  376. AC_MSG_CHECKING(for sa_len in struct sockaddr)
  377. AC_TRY_COMPILE([
  378. #include <sys/types.h>
  379. #include <sys/socket.h>],
  380. [struct sockaddr sa; sa.sa_len = 0; return (0);],
  381. [AC_MSG_RESULT(yes)
  382. AC_DEFINE(HAVE_SA_LEN, 1, [Define to 1 if sockaddr has a sa_len member, and corresponding sin_len and sun_len])],
  383. AC_MSG_RESULT(no))
  384. AC_ARG_WITH(pycoverage,
  385. [ --with-pycoverage[=PROGRAM] enable python code coverage using the specified coverage], pycoverage="$withval", pycoverage="no")
  386. if test "$pycoverage" = "no" ; then
  387. # just run the tests normally with python
  388. PYCOVERAGE_RUN="${PYTHON}"
  389. USE_PYCOVERAGE="no"
  390. elif test "$pycoverage" = "yes" ; then
  391. PYCOVERAGE="coverage"
  392. PYCOVERAGE_RUN="${PYCOVERAGE} run --branch --append"
  393. USE_PYCOVERAGE="yes"
  394. else
  395. PYCOVERAGE="$pycoverage"
  396. PYCOVERAGE_RUN="${PYCOVERAGE} run --branch --append"
  397. USE_PYCOVERAGE="yes"
  398. fi
  399. AM_CONDITIONAL(ENABLE_PYTHON_COVERAGE, test x$USE_PYCOVERAGE != xno)
  400. AC_SUBST(PYCOVERAGE)
  401. AC_SUBST(PYCOVERAGE_RUN)
  402. AC_SUBST(USE_PYCOVERAGE)
  403. AC_ARG_WITH(lcov,
  404. [ --with-lcov[=PROGRAM] enable gtest and coverage target using the specified lcov], lcov="$withval", lcov="no")
  405. AC_ARG_WITH(gtest,
  406. [ --with-gtest=PATH specify a path to gtest header files (PATH/include) and library (PATH/lib)],
  407. gtest_path="$withval", gtest_path="no")
  408. USE_LCOV="no"
  409. if test "$lcov" != "no"; then
  410. # force gtest if not set
  411. if test "$gtest_path" = "no"; then
  412. # AC_MSG_ERROR("lcov needs gtest for test coverage report")
  413. AC_MSG_NOTICE([gtest support is now enabled, because used by coverage tests])
  414. gtest_path="yes"
  415. fi
  416. if test "$lcov" != "yes"; then
  417. LCOV=$lcov
  418. else
  419. AC_PATH_PROG([LCOV], [lcov])
  420. fi
  421. if test -x "${LCOV}"; then
  422. USE_LCOV="yes"
  423. else
  424. AC_MSG_ERROR([Cannot find lcov.])
  425. fi
  426. # is genhtml always in the same directory?
  427. GENHTML=`echo "$LCOV" | sed s/lcov$/genhtml/`
  428. if test ! -x $GENHTML; then
  429. AC_MSG_ERROR([genhtml not found, needed for lcov])
  430. fi
  431. # GCC specific?
  432. CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
  433. LIBS=" $LIBS -lgcov"
  434. AC_SUBST(CPPFLAGS)
  435. AC_SUBST(LIBS)
  436. AC_SUBST(LCOV)
  437. AC_SUBST(GENHTML)
  438. fi
  439. AC_SUBST(USE_LCOV)
  440. # Simplified, non-caching AC_CHECK_PROG
  441. # Searches $PATH for the existence of argument 2,
  442. # and sets the full path to the variable in argument 1.
  443. # if not found, and a third argument is given, the value
  444. # is set to that.
  445. # Does not take full paths into account at this point,
  446. # and also works for single files only (arguments are not
  447. # stripped like in AC_CHECK_PROG)
  448. AC_DEFUN([ACX_CHECK_PROG_NONCACHE], [
  449. RESULT=""
  450. IFS_SAVED="$IFS"
  451. IFS=":"
  452. for cur_path in ${PATH} ; do
  453. if test -e "${cur_path}/$2" ; then
  454. RESULT="${cur_path}/$2"
  455. fi
  456. done
  457. if test "$RESULT" = "" ; then
  458. m4_ifvaln([$3], [$1=$3])
  459. else
  460. $1=$RESULT
  461. fi
  462. IFS="$IFS_SAVED"
  463. ])
  464. # Botan helper test function
  465. # Tries to compile a program, given the output of the given
  466. # Arguments:
  467. # - name of tool (checked for path), must support --libs and --cflags
  468. # - fixed argument(s) for tool
  469. # - action if successful
  470. # - action if failed
  471. AC_DEFUN([ACX_TRY_BOTAN_TOOL], [
  472. TOOL=$1
  473. TOOL_ARG=$2
  474. BOTAN_TOOL=""
  475. ACX_CHECK_PROG_NONCACHE([BOTAN_TOOL], [${TOOL}], [""])
  476. AC_MSG_CHECKING([for usability of ${TOOL} ${TOOL_ARG}])
  477. if test "$BOTAN_TOOL" != "" ; then
  478. if test -x ${BOTAN_TOOL}; then
  479. BOTAN_LIBS=`$BOTAN_TOOL $TOOL_ARG --libs`
  480. LIBS_SAVED=${LIBS}
  481. LIBS="$LIBS $BOTAN_LIBS"
  482. BOTAN_INCLUDES=`$BOTAN_TOOL $TOOL_ARG --cflags`
  483. CPPFLAGS_SAVED=${CPPFLAGS}
  484. CPPFLAGS="$BOTAN_INCLUDES $CPPFLAGS"
  485. #AC_MSG_RESULT([found])
  486. AC_LINK_IFELSE(
  487. [AC_LANG_PROGRAM([#include <botan/botan.h>
  488. #include <botan/hash.h>
  489. ],
  490. [using namespace Botan;
  491. LibraryInitializer::initialize();
  492. HashFunction *h = get_hash("MD5");
  493. ])],
  494. [ AC_MSG_RESULT([ok])
  495. $3
  496. ],
  497. [ AC_MSG_RESULT([not usable])
  498. $4
  499. ]
  500. )
  501. LIBS=${LIBS_SAVED}
  502. CPPFLAGS=${CPPFLAGS_SAVED}
  503. else
  504. AC_MSG_RESULT([not executable])
  505. $4
  506. fi
  507. else
  508. AC_MSG_RESULT([not found])
  509. $4
  510. fi
  511. BOTAN_TOOL=""
  512. AC_SUBST(BOTAN_TOOL)
  513. ]
  514. )
  515. # Check for Botan
  516. botan_config="yes"
  517. AC_ARG_WITH([botan-config],
  518. AC_HELP_STRING([--with-botan-config=PATH],
  519. [specify the path to the botan-config script]),
  520. [botan_config="$withval"])
  521. if test "${botan_config}" = "no" ; then
  522. AC_MSG_ERROR([Need botan for libcryptolink])
  523. fi
  524. if test "${botan_config}" != "yes" ; then
  525. if test -x "${botan_config}" ; then
  526. if test -d "${botan_config}" ; then
  527. AC_MSG_ERROR([${botan_config} is a directory])
  528. else
  529. BOTAN_CONFIG="${botan_config}"
  530. fi
  531. else
  532. AC_MSG_ERROR([--with-botan-config should point to a botan-config program and not a directory (${botan_config})])
  533. fi
  534. else
  535. BOTAN_CONFIG=""
  536. # first try several possible names of the config script
  537. # (1.8 is there just in case)
  538. BOTAN_CONFIG_VERSIONS="botan-config-1.10 botan-config-1.9 botan-config-1.8 botan-config"
  539. for botan_config in $BOTAN_CONFIG_VERSIONS; do
  540. ACX_TRY_BOTAN_TOOL([$botan_config],,
  541. [ BOTAN_CONFIG="$botan_config" ],
  542. []
  543. )
  544. if test "$BOTAN_CONFIG" != "" ; then
  545. break
  546. fi
  547. done
  548. if test "$BOTAN_CONFIG" = "" ; then
  549. AC_PATH_PROG([PKG_CONFIG], [pkg-config])
  550. if test "$PKG_CONFIG" != "" ; then
  551. # Ok so no script found, see if pkg-config knows of it.
  552. # Unfortunately, the botan.pc files also have their minor version
  553. # in their name, so we need to try them one by one
  554. BOTAN_VERSIONS="botan-1.10 botan-1.9 botan-1.8"
  555. for version in $BOTAN_VERSIONS; do
  556. ACX_TRY_BOTAN_TOOL([pkg-config], ["$version --silence-errors"],
  557. [ BOTAN_CONFIG="$PKG_CONFIG $version" ],
  558. []
  559. )
  560. if test "$BOTAN_CONFIG" != "" ; then
  561. break
  562. fi
  563. done
  564. fi
  565. fi
  566. fi
  567. if test "x${BOTAN_CONFIG}" != "x"
  568. then
  569. BOTAN_LIBS=`${BOTAN_CONFIG} --libs`
  570. BOTAN_INCLUDES=`${BOTAN_CONFIG} --cflags`
  571. # We expect botan-config --libs to contain -L<path_to_libbotan>, but
  572. # this is not always the case. As a heuristics workaround we add
  573. # -L`botan-config --prefix/lib` in this case (if not present already).
  574. # Same for BOTAN_INCLUDES (but using include instead of lib) below.
  575. if [ ${BOTAN_CONFIG} --prefix >/dev/null 2>&1 ] ; then
  576. echo ${BOTAN_LIBS} | grep -- -L > /dev/null || \
  577. BOTAN_LIBS="-L`${BOTAN_CONFIG} --prefix`/lib ${BOTAN_LIBS}"
  578. echo ${BOTAN_INCLUDES} | grep -- -I > /dev/null || \
  579. BOTAN_INCLUDES="-I`${BOTAN_CONFIG} --prefix`/include ${BOTAN_INCLUDES}"
  580. fi
  581. fi
  582. # botan-config script (and the way we call pkg-config) returns -L and -l
  583. # as one string, but we need them in separate values
  584. BOTAN_LDFLAGS=
  585. BOTAN_NEWLIBS=
  586. for flag in ${BOTAN_LIBS}; do
  587. BOTAN_LDFLAGS="${BOTAN_LDFLAGS} `echo $flag | sed -ne '/^\(\-L\)/p'`"
  588. BOTAN_LIBS="${BOTAN_LIBS} `echo $flag | sed -ne '/^\(\-l\)/p'`"
  589. done
  590. # See python_rpath for some info on why we do this
  591. if test $rpath_flag != no; then
  592. BOTAN_RPATH=
  593. for flag in ${BOTAN_LIBS}; do
  594. BOTAN_RPATH="${BOTAN_RPATH} `echo $flag | sed -ne "s/^\(\-L\)/${rpath_flag}/p"`"
  595. done
  596. AC_SUBST(BOTAN_RPATH)
  597. # According to the libtool manual, it should be sufficient if we
  598. # specify the "-R libdir" in our wrapper library of botan (no other
  599. # programs will need libbotan directly); "libdir" should be added to
  600. # the program's binary image. But we've seen in our build environments
  601. # that (some versions of?) libtool doesn't propagate -R as documented,
  602. # and it caused a linker error at run time. To work around this, we
  603. # also add the rpath to the global LDFLAGS.
  604. LDFLAGS="$BOTAN_RPATH $LDFLAGS"
  605. fi
  606. AC_SUBST(BOTAN_LDFLAGS)
  607. AC_SUBST(BOTAN_LIBS)
  608. AC_SUBST(BOTAN_INCLUDES)
  609. # Even though chances are high we already performed a real compilation check
  610. # in the search for the right (pkg)config data, we try again here, to
  611. # be sure.
  612. CPPFLAGS_SAVED=$CPPFLAGS
  613. CPPFLAGS="$BOTAN_INCLUDES $CPPFLAGS"
  614. LIBS_SAVED="$LIBS"
  615. LIBS="$LIBS $BOTAN_LIBS"
  616. AC_CHECK_HEADERS([botan/botan.h],,AC_MSG_ERROR([Missing required header files.]))
  617. AC_LINK_IFELSE(
  618. [AC_LANG_PROGRAM([#include <botan/botan.h>
  619. #include <botan/hash.h>
  620. ],
  621. [using namespace Botan;
  622. LibraryInitializer::initialize();
  623. HashFunction *h = get_hash("MD5");
  624. ])],
  625. [AC_MSG_RESULT([checking for Botan library... yes])],
  626. [AC_MSG_RESULT([checking for Botan library... no])
  627. AC_MSG_ERROR([Needs Botan library 1.8 or higher. On some systems,
  628. the botan package has a few missing dependencies (libbz2 and
  629. libgmp), if libbotan has been installed and you see this error,
  630. try upgrading to a higher version of botan or installing libbz2
  631. and libgmp.])]
  632. )
  633. CPPFLAGS=$CPPFLAGS_SAVED
  634. LIBS=$LIBS_SAVED
  635. # Check for log4cplus
  636. log4cplus_path="yes"
  637. AC_ARG_WITH([log4cplus],
  638. AC_HELP_STRING([--with-log4cplus=PATH],
  639. [specify exact directory of log4cplus library and headers]),
  640. [log4cplus_path="$withval"])
  641. if test "${log4cplus_path}" = "no" ; then
  642. AC_MSG_ERROR([Need log4cplus])
  643. elif test "${log4cplus_path}" != "yes" ; then
  644. LOG4CPLUS_INCLUDES="-I${log4cplus_path}/include"
  645. LOG4CPLUS_LIBS="-L${log4cplus_path}/lib"
  646. else
  647. # If not specified, try some common paths.
  648. log4cplusdirs="/usr/local /usr/pkg /opt /opt/local"
  649. for d in $log4cplusdirs
  650. do
  651. if test -f $d/include/log4cplus/logger.h; then
  652. LOG4CPLUS_INCLUDES="-I$d/include"
  653. LOG4CPLUS_LIBS="-L$d/lib"
  654. break
  655. fi
  656. done
  657. fi
  658. LOG4CPLUS_LIBS="$LOG4CPLUS_LIBS -llog4cplus $MULTITHREADING_FLAG"
  659. AC_SUBST(LOG4CPLUS_LIBS)
  660. AC_SUBST(LOG4CPLUS_INCLUDES)
  661. CPPFLAGS_SAVED=$CPPFLAGS
  662. CPPFLAGS="$LOG4CPLUS_INCLUDES $CPPFLAGS"
  663. LIBS_SAVED="$LIBS"
  664. LIBS="$LOG4CPLUS_LIBS $LIBS"
  665. AC_CHECK_HEADERS([log4cplus/logger.h],,AC_MSG_ERROR([Missing required header files.]))
  666. AC_LINK_IFELSE(
  667. [AC_LANG_PROGRAM([#include <log4cplus/logger.h>
  668. ],
  669. [using namespace log4cplus;
  670. Logger logger = Logger::getInstance("main");
  671. ])],
  672. [AC_MSG_RESULT([checking for log4cplus library... yes])],
  673. [AC_MSG_RESULT([checking for log4cplus library... no])
  674. AC_MSG_ERROR([Needs log4cplus library])]
  675. )
  676. CPPFLAGS=$CPPFLAGS_SAVED
  677. LIBS=$LIBS_SAVED
  678. #
  679. # Configure Boost header path
  680. #
  681. # If explicitly specified, use it.
  682. AC_ARG_WITH([boost-include],
  683. AC_HELP_STRING([--with-boost-include=PATH],
  684. [specify exact directory for Boost headers]),
  685. [boost_include_path="$withval"])
  686. # If not specified, try some common paths.
  687. if test -z "$with_boost_include"; then
  688. boostdirs="/usr/local /usr/pkg /opt /opt/local"
  689. for d in $boostdirs
  690. do
  691. if test -f $d/include/boost/shared_ptr.hpp; then
  692. boost_include_path=$d/include
  693. break
  694. fi
  695. done
  696. fi
  697. CPPFLAGS_SAVES="$CPPFLAGS"
  698. if test "${boost_include_path}" ; then
  699. BOOST_INCLUDES="-I${boost_include_path}"
  700. CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES"
  701. fi
  702. 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],,
  703. AC_MSG_ERROR([Missing required header files.]))
  704. CPPFLAGS="$CPPFLAGS_SAVES"
  705. AC_SUBST(BOOST_INCLUDES)
  706. if test "${use_boost_threads}" = "yes" ; then
  707. AC_DEFINE([USE_BOOST_THREADS], [], [Use boost threads])
  708. # Using boost::mutex can result in requiring libboost_thread with older
  709. # versions of Boost. We'd like to avoid relying on a compiled Boost library
  710. # whenever possible, so we need to check for it step by step.
  711. #
  712. # NOTE: another fix of this problem is to simply require newer versions of
  713. # boost. If we choose that solution we should simplify the following tricky
  714. # checks accordingly and all Makefile.am's that refer to NEED_LIBBOOST_THREAD.
  715. AC_MSG_CHECKING(for boost::mutex)
  716. CPPFLAGS_SAVES="$CPPFLAGS"
  717. LIBS_SAVES="$LIBS"
  718. CPPFLAGS="$BOOST_INCLUDES $CPPFLAGS $MULTITHREADING_FLAG"
  719. need_libboost_thread=0
  720. need_sunpro_workaround=0
  721. AC_TRY_LINK([
  722. #include <boost/thread.hpp>
  723. ],[
  724. boost::mutex m;
  725. ],
  726. [ AC_MSG_RESULT(yes (without libboost_thread)) ],
  727. # there is one specific problem with SunStudio 5.10
  728. # where including boost/thread causes a compilation failure
  729. # There is a workaround in boost but it checks the version not being 5.10
  730. # This will probably be fixed in the future, in which case this
  731. # is only a temporary workaround
  732. [ AC_TRY_LINK([
  733. #if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
  734. #undef __SUNPRO_CC
  735. #define __SUNPRO_CC 0x5090
  736. #endif
  737. #include <boost/thread.hpp>
  738. ],[
  739. boost::mutex m;
  740. ],
  741. [ AC_MSG_RESULT(yes (with SUNOS workaround))
  742. need_sunpro_workaround=1 ],
  743. [ LIBS=" $LIBS -lboost_thread"
  744. AC_TRY_LINK([
  745. #include <boost/thread.hpp>
  746. ],[
  747. boost::mutex m;
  748. ],
  749. [ AC_MSG_RESULT(yes (with libboost_thread))
  750. need_libboost_thread=1 ],
  751. [ AC_MSG_RESULT(no)
  752. AC_MSG_ERROR([boost::mutex cannot be linked in this build environment.
  753. Perhaps you are using an older version of Boost that requires libboost_thread for the mutex support, which does not appear to be available.
  754. You may want to check the availability of the library or to upgrade Boost.])
  755. ])])])
  756. CPPFLAGS="$CPPFLAGS_SAVES"
  757. LIBS="$LIBS_SAVES"
  758. AM_CONDITIONAL(NEED_LIBBOOST_THREAD, test $need_libboost_thread = 1)
  759. if test $need_sunpro_workaround = 1; then
  760. AC_DEFINE([NEED_SUNPRO_WORKAROUND], [], [Need boost sunstudio workaround])
  761. fi
  762. else
  763. AM_CONDITIONAL(NEED_LIBBOOST_THREAD, test "${use_boost_threads}" = "yes")
  764. fi
  765. # I can't get some of the #include <asio.hpp> right without this
  766. # TODO: find the real cause of asio/boost wanting pthreads
  767. # (this currently only occurs for src/lib/cc/session_unittests)
  768. PTHREAD_LDFLAGS=
  769. AC_CHECK_LIB(pthread, pthread_create,[ PTHREAD_LDFLAGS=-lpthread ], [])
  770. AC_SUBST(PTHREAD_LDFLAGS)
  771. AC_SUBST(MULTITHREADING_FLAG)
  772. #
  773. # Check availability of gtest, which will be used for unit tests.
  774. #
  775. if test "$gtest_path" != "no"
  776. then
  777. DISTCHECK_GTEST_CONFIGURE_FLAG="--with-gtest=\"$gtest_path\""
  778. if test "$gtest_path" != "yes"; then
  779. GTEST_PATHS=$gtest_path
  780. if test -x "${gtest_path}/bin/gtest-config" ; then
  781. GTEST_CONFIG="${gtest_path}/bin/gtest-config"
  782. fi
  783. else
  784. AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
  785. fi
  786. if test -x "${GTEST_CONFIG}" ; then :
  787. # using cppflags instead of cxxflags
  788. GTEST_INCLUDES=`${GTEST_CONFIG} --cppflags`
  789. GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
  790. GTEST_LDADD=`${GTEST_CONFIG} --libs`
  791. GTEST_FOUND="true"
  792. else
  793. AC_MSG_WARN([Unable to locate Google Test gtest-config.])
  794. if test -z "${GTEST_PATHS}" ; then
  795. GTEST_PATHS="/usr /usr/local"
  796. fi
  797. GTEST_FOUND="false"
  798. fi
  799. if test "${GTEST_FOUND}" != "true"; then
  800. GTEST_FOUND="false"
  801. for dir in $GTEST_PATHS; do
  802. if test -f "$dir/include/gtest/gtest.h"; then
  803. GTEST_INCLUDES="-I$dir/include"
  804. GTEST_LDFLAGS="-L$dir/lib"
  805. GTEST_LDADD="-lgtest"
  806. GTEST_FOUND="true"
  807. # There is no gtest-config script on this
  808. # system, which is supposed to inform us
  809. # whether we need pthreads as well (a
  810. # gtest compile-time option). So we still
  811. # need to test that manually.
  812. CPPFLAGS_SAVED="$CPPFLAGS"
  813. CPPFLAGS="$CPPFLAGS $GTEST_INCLUDES"
  814. LDFLAGS_SAVED="$LDFLAGS"
  815. LDFLAGS="$LDFLAGS $GTEST_LDFLAGS"
  816. LIBS_SAVED=$LIBS
  817. LIBS="$LIBS $GTEST_LDADD"
  818. AC_MSG_CHECKING([Checking whether gtest tests need pthreads])
  819. # First try to compile without pthreads
  820. AC_TRY_LINK([
  821. #include <gtest/gtest.h>
  822. ],[
  823. int i = 0;
  824. char* c = NULL;
  825. ::testing::InitGoogleTest(&i, &c);
  826. return (0);
  827. ],
  828. [ AC_MSG_RESULT(no) ],
  829. [
  830. LIBS="$SAVED_LIBS $GTEST_LDADD $PTHREAD_LDFLAGS"
  831. # Now try to compile with pthreads
  832. AC_TRY_LINK([
  833. #include <gtest/gtest.h>
  834. ],[
  835. int i = 0;
  836. char* c = NULL;
  837. ::testing::InitGoogleTest(&i, &c);
  838. return (0);
  839. ],
  840. [ AC_MSG_RESULT(yes)
  841. GTEST_LDADD="$GTEST_LDADD $PTHREAD_LDFLAGS"
  842. ],
  843. # Apparently we can't compile it at all
  844. [ AC_MSG_ERROR(unable to compile with gtest) ])
  845. ])
  846. CPPFLAGS=$CPPFLAGS_SAVED
  847. LDFLAGS=$LDFLAGS_SAVED
  848. LIBS=$LIBS_SAVED
  849. break
  850. fi
  851. done
  852. fi
  853. if test "${GTEST_FOUND}" != "true"; then
  854. AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
  855. fi
  856. else
  857. GTEST_INCLUDES=
  858. GTEST_LDFLAGS=
  859. GTEST_LDADD=
  860. DISTCHECK_GTEST_CONFIGURE_FLAG=
  861. fi
  862. AM_CONDITIONAL(HAVE_GTEST, test $gtest_path != "no")
  863. AC_SUBST(DISTCHECK_GTEST_CONFIGURE_FLAG)
  864. AC_SUBST(GTEST_INCLUDES)
  865. AC_SUBST(GTEST_LDFLAGS)
  866. AC_SUBST(GTEST_LDADD)
  867. dnl check for pkg-config itself so we don't try the m4 macro without pkg-config
  868. AC_CHECK_PROG(HAVE_PKG_CONFIG, pkg-config, yes, no)
  869. if test "x$HAVE_PKG_CONFIG" = "xno" ; then
  870. AC_MSG_ERROR(Please install pkg-config)
  871. fi
  872. PKG_CHECK_MODULES(SQLITE, sqlite3 >= 3.3.9, enable_features="$enable_features SQLite3")
  873. #
  874. # ASIO: we extensively use it as the C++ event management module.
  875. #
  876. # Use local ASIO headers from ext
  877. #
  878. CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/asio"
  879. #
  880. # Use our 'coroutine' header from ext
  881. CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/coroutine"
  882. #
  883. # Disable threads: Currently we don't use them.
  884. CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_THREADS=1"
  885. #
  886. # kqueue portability: ASIO uses kqueue by default if it's available (it's
  887. # generally available in BSD variants). Unfortunately, some public
  888. # implementation of kqueue forces a conversion from a pointer to an integer,
  889. # which is prohibited in C++ unless reinterpret_cast, C++'s most evil beast
  890. # (and ASIO doesn't use it anyway) is used. This will cause build error for
  891. # some of our C++ files including ASIO header files. The following check
  892. # detects such cases and tells ASIO not to use kqueue if so.
  893. AC_CHECK_FUNC(kqueue, ac_cv_have_kqueue=yes, ac_cv_have_kqueue=no)
  894. if test "X$ac_cv_have_kqueue" = "Xyes"; then
  895. AC_MSG_CHECKING([whether kqueue EV_SET compiles in C++])
  896. AC_TRY_COMPILE([
  897. #include <sys/types.h>
  898. #include <sys/param.h>
  899. #include <sys/event.h>],
  900. [char* udata;
  901. EV_SET(NULL, 0, 0, 0, 0, 0, udata);],
  902. [AC_MSG_RESULT(yes)],
  903. [AC_MSG_RESULT([no, disable kqueue for ASIO])
  904. CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_KQUEUE=1"
  905. ])
  906. fi
  907. # perfdhcp: If the clock_gettime() function does not exist on the system,
  908. # use an alternative supplied in the code based on gettimeofday().
  909. CLOCK_GETTIME_LDFLAGS=
  910. AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_GETTIME_LDFLAGS=-lrt], [])
  911. AC_SUBST([CLOCK_GETTIME_LDFLAGS])
  912. # perfdhcp: if getifaddrs() does not exist, have the code output a message
  913. # that it can't be run on this version of the operating system. For the
  914. # systems on which BIND 10 is built, this means Solaris 10. (Replacements
  915. # for this function are long and involved, and the function is reported present
  916. # on Solaris 11 and later, either in the libsocket or libnsl libraries.)
  917. AC_SEARCH_LIBS([getifaddrs], [socket nsl],
  918. [AC_DEFINE([HAVE_GETIFADDRS], [1], [getifaddrs() present])])
  919. # /dev/poll issue: ASIO uses /dev/poll by default if it's available (generally
  920. # the case with Solaris). Unfortunately its /dev/poll specific code would
  921. # trigger the gcc's "missing-field-initializers" warning, which would
  922. # subsequently make the build fail with -Werror. Further, older versions of
  923. # gcc don't provide an option to selectively suppress this warning.
  924. # So, for the moment, we simply disable the use of /dev/poll. Unless we
  925. # implement recursive DNS server with randomized ports, we don't need the
  926. # scalability that /dev/poll can provide, so this decision wouldn't affect
  927. # run time performance. Hopefully we can find a better solution or the ASIO
  928. # code will be updated by the time we really need it.
  929. AC_CHECK_HEADERS(sys/devpoll.h, ac_cv_have_devpoll=yes, ac_cv_have_devpoll=no)
  930. if test "X$ac_cv_have_devpoll" = "Xyes" -a "X$GXX" = "Xyes"; then
  931. CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_DEV_POLL=1"
  932. fi
  933. #
  934. # Perl is optional; it is used only by some of the system test scripts.
  935. #
  936. AC_PATH_PROGS(PERL, perl5 perl)
  937. AC_SUBST(PERL)
  938. AC_PATH_PROGS(AWK, gawk awk)
  939. AC_SUBST(AWK)
  940. AC_ARG_ENABLE(man, [AC_HELP_STRING([--enable-man],
  941. [regenerate man pages [default=no]])], enable_man=$enableval, enable_man=no)
  942. AM_CONDITIONAL(ENABLE_MAN, test x$enable_man != xno)
  943. AC_ARG_ENABLE(install-configurations,
  944. [AC_HELP_STRING([--disable-install-configurations],
  945. [do not install configuration])], install_configurations=$enableval, install_configurations=yes)
  946. AM_CONDITIONAL(INSTALL_CONFIGURATIONS, test x$install_configurations = xyes || test x$install_configurations = xtrue)
  947. AC_CONFIG_FILES([Makefile
  948. doc/Makefile
  949. doc/guide/Makefile
  950. compatcheck/Makefile
  951. src/Makefile
  952. src/bin/Makefile
  953. src/bin/bind10/Makefile
  954. src/bin/bind10/tests/Makefile
  955. src/bin/cmdctl/Makefile
  956. src/bin/cmdctl/tests/Makefile
  957. src/bin/bindctl/Makefile
  958. src/bin/bindctl/tests/Makefile
  959. src/bin/cfgmgr/Makefile
  960. src/bin/cfgmgr/plugins/Makefile
  961. src/bin/cfgmgr/plugins/tests/Makefile
  962. src/bin/cfgmgr/tests/Makefile
  963. src/bin/host/Makefile
  964. src/bin/loadzone/Makefile
  965. src/bin/loadzone/tests/correct/Makefile
  966. src/bin/loadzone/tests/error/Makefile
  967. src/bin/msgq/Makefile
  968. src/bin/msgq/tests/Makefile
  969. src/bin/auth/Makefile
  970. src/bin/auth/tests/Makefile
  971. src/bin/auth/benchmarks/Makefile
  972. src/bin/ddns/Makefile
  973. src/bin/ddns/tests/Makefile
  974. src/bin/dhcp6/Makefile
  975. src/bin/dhcp6/tests/Makefile
  976. src/bin/dhcp4/Makefile
  977. src/bin/dhcp4/tests/Makefile
  978. src/bin/resolver/Makefile
  979. src/bin/resolver/tests/Makefile
  980. src/bin/sockcreator/Makefile
  981. src/bin/sockcreator/tests/Makefile
  982. src/bin/xfrin/Makefile
  983. src/bin/xfrin/tests/Makefile
  984. src/bin/xfrin/tests/testdata/Makefile
  985. src/bin/xfrout/Makefile
  986. src/bin/xfrout/tests/Makefile
  987. src/bin/zonemgr/Makefile
  988. src/bin/zonemgr/tests/Makefile
  989. src/bin/stats/Makefile
  990. src/bin/stats/tests/Makefile
  991. src/bin/usermgr/Makefile
  992. src/bin/tests/Makefile
  993. src/lib/Makefile
  994. src/lib/asiolink/Makefile
  995. src/lib/asiolink/tests/Makefile
  996. src/lib/asiodns/Makefile
  997. src/lib/asiodns/tests/Makefile
  998. src/lib/bench/Makefile
  999. src/lib/bench/example/Makefile
  1000. src/lib/bench/tests/Makefile
  1001. src/lib/cc/Makefile
  1002. src/lib/cc/tests/Makefile
  1003. src/lib/python/Makefile
  1004. src/lib/python/isc/Makefile
  1005. src/lib/python/isc/acl/Makefile
  1006. src/lib/python/isc/acl/tests/Makefile
  1007. src/lib/python/isc/util/Makefile
  1008. src/lib/python/isc/util/tests/Makefile
  1009. src/lib/python/isc/util/cio/Makefile
  1010. src/lib/python/isc/util/cio/tests/Makefile
  1011. src/lib/python/isc/datasrc/Makefile
  1012. src/lib/python/isc/datasrc/tests/Makefile
  1013. src/lib/python/isc/dns/Makefile
  1014. src/lib/python/isc/cc/Makefile
  1015. src/lib/python/isc/cc/tests/Makefile
  1016. src/lib/python/isc/config/Makefile
  1017. src/lib/python/isc/config/tests/Makefile
  1018. src/lib/python/isc/log/Makefile
  1019. src/lib/python/isc/log/tests/Makefile
  1020. src/lib/python/isc/log_messages/Makefile
  1021. src/lib/python/isc/log_messages/work/Makefile
  1022. src/lib/python/isc/net/Makefile
  1023. src/lib/python/isc/net/tests/Makefile
  1024. src/lib/python/isc/notify/Makefile
  1025. src/lib/python/isc/notify/tests/Makefile
  1026. src/lib/python/isc/testutils/Makefile
  1027. src/lib/python/isc/bind10/Makefile
  1028. src/lib/python/isc/bind10/tests/Makefile
  1029. src/lib/python/isc/xfrin/Makefile
  1030. src/lib/python/isc/xfrin/tests/Makefile
  1031. src/lib/python/isc/server_common/Makefile
  1032. src/lib/python/isc/server_common/tests/Makefile
  1033. src/lib/config/Makefile
  1034. src/lib/config/tests/Makefile
  1035. src/lib/config/tests/testdata/Makefile
  1036. src/lib/cryptolink/Makefile
  1037. src/lib/cryptolink/tests/Makefile
  1038. src/lib/dns/Makefile
  1039. src/lib/dns/tests/Makefile
  1040. src/lib/dns/tests/testdata/Makefile
  1041. src/lib/dns/python/Makefile
  1042. src/lib/dns/python/tests/Makefile
  1043. src/lib/dns/benchmarks/Makefile
  1044. src/lib/dhcp/Makefile
  1045. src/lib/dhcp/tests/Makefile
  1046. src/lib/exceptions/Makefile
  1047. src/lib/exceptions/tests/Makefile
  1048. src/lib/datasrc/Makefile
  1049. src/lib/datasrc/tests/Makefile
  1050. src/lib/datasrc/tests/testdata/Makefile
  1051. src/lib/xfr/Makefile
  1052. src/lib/xfr/tests/Makefile
  1053. src/lib/log/Makefile
  1054. src/lib/log/compiler/Makefile
  1055. src/lib/log/tests/Makefile
  1056. src/lib/resolve/Makefile
  1057. src/lib/resolve/tests/Makefile
  1058. src/lib/testutils/Makefile
  1059. src/lib/testutils/testdata/Makefile
  1060. src/lib/nsas/Makefile
  1061. src/lib/nsas/tests/Makefile
  1062. src/lib/cache/Makefile
  1063. src/lib/cache/tests/Makefile
  1064. src/lib/server_common/Makefile
  1065. src/lib/server_common/tests/Makefile
  1066. src/lib/util/Makefile
  1067. src/lib/util/io/Makefile
  1068. src/lib/util/unittests/Makefile
  1069. src/lib/util/python/Makefile
  1070. src/lib/util/pyunittests/Makefile
  1071. src/lib/util/tests/Makefile
  1072. src/lib/acl/Makefile
  1073. src/lib/acl/tests/Makefile
  1074. src/lib/statistics/Makefile
  1075. src/lib/statistics/tests/Makefile
  1076. tests/Makefile
  1077. tests/system/Makefile
  1078. tests/tools/Makefile
  1079. tests/tools/badpacket/Makefile
  1080. tests/tools/badpacket/tests/Makefile
  1081. tests/tools/perfdhcp/Makefile
  1082. ])
  1083. AC_OUTPUT([doc/version.ent
  1084. compatcheck/sqlite3-difftbl-check.py
  1085. src/bin/cfgmgr/b10-cfgmgr.py
  1086. src/bin/cfgmgr/tests/b10-cfgmgr_test.py
  1087. src/bin/cmdctl/cmdctl.py
  1088. src/bin/cmdctl/run_b10-cmdctl.sh
  1089. src/bin/cmdctl/tests/cmdctl_test
  1090. src/bin/cmdctl/cmdctl.spec.pre
  1091. src/bin/ddns/ddns.py
  1092. src/bin/xfrin/tests/xfrin_test
  1093. src/bin/xfrin/xfrin.py
  1094. src/bin/xfrin/run_b10-xfrin.sh
  1095. src/bin/xfrout/xfrout.py
  1096. src/bin/xfrout/xfrout.spec.pre
  1097. src/bin/xfrout/tests/xfrout_test
  1098. src/bin/xfrout/tests/xfrout_test.py
  1099. src/bin/xfrout/run_b10-xfrout.sh
  1100. src/bin/resolver/resolver.spec.pre
  1101. src/bin/resolver/spec_config.h.pre
  1102. src/bin/zonemgr/zonemgr.py
  1103. src/bin/zonemgr/zonemgr.spec.pre
  1104. src/bin/zonemgr/tests/zonemgr_test
  1105. src/bin/zonemgr/run_b10-zonemgr.sh
  1106. src/bin/stats/stats.py
  1107. src/bin/stats/stats_httpd.py
  1108. src/bin/bind10/bind10_src.py
  1109. src/bin/bind10/run_bind10.sh
  1110. src/bin/bind10/tests/bind10_test.py
  1111. src/bin/bindctl/run_bindctl.sh
  1112. src/bin/bindctl/bindctl_main.py
  1113. src/bin/bindctl/tests/bindctl_test
  1114. src/bin/loadzone/run_loadzone.sh
  1115. src/bin/loadzone/tests/correct/correct_test.sh
  1116. src/bin/loadzone/tests/error/error_test.sh
  1117. src/bin/loadzone/b10-loadzone.py
  1118. src/bin/usermgr/run_b10-cmdctl-usermgr.sh
  1119. src/bin/usermgr/b10-cmdctl-usermgr.py
  1120. src/bin/msgq/msgq.py
  1121. src/bin/msgq/tests/msgq_test
  1122. src/bin/msgq/run_msgq.sh
  1123. src/bin/auth/auth.spec.pre
  1124. src/bin/auth/spec_config.h.pre
  1125. src/bin/dhcp4/spec_config.h.pre
  1126. src/bin/dhcp6/spec_config.h.pre
  1127. src/bin/tests/process_rename_test.py
  1128. src/lib/config/tests/data_def_unittests_config.h
  1129. src/lib/python/isc/config/tests/config_test
  1130. src/lib/python/isc/cc/tests/cc_test
  1131. src/lib/python/isc/notify/tests/notify_out_test
  1132. src/lib/python/isc/log/tests/log_console.py
  1133. src/lib/python/isc/log_messages/work/__init__.py
  1134. src/lib/dns/gen-rdatacode.py
  1135. src/lib/python/bind10_config.py
  1136. src/lib/cc/session_config.h.pre
  1137. src/lib/cc/tests/session_unittests_config.h
  1138. src/lib/datasrc/datasrc_config.h.pre
  1139. src/lib/log/tests/console_test.sh
  1140. src/lib/log/tests/destination_test.sh
  1141. src/lib/log/tests/init_logger_test.sh
  1142. src/lib/log/tests/local_file_test.sh
  1143. src/lib/log/tests/severity_test.sh
  1144. src/lib/log/tests/tempdir.h
  1145. src/lib/util/python/mkpywrapper.py
  1146. src/lib/util/python/gen_wiredata.py
  1147. src/lib/server_common/tests/data_path.h
  1148. tests/lettuce/setup_intree_bind10.sh
  1149. tests/system/conf.sh
  1150. tests/system/run.sh
  1151. tests/system/glue/setup.sh
  1152. tests/system/glue/nsx1/b10-config.db
  1153. tests/system/bindctl/nsx1/b10-config.db.template
  1154. tests/system/ixfr/db.example.n0
  1155. tests/system/ixfr/db.example.n2
  1156. tests/system/ixfr/db.example.n2.refresh
  1157. tests/system/ixfr/db.example.n4
  1158. tests/system/ixfr/db.example.n6
  1159. tests/system/ixfr/ixfr_init.sh
  1160. tests/system/ixfr/b10-config.db
  1161. tests/system/ixfr/common_tests.sh
  1162. tests/system/ixfr/in-1/setup.sh
  1163. tests/system/ixfr/in-2/setup.sh
  1164. tests/system/ixfr/in-3/setup.sh
  1165. tests/system/ixfr/in-4/setup.sh
  1166. ], [
  1167. chmod +x compatcheck/sqlite3-difftbl-check.py
  1168. chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
  1169. chmod +x src/bin/xfrin/run_b10-xfrin.sh
  1170. chmod +x src/bin/xfrout/run_b10-xfrout.sh
  1171. chmod +x src/bin/zonemgr/run_b10-zonemgr.sh
  1172. chmod +x src/bin/bind10/run_bind10.sh
  1173. chmod +x src/bin/cmdctl/tests/cmdctl_test
  1174. chmod +x src/bin/xfrin/tests/xfrin_test
  1175. chmod +x src/bin/xfrout/tests/xfrout_test
  1176. chmod +x src/bin/zonemgr/tests/zonemgr_test
  1177. chmod +x src/bin/bindctl/tests/bindctl_test
  1178. chmod +x src/bin/bindctl/run_bindctl.sh
  1179. chmod +x src/bin/loadzone/run_loadzone.sh
  1180. chmod +x src/bin/loadzone/tests/correct/correct_test.sh
  1181. chmod +x src/bin/loadzone/tests/error/error_test.sh
  1182. chmod +x src/bin/usermgr/run_b10-cmdctl-usermgr.sh
  1183. chmod +x src/bin/msgq/run_msgq.sh
  1184. chmod +x src/bin/msgq/tests/msgq_test
  1185. chmod +x src/lib/dns/gen-rdatacode.py
  1186. chmod +x src/lib/log/tests/console_test.sh
  1187. chmod +x src/lib/log/tests/destination_test.sh
  1188. chmod +x src/lib/log/tests/init_logger_test.sh
  1189. chmod +x src/lib/log/tests/local_file_test.sh
  1190. chmod +x src/lib/log/tests/severity_test.sh
  1191. chmod +x src/lib/util/python/mkpywrapper.py
  1192. chmod +x src/lib/util/python/gen_wiredata.py
  1193. chmod +x src/lib/python/isc/log/tests/log_console.py
  1194. chmod +x tests/system/conf.sh
  1195. chmod +x tests/system/run.sh
  1196. chmod +x tests/system/ixfr/ixfr_init.sh
  1197. chmod +x tests/system/ixfr/common_tests.sh
  1198. chmod +x tests/system/ixfr/in-1/setup.sh
  1199. chmod +x tests/system/ixfr/in-2/setup.sh
  1200. chmod +x tests/system/ixfr/in-3/setup.sh
  1201. chmod +x tests/system/ixfr/in-4/setup.sh
  1202. ])
  1203. AC_OUTPUT
  1204. dnl Print the results
  1205. dnl
  1206. cat > config.report << END
  1207. BIND 10 source configure results:
  1208. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1209. Package:
  1210. Name: $PACKAGE_NAME
  1211. Version: $PACKAGE_VERSION
  1212. C++ Compiler: $CXX
  1213. Flags:
  1214. DEFS: $DEFS
  1215. CPPFLAGS: $CPPFLAGS
  1216. CXXFLAGS: $CXXFLAGS
  1217. LDFLAGS: $LDFLAGS
  1218. B10_CXXFLAGS: $B10_CXXFLAGS
  1219. OS Family: $OS_TYPE
  1220. dnl includes too
  1221. Python: ${PYTHON_INCLUDES}
  1222. ${PYTHON_CXXFLAGS}
  1223. ${PYTHON_LDFLAGS}
  1224. ${PYTHON_LIB}
  1225. Boost: ${BOOST_INCLUDES}
  1226. Botan: ${BOTAN_INCLUDES}
  1227. ${BOTAN_LDFLAGS}
  1228. ${BOTAN_LIBS}
  1229. Log4cplus: ${LOG4CPLUS_INCLUDES}
  1230. ${LOG4CPLUS_LIBS}
  1231. SQLite: $SQLITE_CFLAGS
  1232. $SQLITE_LIBS
  1233. Features:
  1234. $enable_features
  1235. Developer:
  1236. Google Tests: $gtest_path
  1237. C++ Code Coverage: $USE_LCOV
  1238. Python Code Coverage: $USE_PYCOVERAGE
  1239. Generate Manuals: $enable_man
  1240. END
  1241. cat config.report
  1242. cat <<EOF
  1243. Now you can type "make" to build BIND 10
  1244. EOF