configure.ac 59 KB

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