configure.ac 58 KB

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