configure.ac 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.59])
  4. # For released versions, this is in x.y.z format.
  5. # For GIT versions, this is x.y.z-git, where x.y.z denotes the software
  6. # version that was used as a base + changes that were made later, but
  7. # are not released yet.
  8. AC_INIT(kea,1.1.0-git, kea-dev@lists.isc.org)
  9. AC_CONFIG_SRCDIR(README)
  10. # serial-tests is not available in automake version before 1.13, so
  11. # we'll check that and conditionally use serial-tests. This check is
  12. # adopted from code by Richard W.M. Jones:
  13. # https://www.redhat.com/archives/libguestfs/2013-February/msg00102.html
  14. m4_define([serial_tests], [
  15. m4_esyscmd([automake --version |
  16. head -1 |
  17. awk '{split ($NF,a,"."); if (a[1] == 1 && a[2] >= 12) { print "serial-tests" }}'
  18. ])
  19. ])
  20. AM_INIT_AUTOMAKE(foreign serial_tests)
  21. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])dnl be backward compatible
  22. AC_CONFIG_HEADERS([config.h])
  23. AC_CONFIG_MACRO_DIR([m4macros])
  24. AC_CANONICAL_HOST
  25. # Checks for programs.
  26. AC_PROG_CXX
  27. # Check for exact Kea version.
  28. AC_MSG_CHECKING(whether this is a tarball or git source)
  29. if test -d "${srcdir}/.git"; then
  30. KEA_SRCID="git `(cd "${top_srcdir}";git rev-parse HEAD)`"
  31. AC_MSG_RESULT("git")
  32. else
  33. KEA_SRCID="tarball"
  34. AC_MSG_RESULT("tarball")
  35. fi
  36. # Export EXTENDED_VERSION to config.h
  37. # This will be either "tarball" or "git abcd".
  38. AC_DEFINE_UNQUOTED([EXTENDED_VERSION], ["${KEA_SRCID}"], [Extended Kea version])
  39. # Find a separator for path_replacer
  40. for sep in "+" "," ";" "&" "__NONE__"; do
  41. if `pwd | grep -q $sep`; then continue; fi
  42. if `echo ${prefix} | grep -q $sep`; then continue; fi
  43. if `echo ${sysconfdir} | grep -q $sep`; then continue; fi
  44. if `echo ${localstatedir} | grep -q $sep`; then continue; fi
  45. SEP=$sep
  46. break
  47. done
  48. if test "$sep" = "__NONE__"; then
  49. AC_MSG_ERROR([can't find a separator character in '+,;&' for the path_replacer shell script])
  50. fi
  51. AC_SUBST(SEP)
  52. # Enable low-performing debugging facilities? This option optionally
  53. # enables some debugging aids that perform slowly and hence aren't built
  54. # by default.
  55. AC_ARG_ENABLE([debug],
  56. AS_HELP_STRING([--enable-debug],
  57. [enable debugging (default is no)]),
  58. [case "${enableval}" in
  59. yes) debug_enabled=yes ;;
  60. no) debug_enabled=no ;;
  61. *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
  62. esac],[debug_enabled=no])
  63. AM_CONDITIONAL([DEBUG_ENABLED], [test x$debug_enabled = xyes])
  64. AM_COND_IF([DEBUG_ENABLED], [AC_DEFINE([ENABLE_DEBUG], [1], [Enable low-performing debugging facilities?])])
  65. PREMIUM_DIR=
  66. if test -d "${srcdir}/premium"; then
  67. PREMIUM_DIR=premium
  68. AC_CONFIG_SUBDIRS([premium])
  69. fi
  70. AC_SUBST(PREMIUM_DIR)
  71. # Libtool configuration
  72. #
  73. # libtool cannot handle spaces in paths, so exit early if there is one
  74. if [ test `echo $PWD | grep -c ' '` != "0" ]; then
  75. AC_MSG_ERROR([Kea 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.])
  76. fi
  77. # On FreeBSD (and probably some others), clang++ does not meet an autoconf
  78. # assumption in identifying libtool configuration regarding shared library:
  79. # the configure script will execute "$CC -shared $CFLAGS/$CXXFLAGS -v" and
  80. # expect the output contains -Lxxx or -Ryyy. This is the case for g++, but
  81. # not for clang++, and, as a result, it will cause various errors in linking
  82. # programs or running them with a shared object (such as some of our python
  83. # scripts).
  84. # To work around this problem we define a temporary variable
  85. # "CXX_LIBTOOL_LDFLAGS". It's expected to be defined as, e.g, "-L/usr/lib"
  86. # to temporarily fake the output so that it will be compatible with that of
  87. # g++.
  88. CFLAGS_SAVED=$CFLAGS
  89. CXXFLAGS_SAVED=$CXXFLAGS
  90. CFLAGS="$CFLAGS $CXX_LIBTOOL_LDFLAGS"
  91. CXXFLAGS="$CXXFLAGS $CXX_LIBTOOL_LDFLAGS"
  92. LT_INIT
  93. CFLAGS=$CFLAGS_SAVED
  94. CXXFLAGS=$CXXFLAGS_SAVED
  95. # Use C++ language
  96. AC_LANG([C++])
  97. # Identify the compiler: this check must be after AC_PROG_CXX and AC_LANG.
  98. AM_CONDITIONAL(USE_GXX, test "X${GXX}" = "Xyes")
  99. AC_CHECK_DECL([__SUNPRO_CC], [SUNCXX="yes"], [SUNCXX="no"])
  100. AC_CHECK_DECL([__clang__], [CLANGPP="yes"], [CLANGPP="no"])
  101. # USE_CLANGPP is no longer used, keep it by summetry with USE_GXX?
  102. AM_CONDITIONAL(USE_CLANGPP, test "X${CLANGPP}" = "Xyes")
  103. # Check for std::unique_ptr and aggregate initialization (aka C++11) support
  104. CXX_SAVED=$CXX
  105. feature=
  106. for retry in "none" "--std=c++11" "--std=c++0x" "--std=c++1x" "fail"; do
  107. if test "$retry" = "fail"; then
  108. AC_MSG_ERROR([$feature (a C++11 feature) is not supported])
  109. fi
  110. if test "$retry" != "none"; then
  111. AC_MSG_WARN([unsupported C++11 feature])
  112. AC_MSG_NOTICE([retrying by adding $retry to $CXX])
  113. CXX="$CXX_SAVED $retry"
  114. fi
  115. AC_MSG_CHECKING(std::unique_ptr support)
  116. feature="std::unique_ptr"
  117. AC_COMPILE_IFELSE(
  118. [AC_LANG_PROGRAM(
  119. [#include <memory>],
  120. [std::unique_ptr<int> a;])],
  121. [AC_MSG_RESULT([yes])],
  122. [AC_MSG_RESULT([no])
  123. continue])
  124. AC_MSG_CHECKING(aggregate initialization support)
  125. feature="aggregate initialization"
  126. AC_COMPILE_IFELSE(
  127. [AC_LANG_PROGRAM(
  128. [#include <vector>],
  129. [std::vector<int> foo = { 1, 2, 3};])],
  130. [AC_MSG_RESULT([yes])
  131. break],
  132. [AC_MSG_RESULT([no])
  133. continue])
  134. done
  135. dnl Determine if we are using GNU sed
  136. GNU_SED=no
  137. $SED --version 2> /dev/null | grep GNU > /dev/null 2>&1
  138. if test $? -eq 0; then
  139. GNU_SED=yes
  140. fi
  141. # Display the C++ version
  142. AC_MSG_CHECKING([C++ version])
  143. cat > conftest.cpp << EOF
  144. long v = __cplusplus;
  145. EOF
  146. CXX_STANDARD=`$CXX $CXXFLAGS -E -o - conftest.cpp | grep '^long v = ' | $SED -e 's/^long v = //' -e 's/[[^0-9]]*$//' 2> /dev/null`
  147. if test -z "$CXX_STANDARD"; then
  148. CXX_STANDARD="unknown"
  149. fi
  150. AC_MSG_RESULT([$CXX_STANDARD])
  151. # Linker options
  152. # check -R, "-Wl,-R" or -rpath
  153. AX_ISC_RPATH
  154. # Compiler dependent settings: define some mandatory CXXFLAGS here.
  155. # We also use a separate variable KEA_CXXFLAGS. This will (and should) be
  156. # used as the default value for each specific AM_CXXFLAGS:
  157. # AM_CXXFLAGS = $(KEA_CXXFLAGS)
  158. # AM_CXXFLAGS += ... # add module specific flags
  159. # We need this so that we can disable some specific compiler warnings per
  160. # module basis; since AM_CXXFLAGS are placed before CXXFLAGS, and since
  161. # gcc's -Wno-XXX option must be specified after -Wall or -Wextra, we cannot
  162. # specify the default warning flags in CXXFLAGS and let specific modules
  163. # "override" the default.
  164. # This may be used to try linker flags.
  165. AC_DEFUN([KEA_CXX_TRY_FLAG], [
  166. AC_MSG_CHECKING([whether $CXX supports $1])
  167. kea_save_CXXFLAGS="$CXXFLAGS"
  168. CXXFLAGS="$CXXFLAGS -Werror $1"
  169. AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){ return 0;}])],
  170. [kea_cxx_flag=yes], [kea_cxx_flag=no])
  171. CXXFLAGS="$kea_save_CXXFLAGS"
  172. if test "x$kea_cxx_flag" = "xyes"; then
  173. ifelse([$2], , :, [$2])
  174. else
  175. ifelse([$3], , :, [$3])
  176. fi
  177. AC_MSG_RESULT([$kea_cxx_flag])
  178. ])
  179. CXX_VERSION="unknown"
  180. # SunStudio compiler requires special compiler options for boost
  181. # (http://blogs.sun.com/sga/entry/boost_mini_howto)
  182. if test "$SUNCXX" = "yes"; then
  183. CXX_VERSION=`$CXX -V 2> /dev/null | head -1`
  184. CXXFLAGS="$CXXFLAGS -library=stlport4 -features=tmplife -features=tmplrefstatic"
  185. KEA_CXXFLAGS="$KEA_CXXFLAGS -mt"
  186. MULTITHREADING_FLAG="-mt"
  187. fi
  188. # Newer versions of clang++ promotes "unused driver arguments" warnings to
  189. # a fatal error with -Werror, causing build failure. Since we use multiple
  190. # compilers on multiple systems, this can easily happen due to settings for
  191. # non clang++ environments that could be just ignored otherwise. It can also
  192. # happen if clang++ is used via ccache. So, although probably suboptimal,
  193. # we suppress this particular warning. Note that it doesn't weaken checks
  194. # on the source code.
  195. if test "X$CLANGPP" = "Xyes"; then
  196. CXX_VERSION=`$CXX --version 2> /dev/null | head -1`
  197. KEA_CXXFLAGS="$KEA_CXXFLAGS -Qunused-arguments"
  198. fi
  199. # gcc/clang specific settings:
  200. if test "X$GXX" = "Xyes"; then
  201. CXX_VERSION=`$CXX --version 2> /dev/null | head -1`
  202. KEA_CXXFLAGS="$KEA_CXXFLAGS -Wall -Wextra -Wnon-virtual-dtor -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
  203. # gcc 4.4 would emit warnings about breaking strict aliasing rules.
  204. # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874
  205. CXX_DUMP_VERSION=`$CXX -dumpversion | cut -f1-2 -d.`
  206. if expr "$CXX_DUMP_VERSION" \< "4.5" > /dev/null; then
  207. WARNING_GCC_44_STRICT_ALIASING_CFLAG="-fno-strict-aliasing"
  208. fi
  209. AC_SUBST(WARNING_GCC_44_STRICT_ALIASING_CFLAG)
  210. case "$host" in
  211. *-solaris*)
  212. MULTITHREADING_FLAG=-pthreads
  213. # In Solaris, IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT need -Wno-missing-braces
  214. KEA_CXXFLAGS="$KEA_CXXFLAGS -Wno-missing-braces"
  215. ;;
  216. *-apple-darwin*)
  217. MULTITHREADING_FLAG=
  218. ;;
  219. *)
  220. MULTITHREADING_FLAG=-pthread
  221. ;;
  222. esac
  223. KEA_CXXFLAGS="$KEA_CXXFLAGS $MULTITHREADING_FLAG"
  224. # Disable -Werror by default. Only use it if specifically enabled.
  225. # The usage of this flag is:
  226. #
  227. # No flag: -Werror is disabled
  228. # --with-werror: -Werror is enabled
  229. # --with-werror=yes: -Werror is enabled
  230. # --with-werror=no: -Werror is disabled
  231. # --with-werror=value -Werror is enabled and "value" is included in the compiler flags
  232. #
  233. # In the last case, "value" may be one or more compiler flags, e.g.
  234. # --with-werror=-Wundef
  235. # --with-werror='-Wundef -Wconversion'
  236. werror_extras=
  237. AC_ARG_WITH(werror,
  238. AC_HELP_STRING([--with-werror], [Compile using -Werror (default=no)]),
  239. [
  240. case "${withval}" in
  241. yes) with_werror=1 ;;
  242. no) with_werror=0 ;;
  243. -*) with_werror=1; werror_extras=${withval} ;;
  244. *) AC_MSG_ERROR(bad value ${withval} for --with-werror) ;;
  245. esac],
  246. [with_werror=0])
  247. werror_ok=0
  248. # Certain versions of gcc (g++) have a bug that incorrectly warns about
  249. # the use of anonymous name spaces even if they're closed in a single
  250. # translation unit. For these versions we have to disable -Werror.
  251. if test $with_werror = 1; then
  252. CXXFLAGS_SAVED="$CXXFLAGS"
  253. CXXFLAGS="$CXXFLAGS $KEA_CXXFLAGS -Werror"
  254. AC_MSG_CHECKING(for in-TU anonymous namespace breakage)
  255. # We use struct, not class, here, because some compilers complain about
  256. # "unused private members", causing a false positive.
  257. AC_TRY_COMPILE([namespace { struct Foo {}; }
  258. namespace isc {struct Bar {Foo foo_;};} ],,
  259. [AC_MSG_RESULT(no)
  260. werror_ok=1
  261. KEA_CXXFLAGS="$KEA_CXXFLAGS -Werror"],
  262. [AC_MSG_RESULT(yes)])
  263. CXXFLAGS="$CXXFLAGS_SAVED"
  264. fi
  265. # Added flags after -Werror
  266. # Some versions of GCC warn about some versions of Boost regarding
  267. # missing initializer for members in its posix_time.
  268. # https://svn.boost.org/trac/boost/ticket/3477
  269. # But older GCC compilers don't have the flag.
  270. KEA_CXX_TRY_FLAG([-Wno-missing-field-initializers],
  271. [KEA_CXXFLAGS="$KEA_CXXFLAGS -Wno-missing-field-initializers"])
  272. if test "X$CLANGPP" = "Xyes"; then
  273. # This is to workaround unused variables tcout and tcerr in
  274. # log4cplus's streams.h and unused parameters from some of the
  275. # Boost headers.
  276. KEA_CXXFLAGS="$KEA_CXXFLAGS -Wno-unused-variable -Wno-unused-parameter"
  277. fi
  278. # Add the extras at the very last
  279. # Note it can be used to re-enable a (fatal) warning
  280. for extra in $werror_extras; do
  281. KEA_CXX_TRY_FLAG([$extra],
  282. [KEA_CXXFLAGS="$KEA_CXXFLAGS $extra"],
  283. [AC_MSG_ERROR([$CXX does not support $extra"])])
  284. done
  285. fi dnl GXX = yes
  286. # allow building programs with static link. we need to make it selective
  287. # because loadable modules cannot be statically linked.
  288. AC_ARG_ENABLE([static-link],
  289. AC_HELP_STRING([--enable-static-link],
  290. [build programs with static link [[default=no]]]),
  291. [enable_static_link=yes], [enable_static_link=no])
  292. AM_CONDITIONAL(USE_STATIC_LINK, test $enable_static_link = yes)
  293. AM_COND_IF([USE_STATIC_LINK], [AC_DEFINE([USE_STATIC_LINK], [1], [Was Kea statically linked?])])
  294. # Check validity about some libtool options
  295. if test $enable_static_link = yes -a $enable_static = no; then
  296. AC_MSG_ERROR([--enable-static-link requires --enable-static])
  297. fi
  298. if test $enable_static_link = no -a $enable_shared = no; then
  299. AC_MSG_ERROR([--disable-static-link requires --enable-shared])
  300. fi
  301. # OS dependent configuration
  302. kea_undefined_pthread_behavior=no
  303. case "$host" in
  304. *-solaris*)
  305. # Solaris requires special definitions to get some standard libraries
  306. # (e.g. getopt(3)) available with common used header files.
  307. CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
  308. # "now" binding is necessary to prevent deadlocks in C++ static initialization code
  309. LDFLAGS="$LDFLAGS -z now"
  310. # Destroying locked mutexes, condition variables being waited
  311. # on, etc. are undefined behavior on Solaris, so we set it as
  312. # such here.
  313. kea_undefined_pthread_behavior=yes
  314. ;;
  315. *-apple-darwin*)
  316. # Starting with OSX 10.7 (Lion) we must choose which IPv6 API to use
  317. # (RFC2292 or RFC3542).
  318. CPPFLAGS="$CPPFLAGS -D__APPLE_USE_RFC_3542"
  319. # In OS X 10.9 (and possibly any future versions?) pthread_cond_destroy
  320. # doesn't work as documented, which makes some of unit tests fail.
  321. AC_MSG_CHECKING([OS X versions where destroying locked locks do not fail])
  322. AC_TRY_COMPILE(
  323. [#include <Availability.h>],
  324. [#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
  325. #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
  326. #error " OS X >= 10.9"
  327. #endif
  328. #endif
  329. return 1;],
  330. [AC_MSG_RESULT([OS X < 10.9])],
  331. [AC_MSG_RESULT([OS X >= 10.9])
  332. kea_undefined_pthread_behavior=yes])
  333. ;;
  334. *-freebsd*)
  335. # On FreeBSD10.1 pthread_cond_destroy doesn't work as documented, which
  336. # causes the CondVarTest.destroyWhileWait test to fail. According to the
  337. # pthread_cond_destroy documentation for FreeBSD, this function should
  338. # return EBUSY error when there is a thread waiting for the conditional
  339. # variable, whereas this function returned success code. We treat it here
  340. # as an undefined behavior. Also note that this issue was only visible
  341. # when gtest 1.7 was in use, because the previous versions of gtest
  342. # didn't seem to have support for the death tests on FreeBSD. As a
  343. # result, the test was not executed and the error didn't occur.
  344. kea_undefined_pthread_behavior=yes
  345. ;;
  346. esac
  347. if [ test $kea_undefined_pthread_behavior = "yes" ]; then
  348. AC_DEFINE([HAS_UNDEFINED_PTHREAD_BEHAVIOR], [1], [Does this platform have some undefined pthreads behavior?])
  349. fi
  350. # Our experiments have shown Solaris 10 has broken support for the
  351. # IPV6_USE_MIN_MTU socket option for getsockopt(); it doesn't return the value
  352. # previously set via setsockopt(). We know it doesn't happen on one instance
  353. # on Solaris 11, but we don't know whether it happens for any Solaris 10
  354. # implementations or for earlier versions of Solaris. In any case, at the
  355. # moment this matters for only one unittest case, so we'll simply disable
  356. # the affected test using the following definition with the specific hardcoding
  357. # of that version of Solaris.
  358. case "$host" in
  359. *-solaris2.10)
  360. AC_DEFINE([HAVE_BROKEN_GET_IPV6_USE_MIN_MTU], [1],
  361. [Define to 1 if getsockopt(IPV6_USE_MIN_MTU) does not work])
  362. ;;
  363. esac
  364. m4_define([_AM_PYTHON_INTERPRETER_LIST], [python python3.4 python3.3 python3.2 python3.1 python3])
  365. AC_ARG_WITH([pythonpath],
  366. AC_HELP_STRING([--with-pythonpath=PATH],
  367. [specify an absolute path to python executable when automatic version check (incorrectly) fails]),
  368. [python_path="$withval"], [python_path="auto"])
  369. if test "$python_path" = auto; then
  370. AM_PATH_PYTHON([3.1],,[PYTHON=no])
  371. else
  372. # Older versions of automake can't handle python3 well. This is an
  373. # in-house workaround for them.
  374. PYTHON=$python_path
  375. AC_SUBST(PYTHON)
  376. PYTHON_PREFIX='${prefix}'
  377. AC_SUBST(PYTHON_PREFIX)
  378. PYTHON_EXEC_PREFIX='$(exec_prefix)'
  379. AC_SUBST(PYTHON_EXEC_PREFIX)
  380. PYTHON_VERSION=[`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"`]
  381. if test `echo "$PYTHON_VERSION >= 3.1" | bc` != 1 ; then
  382. AC_MSG_ERROR(["Python version too old: $PYTHON_VERSION, need 3.1 or higher"])
  383. fi
  384. AC_SUBST(PYTHON_VERSION)
  385. PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
  386. AC_SUBST(PYTHON_PLATFORM)
  387. pythondir='${prefix}/lib/python'$PYTHON_VERSION'/site-packages'
  388. AC_SUBST(pythondir)
  389. pkgpythondir='${pythondir}/'$PACKAGE
  390. AC_SUBST(pkgpythondir)
  391. pyexecdir='${exec_prefix}/lib/python'$PYTHON_VERSION'/site-packages'
  392. AC_SUBST(pyexecdir)
  393. pkgpyexecdir='${pyexecdir}/'$PACKAGE
  394. AC_SUBST(pkgpyexecdir)
  395. fi
  396. # produce PIC unless we disable shared libraries. need this for python bindings.
  397. if test $enable_shared != "no" -a "X$GXX" = "Xyes"; then
  398. KEA_CXXFLAGS="$KEA_CXXFLAGS -fPIC"
  399. fi
  400. AC_SUBST(KEA_CXXFLAGS)
  401. # Checks for libraries.
  402. AC_SEARCH_LIBS(inet_pton, [nsl])
  403. AC_SEARCH_LIBS(recvfrom, [socket])
  404. AC_SEARCH_LIBS(nanosleep, [rt])
  405. AC_SEARCH_LIBS(dlsym, [dl])
  406. # Checks for header files.
  407. # Checks for typedefs, structures, and compiler characteristics.
  408. AC_HEADER_STDBOOL
  409. AC_TYPE_SIZE_T
  410. # Detect OS type (it may be used to do OS-specific things, e.g.
  411. # interface detection in DHCP)
  412. AC_MSG_CHECKING(OS type)
  413. BSD_TYPE="notaBSD"
  414. case $host in
  415. *-linux*)
  416. AC_DEFINE([OS_LINUX], [1], [Running on Linux?])
  417. OS_TYPE="Linux"
  418. CPPFLAGS="$CPPFLAGS -DOS_LINUX"
  419. ;;
  420. *-apple-darwin*)
  421. AC_DEFINE([OS_BSD], [1], [Running on BSD?])
  422. AC_DEFINE([OS_OSX], [1], [Running on OSX?])
  423. OS_TYPE="BSD"
  424. BSD_TYPE="OSX"
  425. CPPFLAGS="$CPPFLAGS -DOS_BSD"
  426. ;;
  427. *-freebsd*)
  428. AC_DEFINE([OS_BSD], [1], [Running on BSD?])
  429. AC_DEFINE([OS_FREEBSD], [1], [Running on FreeBSD?])
  430. OS_TYPE="BSD"
  431. BSD_TYPE="FreeBSD"
  432. CPPFLAGS="$CPPFLAGS -DOS_BSD"
  433. ;;
  434. *-netbsd*)
  435. AC_DEFINE([OS_BSD], [1], [Running on BSD?])
  436. AC_DEFINE([OS_NETBSD], [1], [Running on NetBSD?])
  437. OS_TYPE="BSD"
  438. BSD_TYPE="NetBSD"
  439. CPPFLAGS="$CPPFLAGS -DOS_BSD"
  440. ;;
  441. *-openbsd*)
  442. AC_DEFINE([OS_BSD], [1], [Running on BSD?])
  443. AC_DEFINE([OS_OPENBSD], [1], [Running on OpenBSD?])
  444. OS_TYPE="BSD"
  445. BSD_TYPE="OpenBSD"
  446. CPPFLAGS="$CPPFLAGS -DOS_BSD"
  447. ;;
  448. *-solaris*)
  449. AC_DEFINE([OS_SOLARIS], [1], [Running on Solaris?])
  450. OS_TYPE="Solaris"
  451. CPPFLAGS="$CPPFLAGS -DOS_SUN"
  452. ;;
  453. *)
  454. OS_TYPE="Unknown"
  455. # $host_os is more user friendly than full $host
  456. AC_MSG_WARN("Unsupported OS: $host_os")
  457. ;;
  458. esac
  459. AC_MSG_RESULT($OS_TYPE)
  460. AM_CONDITIONAL(OS_LINUX, test $OS_TYPE = Linux)
  461. AM_CONDITIONAL(OS_BSD, test $OS_TYPE = BSD)
  462. AM_CONDITIONAL(OS_SOLARIS, test $OS_TYPE = Solaris)
  463. AM_CONDITIONAL(OS_OSX, test $BSD_TYPE = OSX)
  464. AM_CONDITIONAL(OS_FREEBSD, test $BSD_TYPE = FreeBSD)
  465. AM_CONDITIONAL(OS_NETBSD, test $BSD_TYPE = NetBSD)
  466. AM_CONDITIONAL(OS_OPENBSD, test $BSD_TYPE = OpenBSD)
  467. AC_MSG_CHECKING(for sa_len in struct sockaddr)
  468. AC_TRY_COMPILE([
  469. #include <sys/types.h>
  470. #include <sys/socket.h>],
  471. [struct sockaddr sa; sa.sa_len = 0; return (0);],
  472. [AC_MSG_RESULT(yes)
  473. AC_DEFINE(HAVE_SA_LEN, 1, [Define to 1 if sockaddr has a sa_len member, and corresponding sin_len and sun_len])],
  474. AC_MSG_RESULT(no))
  475. enable_gtest="no"
  476. GTEST_INCLUDES=
  477. AC_ARG_WITH([gtest-source],
  478. [AS_HELP_STRING([--with-gtest-source=PATH],
  479. [location of the Googletest source])],
  480. [enable_gtest="yes" ; GTEST_SOURCE="$withval"])
  481. AC_ARG_WITH([gtest],
  482. [AS_HELP_STRING([--with-gtest=PATH],
  483. [specify a path to gtest header files (PATH/include) and library (PATH/lib)])],
  484. [gtest_path="$withval"; enable_gtest="yes"], [gtest_path="no"])
  485. AC_ARG_WITH(lcov,
  486. [ --with-lcov[=PROGRAM] enable gtest and coverage target using the specified lcov], lcov="$withval", lcov="no")
  487. USE_LCOV="no"
  488. if test "$lcov" != "no"; then
  489. # force gtest if not set
  490. if test "$enable_gtest" = "no"; then
  491. # AC_MSG_ERROR("lcov needs gtest for test coverage report")
  492. AC_MSG_NOTICE([gtest support is now enabled, because used by coverage tests])
  493. enable_gtest="yes"
  494. fi
  495. if test "$lcov" != "yes"; then
  496. LCOV=$lcov
  497. else
  498. AC_PATH_PROG([LCOV], [lcov])
  499. fi
  500. if test -x "${LCOV}"; then
  501. USE_LCOV="yes"
  502. else
  503. AC_MSG_ERROR([Cannot find lcov.])
  504. fi
  505. # is genhtml always in the same directory?
  506. GENHTML=`echo "$LCOV" | ${SED} s/lcov$/genhtml/`
  507. if test ! -x $GENHTML; then
  508. AC_MSG_ERROR([genhtml not found, needed for lcov])
  509. fi
  510. # GCC specific?
  511. CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
  512. LIBS=" $LIBS -lgcov"
  513. AC_SUBST(CPPFLAGS)
  514. AC_SUBST(LIBS)
  515. AC_SUBST(LCOV)
  516. AC_SUBST(GENHTML)
  517. fi
  518. AC_SUBST(USE_LCOV)
  519. # Simplified, non-caching AC_CHECK_PROG
  520. # Searches $PATH for the existence of argument 2,
  521. # and sets the full path to the variable in argument 1.
  522. # if not found, and a third argument is given, the value
  523. # is set to that. If not, the value is untouched.
  524. # Does not take absolute paths into account at this point,
  525. # and also works for single files only (arguments are not
  526. # stripped like in AC_CHECK_PROG)
  527. AC_DEFUN([ACX_CHECK_PROG_NONCACHE], [
  528. RESULT=""
  529. IFS_SAVED="$IFS"
  530. IFS=${PATH_SEPARATOR}
  531. for cur_path in ${PATH} ; do
  532. if test -e "${cur_path}/$2" ; then
  533. RESULT="${cur_path}/$2"
  534. fi
  535. done
  536. if test "$RESULT" = "" ; then
  537. :
  538. m4_ifvaln([$3], [$1=$3])
  539. else
  540. $1=$RESULT
  541. fi
  542. IFS="$IFS_SAVED"
  543. ])
  544. # Avoid checking Botan if OpenSSL is wanted
  545. AC_ARG_WITH([openssl],
  546. [AS_HELP_STRING([--with-openssl[[=PATH]]], [Enables OpenSSL,
  547. location can be specified optionally])],
  548. [use_openssl="$withval"],
  549. [use_openssl="auto"])
  550. # Botan helper test function
  551. # Tries to compile a botan program, given the output of the given
  552. # config tool
  553. # Arguments:
  554. # - name of tool (checked for path), must support --libs and --cflags
  555. # - fixed argument(s) for tool
  556. # - action if successful
  557. AC_DEFUN([ACX_TRY_BOTAN_TOOL], [
  558. TOOL=$1
  559. TOOL_ARG=$2
  560. BOTAN_TOOL=""
  561. ACX_CHECK_PROG_NONCACHE([BOTAN_TOOL], [${TOOL}])
  562. AC_MSG_CHECKING([usability of ${TOOL} ${TOOL_ARG}])
  563. if test "$BOTAN_TOOL" != "" ; then
  564. if test -x ${BOTAN_TOOL}; then
  565. CRYPTO_LIBS=`$BOTAN_TOOL $TOOL_ARG --libs`
  566. LIBS_SAVED=${LIBS}
  567. LIBS="$LIBS $CRYPTO_LIBS"
  568. CRYPTO_INCLUDES=`$BOTAN_TOOL $TOOL_ARG --cflags`
  569. CPPFLAGS_SAVED=${CPPFLAGS}
  570. CPPFLAGS="$CRYPTO_INCLUDES $CPPFLAGS"
  571. #AC_MSG_RESULT([found])
  572. AC_LINK_IFELSE(
  573. [AC_LANG_PROGRAM([#include <botan/botan.h>
  574. #include <botan/hash.h>
  575. ],
  576. [using namespace Botan;
  577. LibraryInitializer::initialize();
  578. HashFunction *h = get_hash("MD5");
  579. ])],
  580. [ AC_MSG_RESULT([ok])
  581. $3
  582. ],
  583. [ AC_MSG_RESULT([not usable]) ]
  584. )
  585. LIBS=${LIBS_SAVED}
  586. CPPFLAGS=${CPPFLAGS_SAVED}
  587. else
  588. AC_MSG_RESULT([not executable])
  589. fi
  590. else
  591. AC_MSG_RESULT([not found])
  592. fi
  593. BOTAN_TOOL=""
  594. AC_SUBST(BOTAN_TOOL)
  595. ]
  596. )
  597. # Check for Botan
  598. #
  599. # Unless --with-botan-config is given, we first try to find these config
  600. # scripts ourselves. Unfortunately, on some systems, these scripts do not
  601. # provide the correct implementation, so for each script found, we try
  602. # a compilation test (ACX_TRY_BOTAN_TOOL). If none are found, or none of
  603. # them work, we see if pkg-config is available. If so, we try the several
  604. # potential pkg-config .pc files. Again, on some systems, these can return
  605. # incorrect information as well, so the try-compile test is repeated for
  606. # each.
  607. #
  608. # If a working config script or pkgconfig file is found, we then munge its
  609. # output for use in our Makefiles, and to make sure it works, another header
  610. # and compilation test is done (this should also check whether we can compile
  611. # against botan should neither -config scripts nor pkgconfig data exist).
  612. #
  613. botan_config="yes"
  614. if test "${use_openssl}" != "auto" -a "${use_openssl}" != "no" ; then
  615. botan_config="no"
  616. fi
  617. AC_ARG_WITH([botan-config],
  618. AC_HELP_STRING([--with-botan-config=PATH],
  619. [specify the path to the botan-config script]),
  620. [botan_config="$withval"])
  621. distcheck_botan="--with-botan-config=$botan_config"
  622. if test "${botan_config}" = "no" ; then
  623. if test "${use_openssl}" = "no" ; then
  624. AC_MSG_ERROR([Need Botan or OpenSSL for libcryptolink])
  625. fi
  626. elif test "${botan_config}" != "yes" ; then
  627. if test -x "${botan_config}" ; then
  628. if test -d "${botan_config}" ; then
  629. AC_MSG_ERROR([${botan_config} is a directory])
  630. else
  631. BOTAN_CONFIG="${botan_config}"
  632. fi
  633. else
  634. AC_MSG_ERROR([--with-botan-config should point to a botan-config program and not a directory (${botan_config})])
  635. fi
  636. else
  637. BOTAN_CONFIG=""
  638. # first try several possible names of the config script
  639. # (botan-config-1.8 is there just in case, the official name change
  640. # came later)
  641. BOTAN_CONFIG_VERSIONS="botan-config-1.10 botan-config-1.9 botan-config-1.8 botan-config"
  642. for botan_config in $BOTAN_CONFIG_VERSIONS; do
  643. ACX_TRY_BOTAN_TOOL([$botan_config],,
  644. [ BOTAN_CONFIG="$botan_config" ]
  645. )
  646. if test "$BOTAN_CONFIG" != "" ; then
  647. break
  648. fi
  649. done
  650. if test "$BOTAN_CONFIG" = "" ; then
  651. AC_PATH_PROG([PKG_CONFIG], [pkg-config])
  652. if test "$PKG_CONFIG" != "" ; then
  653. # Ok so no script found, see if pkg-config knows of it.
  654. # Unfortunately, the botan.pc files also have their minor version
  655. # in their name, so we need to try them one by one
  656. BOTAN_VERSIONS="botan-1.10 botan-1.9 botan-1.8"
  657. for version in $BOTAN_VERSIONS; do
  658. ACX_TRY_BOTAN_TOOL([pkg-config], ["$version --silence-errors"],
  659. [ BOTAN_CONFIG="$PKG_CONFIG $version" ]
  660. )
  661. if test "$BOTAN_CONFIG" != "" ; then
  662. break
  663. fi
  664. done
  665. fi
  666. fi
  667. fi
  668. if test "x${BOTAN_CONFIG}" != "x"
  669. then
  670. CRYPTO_LIBS=`${BOTAN_CONFIG} --libs`
  671. CRYPTO_INCLUDES=`${BOTAN_CONFIG} --cflags`
  672. # We expect botan-config --libs to contain -L<path_to_libbotan>, but
  673. # this is not always the case. As a heuristics workaround we add
  674. # -L`botan-config --prefix/lib` in this case (if not present already).
  675. # Same for CRYPTO_INCLUDES (but using include instead of lib) below.
  676. if [ ${BOTAN_CONFIG} --prefix >/dev/null 2>&1 ] ; then
  677. echo ${CRYPTO_LIBS} | grep -- -L > /dev/null || \
  678. CRYPTO_LIBS="-L`${BOTAN_CONFIG} --prefix`/lib ${CRYPTO_LIBS}"
  679. echo ${CRYPTO_INCLUDES} | grep -- -I > /dev/null || \
  680. CRYPTO_INCLUDES="-I`${BOTAN_CONFIG} --prefix`/include ${CRYPTO_INCLUDES}"
  681. fi
  682. fi
  683. if test "x${CRYPTO_LIBS}" != "x"
  684. then
  685. dnl Determine the Botan version
  686. AC_MSG_CHECKING([Botan version])
  687. cat > conftest.cpp << EOF
  688. #include <botan/version.h>
  689. AUTOCONF_BOTAN_VERSION=BOTAN_VERSION_MAJOR . BOTAN_VERSION_MINOR . BOTAN_VERSION_PATCH
  690. EOF
  691. CRYPTO_VERSION=`$CPP $CPPFLAGS $CRYPTO_INCLUDES conftest.cpp | grep '^AUTOCONF_BOTAN_VERSION=' | $SED -e 's/^AUTOCONF_BOTAN_VERSION=//' -e 's/[[ ]]//g' -e 's/"//g' 2> /dev/null`
  692. if test -z "$CRYPTO_VERSION"; then
  693. CRYPTO_VERSION="unknown"
  694. fi
  695. $RM -f conftest.cpp
  696. AC_MSG_RESULT([$CRYPTO_VERSION])
  697. # botan-config script (and the way we call pkg-config) returns -L and -l
  698. # as one string, but we need them in separate values
  699. CRYPTO_LDFLAGS=
  700. for flag in ${CRYPTO_LIBS}; do
  701. CRYPTO_LDFLAGS="${CRYPTO_LDFLAGS} `echo $flag | ${SED} -ne '/^\(\-L\)/p'`"
  702. CRYPTO_LIBS="${CRYPTO_LIBS} `echo $flag | ${SED} -ne '/^\(\-l\)/p'`"
  703. done
  704. # See crypto_rpath for some info on why we do this
  705. if test "x$ISC_RPATH_FLAG" != "x"; then
  706. CRYPTO_RPATH=
  707. for flag in ${CRYPTO_LIBS}; do
  708. CRYPTO_RPATH="${CRYPTO_RPATH} `echo $flag | ${SED} -ne "s/^\(\-L\)/${ISC_RPATH_FLAG}/p"`"
  709. done
  710. # According to the libtool manual, it should be sufficient if we
  711. # specify the "-R libdir" in our wrapper library of botan (no other
  712. # programs will need libbotan directly); "libdir" should be added to
  713. # the program's binary image. But we've seen in our build environments
  714. # that (some versions of?) libtool doesn't propagate -R as documented,
  715. # and it caused a linker error at run time. To work around this, we
  716. # also add the rpath to the global LDFLAGS.
  717. LDFLAGS="$CRYPTO_RPATH $LDFLAGS"
  718. fi
  719. # Even though chances are high we already performed a real compilation check
  720. # in the search for the right (pkg)config data, we try again here, to
  721. # be sure.
  722. CPPFLAGS_SAVED=$CPPFLAGS
  723. CPPFLAGS="$CRYPTO_INCLUDES $CPPFLAGS"
  724. LIBS_SAVED="$LIBS"
  725. LIBS="$LIBS $CRYPTO_LIBS"
  726. # ac_header_preproc is an autoconf symbol (undocumented but stable) that
  727. # is set if the pre-processor phase passes. Thus by adding a custom
  728. # failure handler we can detect the difference between a header not existing
  729. # (or not even passing the pre-processor phase) and a header file resulting
  730. # in compilation failures.
  731. AC_CHECK_HEADERS([botan/botan.h],,[
  732. CRYPTO_INCLUDES=""
  733. CRYPTO_LIBS=""
  734. CRYPTO_LDFLAGS=""
  735. CRYPTO_RPATH=""
  736. if test "x$ac_header_preproc" = "xyes"; then
  737. AC_MSG_RESULT([
  738. botan/botan.h was found but is unusable. The most common cause of this problem
  739. is attempting to use an updated C++ compiler with older C++ libraries, such as
  740. the version of Botan that comes with your distribution. If you have updated
  741. your C++ compiler we highly recommend that you use support libraries such as
  742. Boost and Botan that were compiled with the same compiler version.])
  743. else
  744. AC_MSG_RESULT([Missing required header files.])
  745. fi]
  746. )
  747. CPPFLAGS=$CPPFLAGS_SAVED
  748. LIBS=$LIBS_SAVED
  749. fi
  750. if test "x${CRYPTO_LIBS}" != "x"
  751. then
  752. CPPFLAGS_SAVED=$CPPFLAGS
  753. CPPFLAGS="$CRYPTO_INCLUDES $CPPFLAGS"
  754. LIBS_SAVED="$LIBS"
  755. LIBS="$LIBS $CRYPTO_LIBS"
  756. AC_LINK_IFELSE(
  757. [AC_LANG_PROGRAM([#include <botan/botan.h>
  758. #include <botan/hash.h>
  759. ],
  760. [using namespace Botan;
  761. LibraryInitializer::initialize();
  762. HashFunction *h = get_hash("MD5");
  763. ])],
  764. [AC_MSG_RESULT([checking for Botan library... yes])],
  765. [AC_MSG_RESULT([checking for Botan library... no])
  766. CRYPTO_INCLUDES=""
  767. CRYPTO_LIBS=""
  768. CRYPTO_LDFLAGS=""
  769. CRYPTO_RPATH=""
  770. AC_MSG_RESULT([Needs Botan library 1.8 or higher. On some systems,
  771. the botan package has a few missing dependencies (libbz2 and
  772. libgmp), if libbotan has been installed and you see this message,
  773. try upgrading to a higher version of botan or installing libbz2
  774. and libgmp.])]
  775. )
  776. CPPFLAGS=$CPPFLAGS_SAVED
  777. LIBS=$LIBS_SAVED
  778. fi
  779. if test "x${CRYPTO_LIBS}" != "x"
  780. then
  781. CRYPTO_NAME="Botan"
  782. DISABLED_CRYPTO="OpenSSL"
  783. CRYPTO_PACKAGE="botan-1.8"
  784. CRYPTO_CFLAGS=""
  785. DISTCHECK_CRYPTO_CONFIGURE_FLAG="$distcheck_botan"
  786. AC_DEFINE_UNQUOTED([WITH_BOTAN], [], [Compile with Botan crypto])
  787. else
  788. CRYPTO_NAME="OpenSSL"
  789. DISABLED_CRYPTO="Botan"
  790. CRYPTO_PACKAGE="openssl-1.0.1"
  791. AC_DEFINE_UNQUOTED([WITH_OPENSSL], [], [Compile with OpenSSL crypto])
  792. AC_MSG_CHECKING(for OpenSSL library)
  793. # from bind9
  794. if test "${use_openssl}" = "auto" ; then
  795. use_openssl="yes"
  796. fi
  797. if test "${use_openssl}" = "yes" ; then
  798. for d in /usr /usr/local /usr/local/ssl /usr/pkg /usr/sfw; do
  799. if test -f $d/include/openssl/opensslv.h; then
  800. use_openssl=$d; break
  801. fi
  802. done
  803. fi
  804. if test "${use_openssl}" = "yes" ; then
  805. AC_MSG_ERROR([OpenSSL auto detection failed])
  806. fi
  807. if ! test -f "${use_openssl}"/include/openssl/opensslv.h ; then
  808. AC_MSG_ERROR([OpenSSL not found at ${use_openssl}])
  809. fi
  810. AC_MSG_RESULT(yes)
  811. if test "${use_openssl}" = "/usr" ; then
  812. CRYPTO_CFLAGS=""
  813. CRYPTO_INCLUDES=""
  814. CRYPTO_LIBS="-lcrypto"
  815. DISTCHECK_CRYPTO_CONFIGURE_FLAG="--with-openssl"
  816. else
  817. CRYPTO_CFLAGS=""
  818. CRYPTO_INCLUDES="-I${use_openssl}/include"
  819. DISTCHECK_CRYPTO_CONFIGURE_FLAG="--with-openssl=${use_openssl}"
  820. case $host in
  821. *-solaris*)
  822. CRYPTO_LIBS="-L${use_openssl}/lib -R${use_openssl}/lib -lcrypto"
  823. ;;
  824. *-hp-hpux*)
  825. CRYPTO_LIBS="-L${use_openssl}/lib -Wl,+b: -lcrypto"
  826. ;;
  827. *-apple-darwin*)
  828. if test -f "${use_openssl}/lib/libcrypto.dylib" ; then
  829. CRYPTO_LIBS="-L${use_openssl}/lib -lcrypto"
  830. else
  831. CRYPTO_LIBS="${use_openssl}/lib/libcrypto.a"
  832. fi
  833. ;;
  834. *)
  835. CRYPTO_LIBS="-L${use_openssl}/lib -lcrypto"
  836. ;;
  837. esac
  838. fi
  839. dnl Determine the OpenSSL version
  840. # Officially we support >= 1.0.1, 0.9.8 should fail the HMAC API,
  841. # 1.0.0 could work but is not recommended.
  842. AC_MSG_CHECKING([OpenSSL version])
  843. cat > conftest.cpp << EOF
  844. #include <openssl/opensslv.h>
  845. AUTOCONF_OPENSSL_VERSION=OPENSSL_VERSION_TEXT
  846. EOF
  847. CRYPTO_VERSION=`$CPP $CPPFLAGS $CRYPTO_INCLUDES conftest.cpp | grep '^AUTOCONF_OPENSSL_VERSION=' | $SED -e 's/^AUTOCONF_OPENSSL_VERSION=//' -e 's/"//g' 2> /dev/null`
  848. if test -z "$CRYPTO_VERSION" ; then
  849. CRYPTO_VERSION="unknown"
  850. fi
  851. $RM -f conftest.cpp
  852. AC_MSG_RESULT([$CRYPTO_VERSION])
  853. #CRYPTO_LDFLAGS="-ldl"
  854. CRYPTO_LDFLAGS=""
  855. CRYPTO_RPATH=""
  856. dnl Check avaibility of SHA-2
  857. AC_MSG_CHECKING([support of SHA-2])
  858. LIBS_SAVED=${LIBS}
  859. LIBS="$LIBS $CRYPTO_LIBS"
  860. CPPFLAGS_SAVED=${CPPFLAGS}
  861. CPPFLAGS="$CRYPTO_INCLUDES $CPPFLAGS"
  862. AC_LINK_IFELSE(
  863. [AC_LANG_PROGRAM([#include <openssl/evp.h>],
  864. [const EVP_MD* h224 = EVP_sha224();
  865. const EVP_MD* h256 = EVP_sha256();
  866. const EVP_MD* h384 = EVP_sha384();
  867. const EVP_MD* h512 = EVP_sha512();
  868. ])],
  869. [AC_MSG_RESULT([yes])],
  870. [AC_MSG_ERROR([missing EVP entry for SHA-2])])
  871. dnl Check HMAC API
  872. AC_MSG_CHECKING([HMAC functions returning ints])
  873. AC_LINK_IFELSE(
  874. [AC_LANG_PROGRAM([#include <openssl/hmac.h>],
  875. [HMAC_CTX ctx, tmp;
  876. int n = HMAC_Init(&ctx, NULL, 0, NULL);
  877. n += HMAC_Update(&ctx, NULL, 0);
  878. n += HMAC_CTX_copy(&tmp, &ctx);
  879. n += HMAC_Final(&tmp, NULL, NULL);
  880. ])],
  881. [AC_MSG_RESULT([yes])],
  882. [AC_MSG_ERROR([HMAC functions return void: the OpenSSL version should be too old, please change for >= 1.0.1])])
  883. LIBS=${LIBS_SAVED}
  884. CPPFLAGS=${CPPFLAGS_SAVED}
  885. fi
  886. AM_CONDITIONAL(HAVE_BOTAN, test "$CRYPTO_NAME" = "Botan")
  887. AM_CONDITIONAL(HAVE_OPENSSL, test "$CRYPTO_NAME" = "OpenSSL")
  888. AC_SUBST(CRYPTO_INCLUDES)
  889. AC_SUBST(CRYPTO_CFLAGS)
  890. AC_SUBST(CRYPTO_LIBS)
  891. AC_SUBST(CRYPTO_LDFLAGS)
  892. AC_SUBST(CRYPTO_PACKAGE)
  893. AC_SUBST(CRYPTO_RPATH)
  894. AC_SUBST(DISTCHECK_CRYPTO_CONFIGURE_FLAG)
  895. # Check for MySql. The path to the mysql_config program is given with
  896. # the --with-mysql-config (default to /usr/bin/mysql-config). By default,
  897. # the software is not built with MySQL support enabled.
  898. mysql_config="no"
  899. AC_ARG_WITH([dhcp-mysql],
  900. AC_HELP_STRING([--with-dhcp-mysql=PATH],
  901. [path to the MySQL 'mysql_config' script (MySQL is used for the DHCP database)]),
  902. [mysql_config="$withval"])
  903. if test "${mysql_config}" = "yes" ; then
  904. MYSQL_CONFIG="/usr/bin/mysql_config"
  905. elif test "${mysql_config}" != "no" ; then
  906. MYSQL_CONFIG="${withval}"
  907. fi
  908. if test "$MYSQL_CONFIG" != "" ; then
  909. if test -d "$MYSQL_CONFIG" -o ! -x "$MYSQL_CONFIG" ; then
  910. AC_MSG_ERROR([--with-dhcp-mysql should point to a mysql_config program])
  911. fi
  912. MYSQL_CPPFLAGS=`$MYSQL_CONFIG --cflags`
  913. MYSQL_LIBS=`$MYSQL_CONFIG --libs`
  914. MYSQL_VERSION=`$MYSQL_CONFIG --version`
  915. AC_SUBST(MYSQL_CPPFLAGS)
  916. AC_SUBST(MYSQL_LIBS)
  917. # Check that a simple program using MySQL functions can compile and link.
  918. CPPFLAGS_SAVED="$CPPFLAGS"
  919. LIBS_SAVED="$LIBS"
  920. CPPFLAGS="$MYSQL_CPPFLAGS $CPPFLAGS"
  921. LIBS="$MYSQL_LIBS $LIBS"
  922. AC_LINK_IFELSE(
  923. [AC_LANG_PROGRAM([#include <mysql.h>],
  924. [MYSQL mysql_handle;
  925. (void) mysql_init(&mysql_handle);
  926. ])],
  927. [AC_MSG_RESULT([checking for MySQL headers and library... yes])],
  928. [AC_MSG_RESULT([checking for MySQL headers and library... no])
  929. AC_MSG_ERROR([Needs MySQL library])]
  930. )
  931. CPPFLAGS=$CPPFLAGS_SAVED
  932. LIBS=$LIBS_SAVED
  933. # Note that MYSQL is present in the config.h file
  934. AC_DEFINE([HAVE_MYSQL], [1], [MySQL is present])
  935. fi
  936. # Solaris puts FIONREAD in filio.h
  937. AC_CHECK_HEADERS(sys/filio.h,,,)
  938. # ... and at the shell level, so Makefile.am can take action depending on this.
  939. AM_CONDITIONAL(HAVE_MYSQL, test "$MYSQL_CONFIG" != "")
  940. pg_config="no"
  941. AC_ARG_WITH([dhcp-pgsql],
  942. AC_HELP_STRING([--with-dhcp-pgsql=PATH],
  943. [path to the PostgreSQL 'pg_config' script]),
  944. [pg_config="$withval"])
  945. if test "${pg_config}" = "yes" ; then
  946. PG_CONFIG="/usr/bin/pg_config"
  947. elif test "${pg_config}" != "no" ; then
  948. PG_CONFIG="${withval}"
  949. fi
  950. if test "$PG_CONFIG" != "" ; then
  951. if test -d "$PG_CONFIG" -o ! -x "$PG_CONFIG" ; then
  952. AC_MSG_ERROR([--with-dhcp-pgsql should point to a pg_config program])
  953. fi
  954. PGSQL_CPPFLAGS=`$PG_CONFIG --cppflags`
  955. PGSQL_INCLUDEDIR=`$PG_CONFIG --includedir`
  956. PGSQL_INCLUDEDIR_SERVER=`$PG_CONFIG --includedir-server`
  957. PGSQL_CPPFLAGS="$PGSQL_CPPFLAGS -I$PGSQL_INCLUDEDIR -I$PGSQL_INCLUDEDIR_SERVER"
  958. PGSQL_LIBS=`$PG_CONFIG --libdir`
  959. PGSQL_LIBS="-L$PGSQL_LIBS -lpq"
  960. PGSQL_VERSION=`$PG_CONFIG --version`
  961. AC_SUBST(PGSQL_CPPFLAGS)
  962. AC_SUBST(PGSQL_LIBS)
  963. # Check that a simple program using PostgreSQL functions can compile and link.
  964. CPPFLAGS_SAVED="$CPPFLAGS"
  965. LIBS_SAVED="$LIBS"
  966. CPPFLAGS="$PGSQL_CPPFLAGS $CPPFLAGS"
  967. LIBS="$PGSQL_LIBS $LIBS"
  968. AC_LINK_IFELSE(
  969. [AC_LANG_PROGRAM([#include <libpq-fe.h>],
  970. [PGconn * c = PQconnectdb("dbname = 'postgres'");
  971. PQfinish(c);])],
  972. [AC_MSG_RESULT([checking for PostgreSQL headers and library... yes])],
  973. [AC_MSG_RESULT([checking for PostgreSQL headers and library... no])
  974. AC_MSG_ERROR([Needs PostgreSQL library])]
  975. )
  976. AC_CHECK_HEADERS([utils/errcodes.h],,
  977. AC_MSG_ERROR([Missing required header file (errcodes.h) from PostgreSQL server-development package]))
  978. CPPFLAGS=$CPPFLAGS_SAVED
  979. LIBS=$LIBS_SAVED
  980. # Note that PostgreSQL is present in the config.h file
  981. AC_DEFINE([HAVE_PGSQL], [1], [PostgreSQL is present])
  982. fi
  983. # ... and at the shell level, so Makefile.am can take action depending on this.
  984. AM_CONDITIONAL(HAVE_PGSQL, test "$PG_CONFIG" != "")
  985. cql_config="no"
  986. AC_ARG_WITH([cql],
  987. AC_HELP_STRING([--with-cql=PATH],
  988. [path to the Cassandra CQL 'cql_config' script]),
  989. [cql_config="$withval"])
  990. if test "${cql_config}" = "yes" ; then
  991. cql_config="/usr/bin/cql_config"
  992. elif test "${cql_config}" != "no" ; then
  993. CQL_CONFIG="${withval}"
  994. fi
  995. if test "$CQL_CONFIG" != "" ; then
  996. if test -d "$CQL_CONFIG" -o ! -x "$CQL_CONFIG" ; then
  997. AC_MSG_ERROR([--with-cql should point to a cql_config program])
  998. fi
  999. CQL_INCLUDEDIR=`$CQL_CONFIG --includedir`
  1000. CQL_CPPFLAGS="`$CQL_CONFIG --cppflags` -I$CQL_INCLUDEDIR"
  1001. CQL_LIBS="-L`$CQL_CONFIG --libdir` -lcassandra_static -luv"
  1002. CQL_VERSION=`$CQL_CONFIG --version`
  1003. AC_SUBST(CQL_CPPFLAGS)
  1004. AC_SUBST(CQL_LIBS)
  1005. # Check that a simple program using CQL functions can compile and link.
  1006. CPPFLAGS_SAVED="$CPPFLAGS"
  1007. LIBS_SAVED="$LIBS"
  1008. CPPFLAGS="$CQL_CPPFLAGS $CPPFLAGS"
  1009. LIBS="$CQL_LIBS $LIBS"
  1010. AC_LINK_IFELSE(
  1011. [AC_LANG_PROGRAM([#include <cassandra.h>],
  1012. [CassCluster* cluster = cass_cluster_new();
  1013. cass_cluster_free(cluster);])],
  1014. [AC_MSG_RESULT([checking for Cassandra CQL headers and library... yes])],
  1015. [AC_MSG_RESULT([checking for Cassandra CQL headers and library... no])
  1016. AC_MSG_ERROR([Needs Cassandra CQL library])]
  1017. )
  1018. CPPFLAGS=$CPPFLAGS_SAVED
  1019. LIBS=$LIBS_SAVED
  1020. # Note that CQL is present in the config.h file
  1021. AC_DEFINE([HAVE_CQL], [1], [CQL is present])
  1022. fi
  1023. # ... and at the shell level, so Makefile.am can take action depending on this.
  1024. AM_CONDITIONAL(HAVE_CQL, test "$CQL_CONFIG" != "")
  1025. # Check for log4cplus
  1026. log4cplus_path="yes"
  1027. AC_ARG_WITH([log4cplus],
  1028. AC_HELP_STRING([--with-log4cplus=PATH],
  1029. [specify exact directory of log4cplus library and headers]),
  1030. [log4cplus_path="$withval"])
  1031. if test "${log4cplus_path}" = "no" ; then
  1032. AC_MSG_ERROR([Need log4cplus])
  1033. elif test "${log4cplus_path}" != "yes" ; then
  1034. LOG4CPLUS_INCLUDES="-I${log4cplus_path}/include"
  1035. LOG4CPLUS_LIBS="-L${log4cplus_path}/lib"
  1036. else
  1037. # If not specified, try some common paths.
  1038. log4cplusdirs="/usr /usr/local /usr/pkg /opt /opt/local"
  1039. for d in $log4cplusdirs
  1040. do
  1041. if test -f $d/include/log4cplus/logger.h; then
  1042. LOG4CPLUS_INCLUDES="-I$d/include"
  1043. LOG4CPLUS_LIBS="-L$d/lib -L$d/lib64"
  1044. break
  1045. fi
  1046. done
  1047. fi
  1048. LOG4CPLUS_LIBS="$LOG4CPLUS_LIBS -llog4cplus"
  1049. AC_SUBST(LOG4CPLUS_LIBS)
  1050. AC_SUBST(LOG4CPLUS_INCLUDES)
  1051. CPPFLAGS_SAVED=$CPPFLAGS
  1052. CPPFLAGS="$LOG4CPLUS_INCLUDES $CPPFLAGS"
  1053. LIBS_SAVED="$LIBS"
  1054. LIBS="$LOG4CPLUS_LIBS $MULTITHREADING_FLAG $LIBS"
  1055. AC_CHECK_HEADERS([log4cplus/logger.h],,AC_MSG_ERROR([Missing required header files.]))
  1056. AC_LINK_IFELSE(
  1057. [AC_LANG_PROGRAM([#include <log4cplus/logger.h>
  1058. ],
  1059. [using namespace log4cplus;
  1060. Logger logger = Logger::getInstance("main");
  1061. ])],
  1062. [AC_MSG_RESULT([checking for log4cplus library... yes])],
  1063. [AC_MSG_RESULT([checking for log4cplus library... no])
  1064. AC_MSG_ERROR([Needs log4cplus library])]
  1065. )
  1066. dnl Determine the log4cplus version, used mainly for config.report.
  1067. AC_MSG_CHECKING([log4cplus version])
  1068. cat > conftest.cpp << EOF
  1069. #include <log4cplus/version.h>
  1070. AUTOCONF_LOG4CPLUS_VERSION=LOG4CPLUS_VERSION_STR
  1071. EOF
  1072. LOG4CPLUS_VERSION=`$CPP $CPPFLAGS conftest.cpp | grep '^AUTOCONF_LOG4CPLUS_VERSION=' | $SED -e 's/^AUTOCONF_LOG4CPLUS_VERSION=//' -e 's/[[ ]]//g' -e 's/"//g' 2> /dev/null`
  1073. if test -z "$LOG4CPLUS_VERSION"; then
  1074. LOG4CPLUS_VERSION="unknown"
  1075. fi
  1076. $RM -f conftest.cpp
  1077. AC_MSG_RESULT([$LOG4CPLUS_VERSION])
  1078. CPPFLAGS=$CPPFLAGS_SAVED
  1079. LIBS=$LIBS_SAVED
  1080. #
  1081. # Configure Boost header path
  1082. #
  1083. AX_BOOST_FOR_KEA
  1084. # Boost offset_ptr is required in one library and not optional right now, so
  1085. # we unconditionally fail here if it doesn't work.
  1086. if test "$BOOST_OFFSET_PTR_WOULDFAIL" = "yes" -a X"$werror_ok" = X1; then
  1087. AC_MSG_ERROR([Failed to compile a required header file. Try upgrading Boost to 1.44 or higher (when using clang++) or specifying --without-werror. See the ChangeLog entry for Trac no. 2147 for more details.])
  1088. fi
  1089. if test "$BOOST_STATIC_ASSERT_WOULDFAIL" = "yes" -a X"$werror_ok" = X1; then
  1090. AC_MSG_ERROR([Failed to use Boost static assertions. Try upgrading Boost to 1.54 or higher (when using GCC 4.8) or specifying --without-werror. See trac ticket no. 3039 for more details.])
  1091. fi
  1092. # There's a known bug in FreeBSD ports for Boost that would trigger a false
  1093. # warning in build with g++ and -Werror (we exclude clang++ explicitly to
  1094. # avoid unexpected false positives).
  1095. if test "$BOOST_NUMERIC_CAST_WOULDFAIL" = "yes" -a X"$werror_ok" = X1 -a $CLANGPP = "no"; then
  1096. AC_MSG_ERROR([Failed to compile a required header file. If you are using FreeBSD and Boost installed via ports, retry with specifying --without-werror. See the ChangeLog entry for Trac no. 1991 for more details.])
  1097. fi
  1098. # Add some default CPP flags needed for Boost, identified by the AX macro.
  1099. CPPFLAGS="$CPPFLAGS $CPPFLAGS_BOOST_THREADCONF"
  1100. # Can be required by gtest, boost and perhaps still asio
  1101. AC_CHECK_LIB(pthread, pthread_create,[ LDFLAGS="$LDFLAGS -lpthread" ], [])
  1102. #
  1103. # Check availability of gtest, which will be used for unit tests.
  1104. #
  1105. GTEST_LDFLAGS=
  1106. GTEST_LDADD=
  1107. DISTCHECK_GTEST_CONFIGURE_FLAG=
  1108. GTEST_VERSION="unknown"
  1109. if test "x$enable_gtest" = "xyes" ; then
  1110. DISTCHECK_GTEST_CONFIGURE_FLAG="--with-gtest=$gtest_path"
  1111. if test -n "$with_gtest_source" ; then
  1112. if test "x$GTEST_SOURCE" = "xyes" ; then
  1113. AC_MSG_CHECKING([for gtest source])
  1114. # If not specified, try some common paths.
  1115. GTEST_SOURCE=
  1116. for d in /usr/src/gtest /usr/local /usr/pkg /opt /opt/local ; do
  1117. if test -f $d/src/gtest-all.cc -a $d/src/gtest_main.cc; then
  1118. GTEST_SOURCE=$d
  1119. AC_MSG_RESULT([$GTEST_SOURCE])
  1120. break
  1121. fi
  1122. done
  1123. if test -z $GTEST_SOURCE ; then
  1124. AC_MSG_ERROR([no gtest source but it was selected])
  1125. fi
  1126. else
  1127. if test ! -d $GTEST_SOURCE/src -a -d $GTEST_SOURCE/googletest; then
  1128. GTEST_SOURCE=$GTEST_SOURCE/googletest
  1129. fi
  1130. AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
  1131. [$GTEST_SOURCE/src/gtest_main.cc],
  1132. [have_gtest_source=yes],
  1133. [AC_MSG_ERROR([no gtest source at $GTEST_SOURCE])])
  1134. fi
  1135. have_gtest_source=yes
  1136. GTEST_LDFLAGS="\$(top_builddir)/ext/gtest/libgtest.a"
  1137. DISTCHECK_GTEST_CONFIGURE_FLAG="--with-gtest-source=$GTEST_SOURCE"
  1138. GTEST_INCLUDES="-I$GTEST_SOURCE -I$GTEST_SOURCE/include"
  1139. fi
  1140. if test "$gtest_path" != "no" ; then
  1141. if test "$gtest_path" != "yes"; then
  1142. GTEST_PATHS=$gtest_path
  1143. if test -x "${gtest_path}/bin/gtest-config" ; then
  1144. GTEST_CONFIG="${gtest_path}/bin/gtest-config"
  1145. fi
  1146. else
  1147. AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
  1148. fi
  1149. if test -x "${GTEST_CONFIG}" ; then :
  1150. # using cppflags instead of cxxflags
  1151. GTEST_INCLUDES=`${GTEST_CONFIG} --cppflags`
  1152. GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
  1153. GTEST_LDADD=`${GTEST_CONFIG} --libs`
  1154. GTEST_VERSION=`${GTEST_CONFIG} --version`
  1155. GTEST_FOUND="true"
  1156. else
  1157. AC_MSG_WARN([Unable to locate Google Test gtest-config.])
  1158. if test -z "${GTEST_PATHS}" ; then
  1159. GTEST_PATHS="/usr /usr/local"
  1160. fi
  1161. GTEST_FOUND="false"
  1162. fi
  1163. if test "${GTEST_FOUND}" != "true"; then
  1164. GTEST_FOUND="false"
  1165. for dir in $GTEST_PATHS; do
  1166. if test -f "$dir/include/gtest/gtest.h"; then
  1167. if ! test -f "$dir/lib/libgtests.a"; then
  1168. AC_MSG_WARN([Found Google Test include but not the library in $dir.])
  1169. continue
  1170. fi
  1171. GTEST_INCLUDES="-I$dir/include"
  1172. GTEST_LDFLAGS="-L$dir/lib"
  1173. GTEST_LDADD="-lgtest"
  1174. GTEST_FOUND="true"
  1175. break
  1176. fi
  1177. done
  1178. fi
  1179. if test "${GTEST_FOUND}" != "true"; then
  1180. AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
  1181. fi
  1182. fi
  1183. fi
  1184. AM_CONDITIONAL(HAVE_GTEST, test $enable_gtest != "no")
  1185. AM_CONDITIONAL(HAVE_GTEST_SOURCE, test "X$have_gtest_source" = "Xyes")
  1186. AC_SUBST(DISTCHECK_GTEST_CONFIGURE_FLAG)
  1187. AC_SUBST(GTEST_INCLUDES)
  1188. AC_SUBST(GTEST_LDFLAGS)
  1189. AC_SUBST(GTEST_LDADD)
  1190. AC_SUBST(GTEST_SOURCE)
  1191. #
  1192. # Some Googletest versions bug with C++11 compilers
  1193. #
  1194. if test $enable_gtest != "no"; then
  1195. AC_MSG_CHECKING([if Google Test is compatible with the compiler])
  1196. CPPFLAGS_SAVED=$CPPFLAGS
  1197. CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES $GTEST_INCLUDES"
  1198. AC_COMPILE_IFELSE(
  1199. [AC_LANG_PROGRAM(
  1200. [#include <boost/shared_ptr.hpp>
  1201. #include <gtest/gtest.h>
  1202. void foo() {
  1203. boost::shared_ptr<int> bar;
  1204. ASSERT_TRUE(bar);
  1205. }],
  1206. [return 0;])],
  1207. [AC_MSG_RESULT(yes)],
  1208. [AC_MSG_ERROR([XXX_TRUE() Google Test macros won't compile; the most likely reason is that a later version of Google Test is required])])
  1209. CPPFLAGS=$CPPFLAGS_SAVED
  1210. fi
  1211. #
  1212. # ASIO: we extensively use it as the C++ event management module.
  1213. #
  1214. # Use our 'coroutine' header from ext
  1215. CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/coroutine"
  1216. #
  1217. # Doesn't seem to be required?
  1218. CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_HEADER_ONLY"
  1219. #
  1220. # Disable threads: they seems to break things on some systems
  1221. CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_DISABLE_THREADS=1"
  1222. # We tried to stay header only
  1223. if test "x${BOOST_LIBS}" = "x"; then
  1224. # Don't want boost system library
  1225. CPPFLAGS="$CPPFLAGS -DBOOST_ERROR_CODE_HEADER_ONLY"
  1226. # Avoid boost::system::throws multiple defines
  1227. CPPFLAGS="$CPPFLAGS -DBOOST_SYSTEM_NO_DEPRECATED"
  1228. fi
  1229. # Check for functions that are not available on all platforms
  1230. AC_CHECK_FUNCS([pselect])
  1231. # /dev/poll issue: ASIO uses /dev/poll by default if it's available (generally
  1232. # the case with Solaris). Unfortunately its /dev/poll specific code would
  1233. # trigger the gcc's "missing-field-initializers" warning, which would
  1234. # subsequently make the build fail with -Werror. Further, older versions of
  1235. # gcc don't provide an option to selectively suppress this warning.
  1236. # So, for the moment, we simply disable the use of /dev/poll. Unless we
  1237. # implement recursive DNS server with randomized ports, we don't need the
  1238. # scalability that /dev/poll can provide, so this decision wouldn't affect
  1239. # run time performance. Hopefully we can find a better solution or the ASIO
  1240. # code will be updated by the time we really need it.
  1241. AC_CHECK_HEADERS(sys/devpoll.h, ac_cv_have_devpoll=yes, ac_cv_have_devpoll=no)
  1242. if test "X$ac_cv_have_devpoll" = "Xyes" -a "X$GXX" = "Xyes"; then
  1243. CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_DISABLE_DEV_POLL=1"
  1244. fi
  1245. #
  1246. # Perl is optional; it is used only by some of the system test scripts.
  1247. #
  1248. AC_PATH_PROGS(PERL, perl5 perl)
  1249. AC_SUBST(PERL)
  1250. AC_PATH_PROGS(AWK, gawk awk)
  1251. AC_SUBST(AWK)
  1252. AC_ARG_ENABLE(generate_parser, [AC_HELP_STRING([--enable-generate-parser],
  1253. [indicates that the parsers will be regenerated. This implies that the
  1254. bison and flex are required [default=no]])],
  1255. enable_generate_parser=$enableval, enable_generate_parser=no)
  1256. # Check if flex is avaible. Flex is not needed for building Kea sources,
  1257. # unless you want to regenerate grammar in src/lib/eval
  1258. AC_PROG_LEX
  1259. # Check if bison is available. Bison is not needed for building Kea sources,
  1260. # unless you want to regenerate grammar in src/lib/eval
  1261. AC_PROG_YACC
  1262. if test "x$enable_generate_parser" != "xno"; then
  1263. if test "x$LEX" == "x"; then
  1264. AC_MSG_ERROR([Flex is required for enable-generate-parser, but was not found])
  1265. fi
  1266. if test "x$YACC" == "x"; then
  1267. AC_MSG_ERROR([Bison is required for enable-generate-parser, but was not found])
  1268. fi
  1269. # Ok, let's check if we have at least 3.0.0 version of the bison. The code used
  1270. # to generate src/lib/eval parser is roughly based on bison 3.0 examples.
  1271. cat > bisontest.y << EOF
  1272. %require "3.0.0"
  1273. %token X
  1274. %%
  1275. %start Y;
  1276. Y: X;
  1277. EOF
  1278. # Try to compile.
  1279. $YACC bisontest.y -o bisontest.cc
  1280. if test $? -ne 0 ; then
  1281. $YACC -V
  1282. $RM -f bisontest.y bisontest.cc
  1283. AC_MSG_ERROR("Error with $YACC. Possibly incorrect version? Required at least 3.0.0.")
  1284. fi
  1285. $RM -f bisontest.y bisontest.cc
  1286. fi
  1287. AM_CONDITIONAL([GENERATE_PARSER], [test x$enable_generate_parser != xno])
  1288. AC_ARG_ENABLE(generate_docs, [AC_HELP_STRING([--enable-generate-docs],
  1289. [regenerate documentation using Docbook [default=no]])],
  1290. enable_generate_docs=$enableval, enable_generate_docs=no)
  1291. if test "x$enable_generate_docs" != xno ; then
  1292. # Check for xsltproc
  1293. AC_PATH_PROG([XSLTPROC], [xsltproc])
  1294. if test -z "$XSLTPROC"; then
  1295. AC_MSG_ERROR("xsltproc not found; it is required for --enable-generate-docs")
  1296. else
  1297. AC_MSG_CHECKING([if $XSLTPROC works])
  1298. # run xsltproc to see if works
  1299. $XSLTPROC --novalid --xinclude http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
  1300. if test $? -ne 0 ; then
  1301. AC_MSG_ERROR("Error with $XSLTPROC using release/xsl/current/manpages/docbook.xsl")
  1302. fi
  1303. $XSLTPROC --novalid --xinclude http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl
  1304. if test $? -ne 0 ; then
  1305. AC_MSG_ERROR("Error with $XSLTPROC using release/xsl/current/html/docbook.xsl")
  1306. fi
  1307. AC_MSG_RESULT(yes)
  1308. fi
  1309. AC_PATH_PROG([ELINKS], [elinks])
  1310. if test -z "$ELINKS"; then
  1311. AC_MSG_ERROR("elinks not found; it is required for --enable-generate-docs")
  1312. fi
  1313. fi
  1314. # Don't fail here if not found, used to generate PDF documentation.
  1315. AC_PATH_PROG([DBLATEX], [dblatex])
  1316. AM_CONDITIONAL(HAVE_DBLATEX, test "x$DBLATEX" != "x")
  1317. AM_CONDITIONAL(GENERATE_DOCS, test x$enable_generate_docs != xno)
  1318. AC_ARG_ENABLE(install-configurations,
  1319. [AC_HELP_STRING([--disable-install-configurations],
  1320. [do not install configuration])], install_configurations=$enableval, install_configurations=yes)
  1321. AM_CONDITIONAL(INSTALL_CONFIGURATIONS, test x$install_configurations = xyes || test x$install_configurations = xtrue)
  1322. AC_ARG_ENABLE(logger-checks, [AC_HELP_STRING([--enable-logger-checks],
  1323. [check logger messages [default=no]])], enable_logger_checks=$enableval, enable_logger_checks=no)
  1324. AM_CONDITIONAL(ENABLE_LOGGER_CHECKS, test x$enable_logger_checks != xno)
  1325. AM_COND_IF([ENABLE_LOGGER_CHECKS], [AC_DEFINE([ENABLE_LOGGER_CHECKS], [1], [Check logger messages?])])
  1326. # Check for asciidoc
  1327. AC_PATH_PROG(ASCIIDOC, asciidoc, no)
  1328. AM_CONDITIONAL(HAVE_ASCIIDOC, test "x$ASCIIDOC" != "xno")
  1329. # Check for plantuml
  1330. AC_PATH_PROG(PLANTUML, plantuml, no)
  1331. AM_CONDITIONAL(HAVE_PLANTUML, test "x$PLANTUML" != "xno")
  1332. # Check for valgrind
  1333. AC_PATH_PROG(VALGRIND, valgrind, no)
  1334. AM_CONDITIONAL(HAVE_VALGRIND, test "x$VALGRIND" != "xno")
  1335. # Also check for valgrind headers
  1336. # We could consider adding them to the source code tree, as this
  1337. # is the encouraged method of using them; they are BSD-licensed.
  1338. # However, until we find that this is a problem, we just use
  1339. # the system-provided ones, if available
  1340. AC_CHECK_HEADERS(valgrind/valgrind.h, [AC_DEFINE([HAVE_VALGRIND_HEADERS], [1], [Check valgrind headers])])
  1341. found_valgrind="not found"
  1342. if test "x$VALGRIND" != "xno"; then
  1343. found_valgrind="found"
  1344. fi
  1345. # Check for optreset in unistd.h. On BSD systems the optreset is
  1346. # used to reset the state of getopt() function. Resetting its state
  1347. # is required if command line arguments are parsed multiple times
  1348. # during a program. On Linux this variable will not exist because
  1349. # getopt() reset is performed by setting optind = 0. On Operating
  1350. # Systems where optreset is defined use optreset = 1 and optind = 1
  1351. # to reset internal state of getopt(). Failing to do so will result
  1352. # in unpredictable output from getopt().
  1353. AC_MSG_CHECKING([whether optreset variable is defined in unistd.h])
  1354. AC_TRY_LINK(
  1355. [#include <unistd.h>],
  1356. [extern int optreset; optreset=1;],
  1357. [ AC_MSG_RESULT(yes)
  1358. var_optreset_exists=yes],
  1359. [ AC_MSG_RESULT(no)
  1360. var_optreset_exists=no]
  1361. )
  1362. AM_CONDITIONAL(HAVE_OPTRESET, test "x$var_optreset_exists" != "xno")
  1363. AM_COND_IF([HAVE_OPTRESET], [AC_DEFINE([HAVE_OPTRESET], [1], [Check for optreset?])])
  1364. AC_DEFINE([CONFIG_H_WAS_INCLUDED], [1], [config.h inclusion marker])
  1365. AC_CONFIG_FILES([compatcheck/Makefile
  1366. dns++.pc
  1367. doc/design/datasrc/Makefile
  1368. doc/design/Makefile
  1369. doc/guide/Makefile
  1370. doc/Makefile
  1371. doc/version.ent
  1372. ext/coroutine/Makefile
  1373. ext/gtest/Makefile
  1374. ext/Makefile
  1375. m4macros/Makefile
  1376. Makefile
  1377. src/Makefile
  1378. src/bin/Makefile
  1379. src/bin/d2/Makefile
  1380. src/bin/d2/tests/Makefile
  1381. src/bin/d2/tests/d2_process_tests.sh
  1382. src/bin/d2/tests/test_data_files_config.h
  1383. src/bin/dhcp4/Makefile
  1384. src/bin/dhcp4/spec_config.h.pre
  1385. src/bin/dhcp4/tests/Makefile
  1386. src/bin/dhcp4/tests/dhcp4_process_tests.sh
  1387. src/bin/dhcp4/tests/marker_file.h
  1388. src/bin/dhcp4/tests/test_data_files_config.h
  1389. src/bin/dhcp4/tests/test_libraries.h
  1390. src/bin/dhcp6/Makefile
  1391. src/bin/dhcp6/spec_config.h.pre
  1392. src/bin/dhcp6/tests/Makefile
  1393. src/bin/dhcp6/tests/dhcp6_process_tests.sh
  1394. src/bin/dhcp6/tests/marker_file.h
  1395. src/bin/dhcp6/tests/test_data_files_config.h
  1396. src/bin/dhcp6/tests/test_libraries.h
  1397. src/bin/keactrl/Makefile
  1398. src/bin/keactrl/keactrl
  1399. src/bin/keactrl/keactrl.conf
  1400. src/bin/keactrl/tests/Makefile
  1401. src/bin/keactrl/tests/keactrl_tests.sh
  1402. src/bin/lfc/Makefile
  1403. src/bin/lfc/tests/Makefile
  1404. src/bin/perfdhcp/Makefile
  1405. src/bin/perfdhcp/tests/Makefile
  1406. src/bin/perfdhcp/tests/testdata/Makefile
  1407. src/bin/admin/Makefile
  1408. src/bin/admin/kea-admin
  1409. src/bin/admin/tests/Makefile
  1410. src/bin/admin/tests/data/Makefile
  1411. src/bin/admin/tests/memfile_tests.sh
  1412. src/bin/admin/tests/mysql_tests.sh
  1413. src/bin/admin/tests/pgsql_tests.sh
  1414. src/bin/admin/tests/cql_tests.sh
  1415. src/hooks/Makefile
  1416. src/hooks/dhcp/Makefile
  1417. src/hooks/dhcp/user_chk/Makefile
  1418. src/hooks/dhcp/user_chk/tests/Makefile
  1419. src/hooks/dhcp/user_chk/tests/test_data_files_config.h
  1420. src/lib/Makefile
  1421. src/lib/asiodns/Makefile
  1422. src/lib/asiodns/tests/Makefile
  1423. src/lib/asiolink/Makefile
  1424. src/lib/asiolink/tests/Makefile
  1425. src/lib/cc/Makefile
  1426. src/lib/cc/tests/Makefile
  1427. src/lib/cfgrpt/Makefile
  1428. src/lib/cfgrpt/tests/Makefile
  1429. src/lib/config/Makefile
  1430. src/lib/config/tests/Makefile
  1431. src/lib/config/tests/data_def_unittests_config.h
  1432. src/lib/config/tests/testdata/Makefile
  1433. src/lib/cryptolink/Makefile
  1434. src/lib/cryptolink/tests/Makefile
  1435. src/lib/dhcp/Makefile
  1436. src/lib/dhcp/tests/Makefile
  1437. src/lib/dhcp_ddns/Makefile
  1438. src/lib/dhcp_ddns/tests/Makefile
  1439. src/lib/dhcpsrv/Makefile
  1440. src/lib/dhcpsrv/tests/Makefile
  1441. src/lib/dhcpsrv/tests/test_libraries.h
  1442. src/lib/dhcpsrv/testutils/Makefile
  1443. src/lib/dns/Makefile
  1444. src/lib/dns/gen-rdatacode.py
  1445. src/lib/dns/tests/Makefile
  1446. src/lib/dns/tests/testdata/Makefile
  1447. src/lib/exceptions/Makefile
  1448. src/lib/exceptions/tests/Makefile
  1449. src/lib/hooks/Makefile
  1450. src/lib/hooks/tests/Makefile
  1451. src/lib/hooks/tests/marker_file.h
  1452. src/lib/hooks/tests/test_libraries.h
  1453. src/lib/log/Makefile
  1454. src/lib/log/compiler/Makefile
  1455. src/lib/log/interprocess/Makefile
  1456. src/lib/log/interprocess/tests/Makefile
  1457. src/lib/log/tests/Makefile
  1458. src/lib/log/tests/buffer_logger_test.sh
  1459. src/lib/log/tests/console_test.sh
  1460. src/lib/log/tests/destination_test.sh
  1461. src/lib/log/tests/init_logger_test.sh
  1462. src/lib/log/tests/local_file_test.sh
  1463. src/lib/log/tests/logger_lock_test.sh
  1464. src/lib/log/tests/severity_test.sh
  1465. src/lib/log/tests/tempdir.h
  1466. src/lib/process/Makefile
  1467. src/lib/process/spec_config.h.pre
  1468. src/lib/process/tests/Makefile
  1469. src/lib/process/testutils/Makefile
  1470. src/lib/testutils/Makefile
  1471. src/lib/testutils/dhcp_test_lib.sh
  1472. src/lib/stats/Makefile
  1473. src/lib/stats/tests/Makefile
  1474. src/lib/util/Makefile
  1475. src/lib/util/io/Makefile
  1476. src/lib/util/python/Makefile
  1477. src/lib/util/python/gen_wiredata.py
  1478. src/lib/util/tests/Makefile
  1479. src/lib/util/tests/process_spawn_app.sh
  1480. src/lib/util/threads/Makefile
  1481. src/lib/util/threads/tests/Makefile
  1482. src/lib/util/unittests/Makefile
  1483. src/lib/eval/Makefile
  1484. src/lib/eval/tests/Makefile
  1485. src/share/Makefile
  1486. src/share/database/Makefile
  1487. src/share/database/scripts/Makefile
  1488. src/share/database/scripts/mysql/Makefile
  1489. src/share/database/scripts/mysql/upgrade_1.0_to_2.0.sh
  1490. src/share/database/scripts/mysql/upgrade_2.0_to_3.0.sh
  1491. src/share/database/scripts/mysql/upgrade_3.0_to_4.0.sh
  1492. src/share/database/scripts/mysql/upgrade_4.0_to_4.1.sh
  1493. src/share/database/scripts/mysql/upgrade_4.1_to_5.0.sh
  1494. src/share/database/scripts/pgsql/Makefile
  1495. src/share/database/scripts/pgsql/upgrade_1.0_to_2.0.sh
  1496. src/share/database/scripts/pgsql/upgrade_2.0_to_3.0.sh
  1497. src/share/database/scripts/cql/Makefile
  1498. tools/Makefile
  1499. tools/path_replacer.sh
  1500. ])
  1501. AC_CONFIG_COMMANDS([permissions], [
  1502. chmod +x src/bin/dhcp4/tests/dhcp4_process_tests.sh
  1503. chmod +x src/bin/dhcp6/tests/dhcp6_process_tests.sh
  1504. chmod +x src/bin/keactrl/keactrl
  1505. chmod +x src/bin/keactrl/tests/keactrl_tests.sh
  1506. chmod +x src/bin/admin/kea-admin
  1507. chmod +x src/lib/dns/gen-rdatacode.py
  1508. chmod +x src/lib/log/tests/console_test.sh
  1509. chmod +x src/lib/log/tests/destination_test.sh
  1510. chmod +x src/lib/log/tests/init_logger_test.sh
  1511. chmod +x src/lib/log/tests/local_file_test.sh
  1512. chmod +x src/lib/log/tests/logger_lock_test.sh
  1513. chmod +x src/lib/log/tests/severity_test.sh
  1514. chmod +x src/lib/util/python/gen_wiredata.py
  1515. chmod +x src/lib/util/tests/process_spawn_app.sh
  1516. chmod +x tools/path_replacer.sh
  1517. ])
  1518. AM_CONDITIONAL(PREMIUM, test -d "$srcdir/premium/src")
  1519. AC_MSG_CHECKING([if premium package is available])
  1520. if test -d "$srcdir/premium/src"; then
  1521. # Define it in the config.h, so C++ code could use it.
  1522. AC_DEFINE([PREMIUM], [1], [Kea-premium package found])
  1523. # Export it here, so code in configure could use it.
  1524. PREMIUM=1
  1525. AC_MSG_RESULT(yes)
  1526. else
  1527. AC_MSG_RESULT(no)
  1528. fi
  1529. AC_OUTPUT
  1530. dnl Print the results
  1531. dnl
  1532. EXTENDED_VERSION=${PACKAGE_VERSION}
  1533. if test "$KEA_SRCID" != ""; then
  1534. EXTENDED_VERSION="${EXTENDED_VERSION} ($KEA_SRCID)"
  1535. fi
  1536. cat > config.report << END
  1537. Kea source configure results:
  1538. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1539. Package:
  1540. Name: ${PACKAGE_NAME}
  1541. Version: ${PACKAGE_VERSION}
  1542. Extended version:${EXTENDED_VERSION}
  1543. OS Family: ${OS_TYPE}
  1544. Using GNU sed: ${GNU_SED}
  1545. END
  1546. if test "$PREMIUM" != ""; then
  1547. cat >> config.report << END
  1548. Premium package: yes
  1549. END
  1550. else
  1551. cat >> config.report << END
  1552. Premium package: no
  1553. END
  1554. fi
  1555. cat >> config.report << END
  1556. C++ Compiler:
  1557. CXX: ${CXX}
  1558. CXX_VERSION: ${CXX_VERSION}
  1559. CXX_STANDARD: ${CXX_STANDARD}
  1560. DEFS: ${DEFS}
  1561. CPPFLAGS: ${CPPFLAGS}
  1562. CXXFLAGS: ${CXXFLAGS}
  1563. LDFLAGS: ${LDFLAGS}
  1564. KEA_CXXFLAGS: ${KEA_CXXFLAGS}
  1565. END
  1566. if test "$PYTHON" != "no" ; then
  1567. cat >> config.report << END
  1568. Python3:
  1569. PYTHON_VERSION: ${PYTHON_VERSION}
  1570. PYTHON_INCLUDES: ${PYTHON_INCLUDES}
  1571. PYTHON_CXXFLAGS: ${PYTHON_CXXFLAGS}
  1572. PYTHON_LDFLAGS: ${PYTHON_LDFLAGS}
  1573. PYTHON_LIB: ${PYTHON_LIB}
  1574. END
  1575. else
  1576. cat >> config.report << END
  1577. Python3:
  1578. not installed
  1579. END
  1580. fi
  1581. cat >> config.report << END
  1582. Boost:
  1583. BOOST_VERSION: ${BOOST_VERSION}
  1584. BOOST_INCLUDES: ${BOOST_INCLUDES}
  1585. BOOST_LIBS: ${BOOST_LIBS}
  1586. ${CRYPTO_NAME}:
  1587. CRYPTO_VERSION: ${CRYPTO_VERSION}
  1588. CRYPTO_CFLAGS: ${CRYPTO_CFLAGS}
  1589. CRYPTO_INCLUDES: ${CRYPTO_INCLUDES}
  1590. CRYPTO_LDFLAGS: ${CRYPTO_LDFLAGS}
  1591. CRYPTO_LIBS: ${CRYPTO_LIBS}
  1592. ${DISABLED_CRYPTO}: no
  1593. Log4cplus:
  1594. LOG4CPLUS_VERSION: ${LOG4CPLUS_VERSION}
  1595. LOG4CPLUS_INCLUDES: ${LOG4CPLUS_INCLUDES}
  1596. LOG4CPLUS_LIBS: ${LOG4CPLUS_LIBS}
  1597. Flex/bison:
  1598. FLEX: ${LEX}
  1599. BISON: ${YACC}
  1600. END
  1601. # Avoid confusion on DNS/DHCP and only mention MySQL if it
  1602. # were specified on the command line.
  1603. if test "$MYSQL_CPPFLAGS" != "" ; then
  1604. cat >> config.report << END
  1605. MySQL:
  1606. MYSQL_VERSION: ${MYSQL_VERSION}
  1607. MYSQL_CPPFLAGS: ${MYSQL_CPPFLAGS}
  1608. MYSQL_LIBS: ${MYSQL_LIBS}
  1609. END
  1610. else
  1611. cat >> config.report << END
  1612. MySQL:
  1613. no
  1614. END
  1615. fi
  1616. if test "$PGSQL_CPPFLAGS" != "" ; then
  1617. cat >> config.report << END
  1618. PostgreSQL:
  1619. PGSQL_VERSION: ${PGSQL_VERSION}
  1620. PGSQL_CPPFLAGS: ${PGSQL_CPPFLAGS}
  1621. PGSQL_LIBS: ${PGSQL_LIBS}
  1622. END
  1623. else
  1624. cat >> config.report << END
  1625. PostgreSQL:
  1626. no
  1627. END
  1628. fi
  1629. if test "$CQL_CPPFLAGS" != "" ; then
  1630. cat >> config.report << END
  1631. Cassandra CQL:
  1632. CQL_VERSION: ${CQL_VERSION}
  1633. CQL_CPPFLAGS: ${CQL_CPPFLAGS}
  1634. CQL_LIBS: ${CQL_LIBS}
  1635. END
  1636. else
  1637. cat >> config.report << END
  1638. Cassandra CQL:
  1639. no
  1640. END
  1641. fi
  1642. if test "$enable_gtest" != "no"; then
  1643. cat >> config.report << END
  1644. GTest:
  1645. GTEST_VERSION: ${GTEST_VERSION}
  1646. GTEST_INCLUDES: ${GTEST_INCLUDES}
  1647. GTEST_LDFLAGS: ${GTEST_LDFLAGS}
  1648. GTEST_LDADD: ${GTEST_LDADD}
  1649. GTEST_SOURCE: ${GTEST_SOURCE}
  1650. END
  1651. fi
  1652. cat >> config.report << END
  1653. Developer:
  1654. Enable Debugging: $debug_enabled
  1655. Google Tests: $enable_gtest
  1656. Valgrind: $found_valgrind
  1657. C++ Code Coverage: $USE_LCOV
  1658. Logger checks: $enable_logger_checks
  1659. Generate Documentation: $enable_generate_docs
  1660. Parser Generation: $enable_generate_parser
  1661. END
  1662. cat config.report
  1663. cat <<EOF
  1664. Now you can type "make" to build Kea. Note that if you intend to
  1665. run "make check", you must run "make" first as some files need to be
  1666. generated by "make" before "make check" can be run.
  1667. When running "make install" do not use any form of parallel or job
  1668. server options (such as GNU make's -j option). Doing so may cause
  1669. errors.
  1670. EOF