configure.ac 65 KB

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