configure.ac 60 KB

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