configure.ac 68.3 KB
Newer Older
1 2
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
3

4
AC_PREREQ([2.69])
5 6 7 8 9

# For released versions, this is in x.y.z format.
# For GIT versions, this is x.y.z-git, where x.y.z denotes the software
# version that was used as a base + changes that were made later, but
# are not released yet.
10
AC_INIT(kea,1.5.0-git, kea-dev@lists.isc.org)
11
AC_CONFIG_SRCDIR(README)
12 13 14 15 16 17 18 19 20 21 22 23 24

# serial-tests is not available in automake version before 1.13, so
# we'll check that and conditionally use serial-tests. This check is
# adopted from code by Richard W.M. Jones:
# https://www.redhat.com/archives/libguestfs/2013-February/msg00102.html
m4_define([serial_tests], [
    m4_esyscmd([automake --version |
                head -1 |
                awk '{split ($NF,a,"."); if (a[1] == 1 && a[2] >= 12) { print "serial-tests" }}'
    ])
])
AM_INIT_AUTOMAKE(foreign serial_tests)

25
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])dnl be backward compatible
26
AC_CONFIG_HEADERS([config.h])
27
AC_CONFIG_MACRO_DIR([m4macros])
28

29
AC_CANONICAL_HOST
30
AC_CANONICAL_BUILD
31

32 33
# Checks for programs.
AC_PROG_CXX
34

35 36 37
# Check for exact Kea version.
AC_MSG_CHECKING(whether this is a tarball or git source)
if test -d "${srcdir}/.git"; then
38
        KEA_SRCID="git `(cd "${top_srcdir}";git rev-parse HEAD)`"
39 40 41 42 43 44 45
        AC_MSG_RESULT("git")
else
        KEA_SRCID="tarball"
        AC_MSG_RESULT("tarball")
fi
# Export EXTENDED_VERSION to config.h
# This will be either "tarball" or "git abcd".
46 47 48 49
# We do not want to put this in a config.h, because it messes up ccache
# horribly. When building different branches, the commit-id is different
# and since the config.h is included in most files *and* has a different
# content, ccache can't use cached content and thus has to do full compilation.
50 51
# Now it is in kea_version.h and config.status substitutes it.
AC_SUBST(KEA_SRCID)
52

53 54
# Find a separator for path_replacer
for sep in "+" "," ";" "&" "__NONE__"; do
55 56 57 58 59 60
        if `pwd | grep -q $sep`; then continue; fi
        if `echo ${prefix} | grep -q $sep`; then continue; fi
        if `echo ${sysconfdir} | grep -q $sep`; then continue; fi
        if `echo ${localstatedir} | grep -q $sep`; then continue; fi
        SEP=$sep
        break
61 62
done
if test "$sep" = "__NONE__"; then
63
        AC_MSG_ERROR([can't find a separator character in '+,;&' for the path_replacer shell script])
64 65 66
fi
AC_SUBST(SEP)

67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
# If cross compiling assume the message compiler executable was
# magically already in place...
if test "$cross_compiling" = "yes"; then
        AC_MSG_CHECKING("build (vs. host) compiled message compiler")
	if test -x "${srcdir}/src/lib/log/compiler/message"; then
		AC_MSG_RESULT(yes)
	else
		AC_MSG_RESULT(no)
		AC_MSG_WARN("you must install a message compiler in:")
		AC_MSG_WARN("    ${srcdir}/src/lib/log/compiler/message")
		AC_MSG_WARN("compiled for build ($build).")
	fi
fi
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = "yes"])

82 83 84
# pkg-config can be required.
AC_PATH_PROG([PKG_CONFIG], [pkg-config])

85 86 87
# Enable low-performing debugging facilities? This option optionally
# enables some debugging aids that perform slowly and hence aren't built
# by default.
88 89 90 91
AC_ARG_ENABLE([debug],
  AS_HELP_STRING([--enable-debug],
    [enable debugging (default is no)]),
  [case "${enableval}" in
92 93
    yes) debug_enabled=yes ;;
    no)  debug_enabled=no ;;
94
    *)   AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
95 96
  esac],[debug_enabled=no])
AM_CONDITIONAL([DEBUG_ENABLED], [test x$debug_enabled = xyes])
97
AM_COND_IF([DEBUG_ENABLED], [AC_DEFINE([ENABLE_DEBUG], [1], [Enable low-performing debugging facilities?])])
98

99
# Include premium configuration
100 101
INCLUDED_HOOKS=

102
PREMIUM_DIR=
103
DISTCHECK_PREMIUM_CONFIGURE_FLAG=
104
AC_DEFUN([AX_PREMIUM],[])
105
# m4_sinclude includes the file if it exists at autoreconf time
106
m4_sinclude(premium/config.m4)
107
AC_SUBST(PREMIUM_DIR)
108
AC_SUBST(DISTCHECK_PREMIUM_CONFIGURE_FLAG)
109
AX_PREMIUM
110

111
# Include contrib configuration
112
# (currently only a provision copied from premium support)
113
CONTRIB_DIR=
114
DISTCHECK_CONTRIB_CONFIGURE_FLAG=
115
AC_DEFUN([AX_CONTRIB],[])
116
m4_sinclude(contrib/config.m4)
117
AC_SUBST(CONTRIB_DIR)
118
AC_SUBST(DISTCHECK_CONTRIB_CONFIGURE_FLAG)
119
AX_CONTRIB
120

121 122
# Libtool configuration
#
123 124 125

# libtool cannot handle spaces in paths, so exit early if there is one
if [ test `echo $PWD | grep -c ' '` != "0"  ]; then
126
    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.])
127 128
fi

129 130
# On FreeBSD (and probably some others), clang++ does not meet an autoconf
# assumption in identifying libtool configuration regarding shared library:
131 132 133 134 135
# the configure script will execute "$CC -shared $CFLAGS/$CXXFLAGS -v" and
# expect the output contains -Lxxx or -Ryyy.  This is the case for g++, but
# not for clang++, and, as a result, it will cause various errors in linking
# programs or running them with a shared object (such as some of our python
# scripts).
136 137 138 139 140
# To work around this problem we define a temporary variable
# "CXX_LIBTOOL_LDFLAGS".  It's expected to be defined as, e.g, "-L/usr/lib"
# to temporarily fake the output so that it will be compatible with that of
# g++.
CFLAGS_SAVED=$CFLAGS
141
CXXFLAGS_SAVED=$CXXFLAGS
142
CFLAGS="$CFLAGS $CXX_LIBTOOL_LDFLAGS"
143
CXXFLAGS="$CXXFLAGS $CXX_LIBTOOL_LDFLAGS"
144
LT_INIT
145
CFLAGS=$CFLAGS_SAVED
146
CXXFLAGS=$CXXFLAGS_SAVED
147

148
# Use C++ language
149 150 151
AC_LANG([C++])

# Identify the compiler: this check must be after AC_PROG_CXX and AC_LANG.
152
AM_CONDITIONAL(USE_GXX, test "X${GXX}" = "Xyes")
153
AC_CHECK_DECL([__SUNPRO_CC], [SUNCXX="yes"], [SUNCXX="no"])
154
AC_CHECK_DECL([__clang__], [CLANGPP="yes"], [CLANGPP="no"])
Josh Soref's avatar
Josh Soref committed
155
# USE_CLANGPP is no longer used, keep it by symmetry with USE_GXX?
156
AM_CONDITIONAL(USE_CLANGPP, test "X${CLANGPP}" = "Xyes")
157

158
# Check for C++11 features support
159
AX_ISC_CPP11
160

161 162 163
# Check for std::is_base_of support
AC_MSG_CHECKING([for std::is_base_of])
AC_COMPILE_IFELSE(
164 165 166 167 168 169 170 171 172
    [AC_LANG_PROGRAM(
        [#include <type_traits>
        class A {};
        class B : A {};]
        [static_assert(std::is_base_of<A, B>::value, "");])],
    [AC_MSG_RESULT(yes)
    AC_DEFINE([HAVE_IS_BASE_OF], [1],
    [Define to 1 if std::is_base_of is available])],
    [AC_MSG_RESULT(no)])
173

174
dnl Determine if we are using GNU sed
175
GNU_SED=no
176
$SED --version 2> /dev/null | grep GNU > /dev/null 2>&1
177 178 179 180
if test $? -eq 0; then
  GNU_SED=yes
fi

181 182 183 184 185 186 187
# Display the C++ version
AC_MSG_CHECKING([C++ version])
cat > conftest.cpp << EOF
long v = __cplusplus;
EOF
CXX_STANDARD=`$CXX $CXXFLAGS -E -o - conftest.cpp | grep '^long v = ' | $SED -e 's/^long v = //' -e 's/[[^0-9]]*$//' 2> /dev/null`
if test -z "$CXX_STANDARD"; then
188
        CXX_STANDARD="unknown"
189 190 191
fi
AC_MSG_RESULT([$CXX_STANDARD])

192 193
# Linker options

194
# check -R, "-Wl,-R" or -rpath
195
AX_ISC_RPATH
196

197
# Compiler dependent settings: define some mandatory CXXFLAGS here.
198
# We also use a separate variable KEA_CXXFLAGS.  This will (and should) be
199
# used as the default value for each specific AM_CXXFLAGS:
200
# AM_CXXFLAGS = $(KEA_CXXFLAGS)
201 202 203 204 205 206 207 208
# AM_CXXFLAGS += ... # add module specific flags
# We need this so that we can disable some specific compiler warnings per
# module basis; since AM_CXXFLAGS are placed before CXXFLAGS, and since
# gcc's -Wno-XXX option must be specified after -Wall or -Wextra, we cannot
# specify the default warning flags in CXXFLAGS and let specific modules
# "override" the default.

# This may be used to try linker flags.
209
AC_DEFUN([KEA_CXX_TRY_FLAG], [
210 211
  AC_MSG_CHECKING([whether $CXX supports $1])

212
  kea_save_CXXFLAGS="$CXXFLAGS"
213
  CXXFLAGS="$CXXFLAGS -Werror $1"
214

215
  AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){ return 0;}])],
216 217
                 [kea_cxx_flag=yes], [kea_cxx_flag=no])
  CXXFLAGS="$kea_save_CXXFLAGS"
218

219
  if test "x$kea_cxx_flag" = "xyes"; then
220 221 222 223 224
    ifelse([$2], , :, [$2])
  else
    ifelse([$3], , :, [$3])
  fi

225
  AC_MSG_RESULT([$kea_cxx_flag])
226 227
])

228 229
CXX_VERSION="unknown"

230 231 232
# SunStudio compiler requires special compiler options for boost
# (http://blogs.sun.com/sga/entry/boost_mini_howto)
if test "$SUNCXX" = "yes"; then
233
CXX_VERSION=`$CXX -V 2> /dev/null | head -1`
234
CXXFLAGS="$CXXFLAGS -library=stlport4 -features=tmplife -features=tmplrefstatic"
235
KEA_CXXFLAGS="$KEA_CXXFLAGS -mt"
236 237 238 239 240 241 242 243 244 245
MULTITHREADING_FLAG="-mt"
fi

# Newer versions of clang++ promotes "unused driver arguments" warnings to
# a fatal error with -Werror, causing build failure.  Since we use multiple
# compilers on multiple systems, this can easily happen due to settings for
# non clang++ environments that could be just ignored otherwise.  It can also
# happen if clang++ is used via ccache.  So, although probably suboptimal,
# we suppress this particular warning.  Note that it doesn't weaken checks
# on the source code.
246
if test "X$CLANGPP" = "Xyes"; then
247
CXX_VERSION=`$CXX --version 2> /dev/null | head -1`
248
KEA_CXXFLAGS="$KEA_CXXFLAGS -Qunused-arguments"
249 250
fi

251
# gcc/clang specific settings:
252
if test "X$GXX" = "Xyes"; then
253
CXX_VERSION=`$CXX --version 2> /dev/null | head -1`
254
KEA_CXXFLAGS="$KEA_CXXFLAGS -Wall -Wextra -Wnon-virtual-dtor -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
255 256 257
# gcc 4.4 would emit warnings about breaking strict aliasing rules.
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41874
CXX_DUMP_VERSION=`$CXX -dumpversion | cut -f1-2 -d.`
258
if expr "$CXX_DUMP_VERSION" \< "4.5" > /dev/null; then
259 260 261
       WARNING_GCC_44_STRICT_ALIASING_CFLAG="-fno-strict-aliasing"
fi
AC_SUBST(WARNING_GCC_44_STRICT_ALIASING_CFLAG)
262
CPPP="$CPP"
263
# gcc 5 preprocessor requires -P for checking its output
264
if expr "$CXX_DUMP_VERSION" \> "5" > /dev/null; then
265 266
       CPPP="$CPP -P"
fi
267

268 269
case "$host" in
*-solaris*)
270 271 272 273
        MULTITHREADING_FLAG=-pthreads
        # In Solaris, IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT need -Wno-missing-braces
        KEA_CXXFLAGS="$KEA_CXXFLAGS -Wno-missing-braces"
        ;;
274
*-apple-darwin*)
275 276
        MULTITHREADING_FLAG=
        ;;
277
*)
278 279
        MULTITHREADING_FLAG=-pthread
        ;;
280
esac
281
KEA_CXXFLAGS="$KEA_CXXFLAGS $MULTITHREADING_FLAG"
282

283 284 285
# Disable -Werror by default. Only use it if specifically enabled.
# The usage of this flag is:
#
286 287 288 289 290
# No flag:            -Werror is disabled
# --with-werror:      -Werror is enabled
# --with-werror=yes:  -Werror is enabled
# --with-werror=no:   -Werror is disabled
# --with-werror=value -Werror is enabled and "value" is included in the compiler flags
291 292 293 294
#
# In the last case, "value" may be one or more compiler flags, e.g.

# --with-werror=-Wundef
295
# --with-werror='-Wundef -Wconversion'
296

297
werror_extras=
298
AC_ARG_WITH(werror,
299
    AC_HELP_STRING([--with-werror], [Compile using -Werror (default=no)]),
300 301 302 303
    [
     case "${withval}" in
         yes) with_werror=1 ;;
         no)  with_werror=0 ;;
304
         -*)  with_werror=1; werror_extras=${withval} ;;
305
         *)   AC_MSG_ERROR(bad value ${withval} for --with-werror) ;;
306
     esac],
307
     [with_werror=0])
308 309 310 311 312 313 314 315

werror_ok=0

# Certain versions of gcc (g++) have a bug that incorrectly warns about
# the use of anonymous name spaces even if they're closed in a single
# translation unit.  For these versions we have to disable -Werror.
if test $with_werror = 1; then
   CXXFLAGS_SAVED="$CXXFLAGS"
316
   CXXFLAGS="$CXXFLAGS $KEA_CXXFLAGS -Werror"
317
   AC_MSG_CHECKING(for in-TU anonymous namespace breakage)
318 319 320 321
   # We use struct, not class, here, because some compilers complain about
   # "unused private members", causing a false positive.
   AC_TRY_COMPILE([namespace { struct Foo {}; }
   namespace isc {struct Bar {Foo foo_;};} ],,
322 323 324 325
        [AC_MSG_RESULT(no)
         werror_ok=1
         KEA_CXXFLAGS="$KEA_CXXFLAGS -Werror"],
        [AC_MSG_RESULT(yes)])
326 327 328
   CXXFLAGS="$CXXFLAGS_SAVED"
fi

329 330 331 332 333 334 335
# Added flags after -Werror

# Some versions of GCC warn about some versions of Boost regarding
# missing initializer for members in its posix_time.
# https://svn.boost.org/trac/boost/ticket/3477
# But older GCC compilers don't have the flag.
KEA_CXX_TRY_FLAG([-Wno-missing-field-initializers],
336
        [KEA_CXXFLAGS="$KEA_CXXFLAGS -Wno-missing-field-initializers"])
337 338

if test "X$CLANGPP" = "Xyes"; then
339 340 341 342
        # This is to workaround unused variables tcout and tcerr in
        # log4cplus's streams.h and unused parameters from some of the
        # Boost headers.
        KEA_CXXFLAGS="$KEA_CXXFLAGS -Wno-unused-variable -Wno-unused-parameter"
343 344 345 346 347
fi

# Add the extras at the very last
# Note it can be used to re-enable a (fatal) warning
for extra in $werror_extras; do
348 349 350
        KEA_CXX_TRY_FLAG([$extra],
                [KEA_CXXFLAGS="$KEA_CXXFLAGS $extra"],
                [AC_MSG_ERROR([$CXX does not support $extra"])])
351 352
done

353
fi                              dnl GXX = yes
354

355 356 357 358 359 360 361
# allow building programs with static link.  we need to make it selective
# because loadable modules cannot be statically linked.
AC_ARG_ENABLE([static-link],
AC_HELP_STRING([--enable-static-link],
  [build programs with static link [[default=no]]]),
  [enable_static_link=yes], [enable_static_link=no])
AM_CONDITIONAL(USE_STATIC_LINK, test $enable_static_link = yes)
362
AM_COND_IF([USE_STATIC_LINK], [AC_DEFINE([USE_STATIC_LINK], [1], [Was Kea statically linked?])])
363

364 365
# Check validity about some libtool options
if test $enable_static_link = yes -a $enable_static = no; then
366
        AC_MSG_ERROR([--enable-static-link requires --enable-static])
367
fi
368
if test $enable_static_link = no -a $enable_shared = no; then
369
        AC_MSG_ERROR([--disable-static-link requires --enable-shared])
370 371
fi

372
# OS dependent configuration
373
kea_undefined_pthread_behavior=no
374

375
case "$host" in
376
*-solaris*)
377 378 379 380 381 382 383 384 385 386
        # Solaris requires special definitions to get some standard libraries
        # (e.g. getopt(3)) available with common used header files.
        CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
        # "now" binding is necessary to prevent deadlocks in C++ static initialization code
        LDFLAGS="$LDFLAGS -z now"
        # Destroying locked mutexes, condition variables being waited
        # on, etc. are undefined behavior on Solaris, so we set it as
        # such here.
        kea_undefined_pthread_behavior=yes
        ;;
387
*-apple-darwin*)
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
        # Starting with OSX 10.7 (Lion) we must choose which IPv6 API to use
        # (RFC2292 or RFC3542).
        CPPFLAGS="$CPPFLAGS -D__APPLE_USE_RFC_3542"

        # In OS X 10.9 (and possibly any future versions?) pthread_cond_destroy
        # doesn't work as documented, which makes some of unit tests fail.
        AC_MSG_CHECKING([OS X versions where destroying locked locks do not fail])
        AC_TRY_COMPILE(
        [#include <Availability.h>],
        [#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
         #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
         #error " OS X >= 10.9"
         #endif
         #endif
         return 1;],
        [AC_MSG_RESULT([OS X < 10.9])],
        [AC_MSG_RESULT([OS X >= 10.9])
         kea_undefined_pthread_behavior=yes])
        ;;
407
*-freebsd*)
408 409 410 411 412 413 414 415 416 417 418
        # On FreeBSD10.1 pthread_cond_destroy doesn't work as documented, which
        # causes the CondVarTest.destroyWhileWait test to fail. According to the
        # pthread_cond_destroy documentation for FreeBSD, this function should
        # return EBUSY error when there is a thread waiting for the conditional
        # variable, whereas this function returned success code. We treat it here
        # as an undefined behavior. Also note that this issue was only visible
        # when gtest 1.7 was in use, because the previous versions of gtest
        # didn't seem to have support for the death tests on FreeBSD. As a
        # result, the test was not executed and the error didn't occur.
        kea_undefined_pthread_behavior=yes
        ;;
419
esac
420
if [ test $kea_undefined_pthread_behavior = "yes" ]; then
421 422
   AC_DEFINE([HAS_UNDEFINED_PTHREAD_BEHAVIOR], [1], [Does this platform have some undefined pthreads behavior?])
fi
423

424 425 426 427 428 429 430 431 432 433
# Our experiments have shown Solaris 10 has broken support for the
# IPV6_USE_MIN_MTU socket option for getsockopt(); it doesn't return the value
# previously set via setsockopt().  We know it doesn't happen on one instance
# on Solaris 11, but we don't know whether it happens for any Solaris 10
# implementations or for earlier versions of Solaris.  In any case, at the
# moment this matters for only one unittest case, so we'll simply disable
# the affected test using the following definition with the specific hardcoding
# of that version of Solaris.
case "$host" in
*-solaris2.10)
434 435 436
        AC_DEFINE([HAVE_BROKEN_GET_IPV6_USE_MIN_MTU], [1],
        [Define to 1 if getsockopt(IPV6_USE_MIN_MTU) does not work])
        ;;
437 438
esac

439 440 441 442 443 444 445 446
# Kea-shell is written in python. It can work with python 2.7 or any 3.x.
# It may likely work with earlier versions, but 2.7 was the oldest one we tested
# it with. We require python only if kea-shell was enabled. It is disabled
# by default to not introduce hard dependency on python.
AC_ARG_ENABLE(shell, [AC_HELP_STRING([--enable-shell],
  [enable kea-shell, a text management client for Control Agent [default=no]])],
  enable_shell=$enableval, enable_shell=no)

447
DISTCHECK_KEA_SHELL_CONFIGURE_FLAG=
Francis Dupont's avatar
Francis Dupont committed
448
PKGPYTHONDIR=
449 450 451
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
 [python3 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 dnl
  python3.3 python3.2 python3.1 python3.0 python python2 python2.7])
452 453
if test "x$enable_shell" != xno ; then
# If kea-shell is enabled, we really need python. 2.7 or anything newer will do.
454
# We try to find 3.x first. If not found, we can do with 2.7.
455
  AM_PATH_PYTHON([2.7])
Francis Dupont's avatar
Francis Dupont committed
456
  # pkgpythondir needs to be expanded
457 458 459 460
  saved_prefix="$prefix"
  if test "$prefix" = "NONE"; then
    prefix=$ac_default_prefix
  fi
Francis Dupont's avatar
Francis Dupont committed
461 462 463 464 465 466
  PKGPYTHONDIR="$pkgpythondir"
  OLD=
  while test "x$OLD" != "x$PKGPYTHONDIR"; do
    OLD="$PKGPYTHONDIR"
    eval PKGPYTHONDIR="\"$OLD\""
  done
467
  prefix="$saved_prefix"
468
  DISTCHECK_KEA_SHELL_CONFIGURE_FLAG="--enable-shell"
469
else
470
  PYTHON=no
471
fi
472

473 474
# Export to makefiles the info whether we have shell enabled or not
AM_CONDITIONAL(KEA_SHELL, test x$enable_shell != xno)
475
AC_SUBST(DISTCHECK_KEA_SHELL_CONFIGURE_FLAG)
Francis Dupont's avatar
Francis Dupont committed
476
AC_SUBST(PKGPYTHONDIR)
477

478
# produce PIC unless we disable shared libraries. need this for python bindings.
479
if test $enable_shared != "no" -a "X$GXX" = "Xyes"; then
480
   KEA_CXXFLAGS="$KEA_CXXFLAGS -fPIC"
481 482
fi

483
# Look for glib static libs if they're trying to do static builds
484
if test $enable_static_link != "no"; then
485 486 487 488
   CXX_SAVED=$CXX
   CXX="$CXX -static"

   AC_LINK_IFELSE(
489
     [AC_LANG_PROGRAM([#include <math.h>],[(void)sqrt(-1.0);])],
490 491
     [AC_MSG_RESULT([checking for static glib libraries... yes])],
     [AC_MSG_RESULT([checking for static glib libraries... no])
492
      AC_MSG_ERROR([Building with --enable-static-link does not work. You appear to be missing glib static libraries. Check config.log for details.])])
493 494 495

   CXX=$CXX_SAVED
fi
496

497
AC_SUBST(KEA_CXXFLAGS)
498

499 500
# Checks for libraries.

501 502
AC_SEARCH_LIBS(inet_pton, [nsl])
AC_SEARCH_LIBS(recvfrom, [socket])
503
AC_SEARCH_LIBS(nanosleep, [rt])
504
AC_SEARCH_LIBS(dlsym, [dl])
505

506 507 508 509 510 511
# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T

512

513 514
# Detect OS type (it may be used to do OS-specific things, e.g.
# interface detection in DHCP)
515
AC_MSG_CHECKING(OS type)
516
BSD_TYPE="notaBSD"
517 518 519
case $host in
    *-linux*)
      AC_DEFINE([OS_LINUX], [1], [Running on Linux?])
520
      OS_TYPE="Linux"
521 522
      CPPFLAGS="$CPPFLAGS -DOS_LINUX"
      ;;
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
    *-apple-darwin*)
      AC_DEFINE([OS_BSD], [1], [Running on BSD?])
      AC_DEFINE([OS_OSX], [1], [Running on OSX?])
      OS_TYPE="BSD"
      BSD_TYPE="OSX"
      CPPFLAGS="$CPPFLAGS -DOS_BSD"
      ;;
    *-freebsd*)
      AC_DEFINE([OS_BSD], [1], [Running on BSD?])
      AC_DEFINE([OS_FREEBSD], [1], [Running on FreeBSD?])
      OS_TYPE="BSD"
      BSD_TYPE="FreeBSD"
      CPPFLAGS="$CPPFLAGS -DOS_BSD"
      ;;
    *-netbsd*)
      AC_DEFINE([OS_BSD], [1], [Running on BSD?])
      AC_DEFINE([OS_NETBSD], [1], [Running on NetBSD?])
      OS_TYPE="BSD"
      BSD_TYPE="NetBSD"
      CPPFLAGS="$CPPFLAGS -DOS_BSD"
      ;;
    *-openbsd*)
      AC_DEFINE([OS_BSD], [1], [Running on BSD?])
      AC_DEFINE([OS_OPENBSD], [1], [Running on OpenBSD?])
547
      OS_TYPE="BSD"
548
      BSD_TYPE="OpenBSD"
549 550
      CPPFLAGS="$CPPFLAGS -DOS_BSD"
      ;;
551 552
    *-solaris*)
      AC_DEFINE([OS_SOLARIS], [1], [Running on Solaris?])
553
      OS_TYPE="Solaris"
554
      CPPFLAGS="$CPPFLAGS -DOS_SUN"
555 556 557
      ;;
    *)
      OS_TYPE="Unknown"
558 559
      # $host_os is more user friendly than full $host
      AC_MSG_WARN("Unsupported OS: $host_os")
560 561 562
      ;;
esac
AC_MSG_RESULT($OS_TYPE)
563 564

AM_CONDITIONAL(OS_LINUX, test $OS_TYPE = Linux)
565 566
AM_CONDITIONAL(OS_BSD, test $OS_TYPE = BSD)
AM_CONDITIONAL(OS_SOLARIS, test $OS_TYPE = Solaris)
567 568 569 570
AM_CONDITIONAL(OS_OSX, test $BSD_TYPE = OSX)
AM_CONDITIONAL(OS_FREEBSD, test $BSD_TYPE = FreeBSD)
AM_CONDITIONAL(OS_NETBSD, test $BSD_TYPE = NetBSD)
AM_CONDITIONAL(OS_OPENBSD, test $BSD_TYPE = OpenBSD)
571 572


573 574 575 576 577 578
AC_MSG_CHECKING(for sa_len in struct sockaddr)
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>],
[struct sockaddr sa; sa.sa_len = 0; return (0);],
        [AC_MSG_RESULT(yes)
579
        AC_DEFINE(HAVE_SA_LEN, 1, [Define to 1 if sockaddr has a sa_len member, and corresponding sin_len and sun_len])],
580 581
        AC_MSG_RESULT(no))

582 583 584 585 586 587 588 589 590 591 592 593 594 595
AC_MSG_CHECKING(for usuable C++11 regex)
AC_TRY_RUN([
#include <regex>
#include <iostream>
int main() {
  const std::regex regex(".*");
  const std::string string = "This should match!";
  const auto result = std::regex_search(string, regex);
  return result ? EXIT_SUCCESS : EXIT_FAILURE;
}],
        [AC_MSG_RESULT(yes)
        AC_DEFINE(USE_REGEX, 1, [Define to 1 if C++11 regex is usable])],
        AC_MSG_RESULT(no))

596
enable_gtest="no"
597
GTEST_INCLUDES=
598 599 600

AC_ARG_WITH([gtest-source],
            [AS_HELP_STRING([--with-gtest-source=PATH],
601 602
                            [location of the Googletest source])],
            [enable_gtest="yes" ; GTEST_SOURCE="$withval"])
603 604

AC_ARG_WITH([gtest],
605 606 607
            [AS_HELP_STRING([--with-gtest=PATH],
                            [specify a path to gtest header files (PATH/include) and library (PATH/lib)])],
        [gtest_path="$withval"; enable_gtest="yes"], [gtest_path="no"])
608

609
AC_ARG_WITH(lcov,
610
[  --with-lcov[=PROGRAM]         enable gtest and coverage target using the specified lcov], lcov="$withval", lcov="no")
611 612 613

USE_LCOV="no"
if test "$lcov" != "no"; then
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
        # force gtest if not set
        if test "$enable_gtest" = "no"; then
#               AC_MSG_ERROR("lcov needs gtest for test coverage report")
                AC_MSG_NOTICE([gtest support is now enabled, because used by coverage tests])
                enable_gtest="yes"
        fi
        if test "$lcov" != "yes"; then
                LCOV=$lcov
        else
                AC_PATH_PROG([LCOV], [lcov])
        fi
        if test -x "${LCOV}"; then
                USE_LCOV="yes"
        else
                AC_MSG_ERROR([Cannot find lcov.])
        fi
        # is genhtml always in the same directory?
        GENHTML=`echo "$LCOV" | ${SED} s/lcov$/genhtml/`
        if test ! -x $GENHTML; then
                AC_MSG_ERROR([genhtml not found, needed for lcov])
        fi
        # GCC specific?
        CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
        LIBS=" $LIBS -lgcov"
        AC_SUBST(CPPFLAGS)
        AC_SUBST(LIBS)
        AC_SUBST(LCOV)
        AC_SUBST(GENHTML)
642 643 644
fi
AC_SUBST(USE_LCOV)

Andrei Pavel's avatar
Andrei Pavel committed
645 646 647 648 649 650 651 652 653 654 655 656 657
enable_benchmark="no"
BENCHMARK_INCLUDES=

AC_ARG_WITH([benchmark-source],
            [AS_HELP_STRING([--with-benchmark-source=PATH],
                            [location of the benchmark source])],
            [enable_benchmark="yes" ; BENCHMARK_SOURCE="$withval"])

AC_ARG_WITH([benchmark],
            [AS_HELP_STRING([--with-benchmark=PATH],
                            [specify a path to benchmark header files (PATH/include) and library (PATH/lib)])],
        [benchmark_path="$withval"; enable_benchmark="yes"], [benchmark_path="no"])

658 659 660
# Sets up for use of botan unless openssl is specified
# sets variables CRYPTO_*
AX_CRYPTO
661

662 663 664 665
# List of directories, where tools like mysql_config or pgsql_config will be
# searched for
defaultdirs="/usr /usr/local /usr/pkg /opt /opt/local"

666
# Check for MySql.  The path to the mysql_config program is given with
667 668
# the --with-mysql-config (default to /usr/bin/mysql-config).  By default,
# the software is not built with MySQL support enabled.
669
mysql_config="no"
670 671
AC_ARG_WITH([mysql],
  AC_HELP_STRING([--with-mysql=PATH],
672
    [path to the MySQL 'mysql_config' script (MySQL is used for the DHCP database)]),
673 674
    [mysql_config="$withval"])

675 676 677 678 679 680 681 682
deprec_msg="no"
AC_ARG_WITH([dhcp-mysql],,
    [mysql_config="$withval";deprec_msg="yes"])

if test "${deprec_msg}" = "yes" ; then
    AC_MSG_WARN([--with-dhcp-mysql has been deprecated, please use --with-mysql])
fi

683
if test "${mysql_config}" = "yes" ; then
684 685 686 687 688 689 690
    for d in $defaultdirs
    do
        if test -f $d/bin/mysql_config; then
            MYSQL_CONFIG="$d/bin/mysql_config"
            break
        fi
    done
691 692 693 694 695
elif test "${mysql_config}" != "no" ; then
    MYSQL_CONFIG="${withval}"
fi

if test "$MYSQL_CONFIG" != "" ; then
696
    if test -d "$MYSQL_CONFIG" -o ! -x "$MYSQL_CONFIG" ; then
697
        AC_MSG_ERROR([--with-mysql should point to a mysql_config program])
698 699 700 701
    fi

    MYSQL_CPPFLAGS=`$MYSQL_CONFIG --cflags`
    MYSQL_LIBS=`$MYSQL_CONFIG --libs`
702
    MYSQL_VERSION=`$MYSQL_CONFIG --version`
703 704 705 706 707 708 709 710 711 712 713 714

    AC_SUBST(MYSQL_CPPFLAGS)
    AC_SUBST(MYSQL_LIBS)

    # Check that a simple program using MySQL functions can compile and link.
    CPPFLAGS_SAVED="$CPPFLAGS"
    LIBS_SAVED="$LIBS"

    CPPFLAGS="$MYSQL_CPPFLAGS $CPPFLAGS"
    LIBS="$MYSQL_LIBS $LIBS"

    AC_LINK_IFELSE(
715
            [AC_LANG_PROGRAM([#include <mysql.h>],
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
                             [MYSQL mysql_handle;
                              (void) mysql_init(&mysql_handle);
                             ])],
            [AC_MSG_RESULT([checking for MySQL headers and library... yes])],
            [AC_MSG_RESULT([checking for MySQL headers and library... no])
             AC_MSG_ERROR([Needs MySQL library])]
    )

    CPPFLAGS=$CPPFLAGS_SAVED
    LIBS=$LIBS_SAVED

    # Note that MYSQL is present in the config.h file
    AC_DEFINE([HAVE_MYSQL], [1], [MySQL is present])
fi

731
# Solaris puts FIONREAD in filio.h
732
AC_CHECK_HEADERS(sys/filio.h,,,)
733

734 735 736
# ... and at the shell level, so Makefile.am can take action depending on this.
AM_CONDITIONAL(HAVE_MYSQL, test "$MYSQL_CONFIG" != "")

737
pg_config="no"
738 739
AC_ARG_WITH([pgsql],
  AC_HELP_STRING([--with-pgsql=PATH],
740 741 742
    [path to the PostgreSQL 'pg_config' script]),
    [pg_config="$withval"])

743 744 745 746 747 748 749 750
deprec_msg="no"
AC_ARG_WITH([dhcp-pgsql],,
    [pg_config="$withval";deprec_msg="yes"])

if test "${deprec_msg}" = "yes" ; then
    AC_MSG_WARN([--with-dhcp-pgsql has been deprecated, please use --with-pgsql])
fi

751
if test "${pg_config}" = "yes" ; then
752 753 754 755 756 757 758
    for d in $defaultdirs
    do
        if test -f $d/bin/pg_config; then
            PG_CONFIG="$d/bin/pg_config"
            break
        fi
    done
759 760 761 762 763 764
elif test "${pg_config}" != "no" ; then
    PG_CONFIG="${withval}"
fi

if test "$PG_CONFIG" != "" ; then
    if test -d "$PG_CONFIG" -o ! -x "$PG_CONFIG" ; then
765
        AC_MSG_ERROR([--with-pgsql should point to a pg_config program])
766 767 768 769
    fi

    PGSQL_CPPFLAGS=`$PG_CONFIG --cppflags`
    PGSQL_INCLUDEDIR=`$PG_CONFIG --includedir`
770 771
    PGSQL_INCLUDEDIR_SERVER=`$PG_CONFIG --includedir-server`
    PGSQL_CPPFLAGS="$PGSQL_CPPFLAGS -I$PGSQL_INCLUDEDIR -I$PGSQL_INCLUDEDIR_SERVER"
772 773
    PGSQL_LIBS=`$PG_CONFIG --libdir`
    PGSQL_LIBS="-L$PGSQL_LIBS -lpq"
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
    PGSQL_VERSION=`$PG_CONFIG --version`

    AC_SUBST(PGSQL_CPPFLAGS)
    AC_SUBST(PGSQL_LIBS)

    # Check that a simple program using PostgreSQL functions can compile and link.
    CPPFLAGS_SAVED="$CPPFLAGS"
    LIBS_SAVED="$LIBS"

    CPPFLAGS="$PGSQL_CPPFLAGS $CPPFLAGS"
    LIBS="$PGSQL_LIBS $LIBS"

    AC_LINK_IFELSE(
            [AC_LANG_PROGRAM([#include <libpq-fe.h>],
                             [PGconn * c = PQconnectdb("dbname = 'postgres'");
                              PQfinish(c);])],
            [AC_MSG_RESULT([checking for PostgreSQL headers and library... yes])],
            [AC_MSG_RESULT([checking for PostgreSQL headers and library... no])
             AC_MSG_ERROR([Needs PostgreSQL library])]
    )

795
    AC_CHECK_HEADERS([utils/errcodes.h],,
796
    AC_MSG_ERROR([Missing required header file (errcodes.h) from PostgreSQL server-development package]))
797

798 799 800 801 802 803 804 805 806
    CPPFLAGS=$CPPFLAGS_SAVED
    LIBS=$LIBS_SAVED

    # Note that PostgreSQL is present in the config.h file
    AC_DEFINE([HAVE_PGSQL], [1], [PostgreSQL is present])
fi

# ... and at the shell level, so Makefile.am can take action depending on this.
AM_CONDITIONAL(HAVE_PGSQL, test "$PG_CONFIG" != "")
807

808
# allow building kea programs with static link to cassandra cpp-driver.
809 810 811 812
AC_ARG_ENABLE([cql-static-lib],
AS_HELP_STRING([--enable-cql-static-lib],
    [build programs with cassandra cpp driver static library [[default=no]]]),
    [enable_cql_static_lib=yes], [enable_cql_static_lib=no])
813
AM_CONDITIONAL(USE_CQL_STATIC_LIB, test "$enable_cql_static_lib" = yes)
814 815 816 817 818 819 820
#AC_DEFINE USE_CQL_STATIC_LIB? (unused)

cql_lib="cassandra"
if test "${enable_cql_static_lib}" = "yes" ; then
    cql_lib="${cql_lib}_static"
fi

Tomek Mrugalski's avatar
Tomek Mrugalski committed
821 822 823
cql_config="no"
AC_ARG_WITH([cql],
  AC_HELP_STRING([--with-cql=PATH],
824
    [path to pkg-config or the Cassandra CQL 'cql_config' script]),
Tomek Mrugalski's avatar
Tomek Mrugalski committed
825 826 827
    [cql_config="$withval"])

if test "${cql_config}" = "yes" ; then
828
    CQL_CONFIG="$PKG_CONFIG"
Tomek Mrugalski's avatar
Tomek Mrugalski committed
829
elif test "${cql_config}" != "no" ; then
830
    CQL_CONFIG="${cql_config}"
831 832
fi

Tomek Mrugalski's avatar
Tomek Mrugalski committed
833 834
if test "$CQL_CONFIG" != "" ; then
    if test -d "$CQL_CONFIG" -o ! -x "$CQL_CONFIG" ; then
835
        AC_MSG_ERROR([--with-cql should point to a pkg-config or cql_config program])
836 837
    fi

838
    CQL_INCLUDEDIR=`$CQL_CONFIG --cflags-only-I $cql_lib`
839
    CQL_CPPFLAGS="$CQL_INCLUDEDIR `$CQL_CONFIG --cflags-only-other $cql_lib`"
840
    CQL_LIBS="`$CQL_CONFIG --libs $cql_lib`"
841
    CQL_VERSION=`$CQL_CONFIG --modversion $cql_lib`
842

Tomek Mrugalski's avatar
Tomek Mrugalski committed
843 844
    AC_SUBST(CQL_CPPFLAGS)
    AC_SUBST(CQL_LIBS)
845

Tomek Mrugalski's avatar
Tomek Mrugalski committed
846
    # Check that a simple program using CQL functions can compile and link.
847 848 849
    CPPFLAGS_SAVED="$CPPFLAGS"
    LIBS_SAVED="$LIBS"

Tomek Mrugalski's avatar
Tomek Mrugalski committed
850 851
    CPPFLAGS="$CQL_CPPFLAGS $CPPFLAGS"
    LIBS="$CQL_LIBS $LIBS"
852 853 854 855 856

    AC_LINK_IFELSE(
            [AC_LANG_PROGRAM([#include <cassandra.h>],
                             [CassCluster* cluster = cass_cluster_new();
                              cass_cluster_free(cluster);])],
Tomek Mrugalski's avatar
Tomek Mrugalski committed
857 858 859
            [AC_MSG_RESULT([checking for Cassandra CQL headers and library... yes])],
            [AC_MSG_RESULT([checking for Cassandra CQL headers and library... no])
             AC_MSG_ERROR([Needs Cassandra CQL library])]
860 861 862 863
    )
    CPPFLAGS=$CPPFLAGS_SAVED
    LIBS=$LIBS_SAVED

Tomek Mrugalski's avatar
Tomek Mrugalski committed
864 865
    # Note that CQL is present in the config.h file
    AC_DEFINE([HAVE_CQL], [1], [CQL is present])
866 867 868
fi

# ... and at the shell level, so Makefile.am can take action depending on this.
Tomek Mrugalski's avatar
Tomek Mrugalski committed
869
AM_CONDITIONAL(HAVE_CQL, test "$CQL_CONFIG" != "")
870

871
DISTCHECK_SYSREPO_CONFIGURE_FLAG=
872 873 874
sysrepo_config="no"
AC_ARG_WITH([sysrepo],
  AC_HELP_STRING([--with-sysrepo=PATH],
875
    [path to pkg-config or the Sysrepo 'sysrepo_config' script]),
876 877 878 879
    [sysrepo_config="$withval"])

if test "${sysrepo_config}" = "yes" ; then
    SYSREPO_CONFIG="$PKG_CONFIG"
880
    DISTCHECK_SYSREPO_CONFIGURE_FLAG="-with-sysrepo=${sysrepo_config}"
881 882
elif test "${sysrepo_config}" != "no" ; then
    SYSREPO_CONFIG="${sysrepo_config}"
883
    DISTCHECK_SYSREPO_CONFIGURE_FLAG="-with-sysrepo=${sysrepo_config}"
884
fi
885
AC_SUBST(DISTCHECK_SYSREPO_CONFIGURE_FLAG)
886

887
if test "$SYSREPO_CONFIG" != "" ; then
888
    if test -d "$SYSREPO_CONFIG" -o ! -x "$SYSREPO_CONFIG" ; then
889
        AC_MSG_ERROR([--with-sysrepo should point to a pkg-config or sysrepo_config program])
890 891
    fi

892
    # Let's get the configuration environment for pure Sysrepo (written in C) first
893 894 895 896
    SYSREPO_INCLUDEDIR=`$SYSREPO_CONFIG --cflags-only-I libsysrepo`
    SYSREPO_CPPFLAGS="$SYSREPO_INCLUDEDIR `$SYSREPO_CONFIG --cflags-only-other libsysrepo`"
    SYSREPO_LIBS="`$SYSREPO_CONFIG --libs libsysrepo`"
    SYSREPO_VERSION=`$SYSREPO_CONFIG --modversion libsysrepo`
897
    SYSREPO_REPO=`$SYSREPO_CONFIG --variable=SR_REPOSITORY_LOC libsysrepo`
898

899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918
    # Now get the environment for C++ bindings for Sysrepo.
    SYSREPOCPP_INCLUDEDIR=`$SYSREPO_CONFIG --cflags-only-I libSysrepo-cpp`
    SYSREPOCPP_CPPFLAGS="$SYSREPO_INCLUDEDIR `$SYSREPO_CONFIG --cflags-only-other libSysrepo-cpp`"
    SYSREPOCPP_LIBS="`$SYSREPO_CONFIG --libs libSysrepo-cpp`"
    SYSREPOCPP_VERSION=`$SYSREPO_CONFIG --modversion libSysrepo-cpp`

    # If include paths are equal, there's no need to include both. But if they're different,
    # we need both.
    if test "${SYSREPO_INCLUDEDIR}" != "${SYSREPOCPP_INCLUDEDIR}"; then
       SYSREPO_INCLUDEDIR="${SYSREPO_INCLUDEDIR} ${SYSREPOCPP_INCLUDEDIR}"
    fi

    if test "${SYSREPO_CPPFLAGS}" != "${SYSREPOCPP_CPPFLAGS}"; then
       SYSREPO_CPPFLAGS="${SYSREPO_CPPFLAGS} ${SYSREPOCPP_CPPFLAGS}"
    fi

    if test "${SYSREPO_LIBS}" != "${SYSREPOCPP_LIBS}"; then
       SYSREPO_LIBS="${SYSREPO_LIBS} ${SYSREPOCPP_LIBS}"
    fi

919 920
    AC_SUBST(SYSREPO_CPPFLAGS)
    AC_SUBST(SYSREPO_LIBS)
921
    AC_SUBST(SYSREPO_REPO)
922

923
    # Check that a simple program using Sysrepo functions can compile and link.
924 925 926 927 928 929 930
    CPPFLAGS_SAVED="$CPPFLAGS"
    LIBS_SAVED="$LIBS"

    CPPFLAGS="$SYSREPO_CPPFLAGS $CPPFLAGS"
    LIBS="$SYSREPO_LIBS $LIBS"

    AC_LINK_IFELSE(
931 932 933
            [AC_LANG_PROGRAM([extern "C" {
                              #include <sysrepo.h>
                              }],
934 935 936 937 938 939 940 941
                              [sr_conn_ctx_t *connection = NULL;
                              sr_session_ctx_t *session = NULL;
                              sr_connect("configure_test", SR_CONN_DEFAULT, &connection);
                              sr_disconnect(connection);])],
            [AC_MSG_RESULT([checking for Sysrepo headers and library... yes])],
            [AC_MSG_RESULT([checking for Sysrepo headers and library... no])
             AC_MSG_ERROR([Needs Sysrepo library])]
    )
942 943

    AC_LINK_IFELSE(
944 945 946 947 948 949 950 951 952
        [AC_LANG_PROGRAM(
            [#include <sysrepo-cpp/Session.hpp>],
            [sysrepo::Connection("conn-name");])],
        [AC_MSG_RESULT([checking for Sysrepo C++ bindings headers and library... yes])],
        [AC_LINK_IFELSE(
            [AC_LANG_PROGRAM(
                [#include <sysrepo-cpp/Session.h>],
                [Connection("conn-name");])],
            [AC_MSG_RESULT([checking for Sysrepo C++ bindings headers and library... old])
953
             AC_DEFINE([HAVE_PRE_0_7_6_SYSREPO], [1], [Using sysrepo < 0.7.6])],
954 955 956
             [AC_MSG_RESULT([checking for Sysrepo C++ bindings headers and library... no])
              AC_MSG_ERROR([Needs Sysrepo C++ bindings (unable to find Sysrepo-ccp library. To get it, you need to compile sysrepo with -DGEN_CPP_BINDINGS=ON.)])]
        )]
957 958
    )

959 960 961
    CPPFLAGS=$CPPFLAGS_SAVED
    LIBS=$LIBS_SAVED

962
    # Note that Sysrepo is present in the config.h file
963 964 965 966 967 968
    AC_DEFINE([HAVE_SYSREPO], [1], [SYSREPO is present])
fi

# ... and at the shell level, so Makefile.am can take action depending on this.
AM_CONDITIONAL(HAVE_SYSREPO, test "$SYSREPO_CONFIG" != "")

969
# Check for log4cplus
970
DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG=
971 972 973 974 975
log4cplus_path="yes"
AC_ARG_WITH([log4cplus],
  AC_HELP_STRING([--with-log4cplus=PATH],
    [specify exact directory of log4cplus library and headers]),
    [log4cplus_path="$withval"])
976
if test "${log4cplus_path}" = "no" ; then
977 978
    AC_MSG_ERROR([Need log4cplus])
elif test "${log4cplus_path}" != "yes" ; then
979
  DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG="-with-log4cplus=${log4cplus_path}"
980
  LOG4CPLUS_INCLUDES="-I${log4cplus_path}/include"
981
  LOG4CPLUS_LIBS="-L${log4cplus_path}/lib"
982 983
else
# If not specified, try some common paths.
984
        for d in $defaultdirs
985 986 987 988 989 990 991
        do
                if test -f $d/include/log4cplus/logger.h; then
                        LOG4CPLUS_INCLUDES="-I$d/include"
                        LOG4CPLUS_LIBS="-L$d/lib -L$d/lib64"
                        break
                fi
        done
992
	DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG="-with-log4cplus"
993 994
fi

995
LOG4CPLUS_LIBS="$LOG4CPLUS_LIBS -llog4cplus"
996

997
AC_SUBST(DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG)
998
AC_SUBST(LOG4CPLUS_LIBS)
999 1000 1001 1002
AC_SUBST(LOG4CPLUS_INCLUDES)

CPPFLAGS_SAVED=$CPPFLAGS
CPPFLAGS="$LOG4CPLUS_INCLUDES $CPPFLAGS"
1003
LIBS_SAVED="$LIBS"
1004
LIBS="$LOG4CPLUS_LIBS $MULTITHREADING_FLAG $LIBS"
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017

AC_CHECK_HEADERS([log4cplus/logger.h],,AC_MSG_ERROR([Missing required header files.]))
AC_LINK_IFELSE(
        [AC_LANG_PROGRAM([#include <log4cplus/logger.h>
                         ],
                         [using namespace log4cplus;
                          Logger logger = Logger::getInstance("main");
                         ])],
        [AC_MSG_RESULT([checking for log4cplus library... yes])],
        [AC_MSG_RESULT([checking for log4cplus library... no])
         AC_MSG_ERROR([Needs log4cplus library])]
)

1018 1019 1020
dnl Determine the log4cplus version, used mainly for config.report.
AC_MSG_CHECKING([log4cplus version])
cat > conftest.cpp << EOF
1021
#include <log4cplus/version.h>
1022 1023 1024
AUTOCONF_LOG4CPLUS_VERSION=LOG4CPLUS_VERSION_STR
EOF

1025
LOG4CPLUS_VERSION=`$CPPP $CPPFLAGS conftest.cpp | grep '^AUTOCONF_LOG4CPLUS_VERSION=' | $SED -e 's/^AUTOCONF_LOG4CPLUS_VERSION=//' -e 's/[[ 	]]//g' -e 's/"//g' 2> /dev/null`
1026 1027 1028 1029 1030 1031
if test -z "$LOG4CPLUS_VERSION"; then
  LOG4CPLUS_VERSION="unknown"
fi
$RM -f conftest.cpp
AC_MSG_RESULT([$LOG4CPLUS_VERSION])

1032
CPPFLAGS=$CPPFLAGS_SAVED
1033
LIBS=$LIBS_SAVED
1034

1035 1036 1037
#
# Configure Boost header path
#
1038
AX_BOOST_FOR_KEA
1039 1040
# Boost offset_ptr is required in one library and not optional right now, so
# we unconditionally fail here if it doesn't work.
1041
if test "$BOOST_OFFSET_PTR_WOULDFAIL" = "yes" -a X"$werror_ok" = X1; then
1042
    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.])
1043
fi
1044

1045 1046 1047 1048
if test "$BOOST_STATIC_ASSERT_WOULDFAIL" = "yes" -a X"$werror_ok" = X1; then
    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.])
fi

1049
# There's a known bug in FreeBSD ports for Boost that would trigger a false
1050 1051
# warning in build with g++ and -Werror (we exclude clang++ explicitly to
# avoid unexpected false positives).
1052
if test "$BOOST_NUMERIC_CAST_WOULDFAIL" = "yes" -a X"$werror_ok" = X1 -a $CLANGPP = "no"; then
1053 1054 1055 1056
    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.])
fi

# Add some default CPP flags needed for Boost, identified by the AX macro.
1057
CPPFLAGS="$CPPFLAGS $CPPFLAGS_BOOST_THREADCONF"
1058

1059
# Can be required by gtest, boost and perhaps still asio
1060
AC_CHECK_LIB(pthread, pthread_create,[ LDFLAGS="$LDFLAGS -lpthread" ], [])
1061

1062
#
1063
# Check availability of gtest, which will be used for unit tests.
1064
#
1065 1066 1067
GTEST_LDFLAGS=
GTEST_LDADD=
DISTCHECK_GTEST_CONFIGURE_FLAG=
1068
GTEST_VERSION="unknown"
1069

1070
if test "x$enable_gtest" = "xyes" ; then
1071

1072 1073
    DISTCHECK_GTEST_CONFIGURE_FLAG="--with-gtest=$gtest_path"

1074
    if test -n "$with_gtest_source" ; then
1075

1076
        if test "x$GTEST_SOURCE" = "xyes" ; then
1077

1078
            AC_MSG_CHECKING([for gtest source])
1079
            # If not specified, try some common paths.
1080
            GTEST_SOURCE=
1081 1082 1083 1084 1085 1086 1087
            for d in /usr/src/gtest /usr/local /usr/pkg /opt /opt/local ; do
                if test -f $d/src/gtest-all.cc -a $d/src/gtest_main.cc; then
                    GTEST_SOURCE=$d
                    AC_MSG_RESULT([$GTEST_SOURCE])
                    break
                fi
            done
1088
            if test -z $GTEST_SOURCE ; then
1089
                AC_MSG_ERROR([no gtest source but it was selected])
1090
            fi
1091
        else
1092 1093 1094
            if test ! -d $GTEST_SOURCE/src -a -d $GTEST_SOURCE/googletest; then
                GTEST_SOURCE=$GTEST_SOURCE/googletest
            fi
1095
            AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc]
1096 1097 1098 1099 1100
                [$GTEST_SOURCE/src/gtest_main.cc],
                [have_gtest_source=yes],
                [AC_MSG_ERROR([no gtest source at $GTEST_SOURCE])])
        fi
        have_gtest_source=yes
1101
        GTEST_LDADD="\$(top_builddir)/ext/gtest/libgtest.a"
1102 1103
        DISTCHECK_GTEST_CONFIGURE_FLAG="--with-gtest-source=$GTEST_SOURCE"
        GTEST_INCLUDES="-I$GTEST_SOURCE -I$GTEST_SOURCE/include"
1104
        GTEST_VERSION="`basename $GTEST_SOURCE`"
1105
    fi
1106 1107 1108 1109 1110 1111 1112 1113 1114

    if test "$gtest_path" != "no" ; then
        if test "$gtest_path" != "yes"; then
            GTEST_PATHS=$gtest_path
            if test -x "${gtest_path}/bin/gtest-config" ; then
                GTEST_CONFIG="${gtest_path}/bin/gtest-config"
            fi
        else
            AC_PATH_PROG([GTEST_CONFIG], [gtest-config])
1115
        fi
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126
        if test -x "${GTEST_CONFIG}" ; then :
            # using cppflags instead of cxxflags
            GTEST_INCLUDES=`${GTEST_CONFIG} --cppflags`
            GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`
            GTEST_LDADD=`${GTEST_CONFIG} --libs`
            GTEST_VERSION=`${GTEST_CONFIG} --version`
            GTEST_FOUND="true"
        else
            AC_MSG_WARN([Unable to locate Google Test gtest-config.])
            if test -z "${GTEST_PATHS}" ; then
                GTEST_PATHS="/usr /usr/local"
1127
            fi
1128 1129 1130 1131 1132 1133
            GTEST_FOUND="false"
        fi
        if test "${GTEST_FOUND}" != "true"; then
            GTEST_FOUND="false"
            for dir in $GTEST_PATHS; do
                if test -f "$dir/include/gtest/gtest.h"; then
1134 1135 1136 1137
                    if ! test -f "$dir/lib/libgtests.a"; then
                        AC_MSG_WARN([Found Google Test include but not the library in $dir.])
                        continue
                    fi
1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148
                    GTEST_INCLUDES="-I$dir/include"
                    GTEST_LDFLAGS="-L$dir/lib"
                    GTEST_LDADD="-lgtest"
                    GTEST_FOUND="true"
                    break
                fi
            done
        fi
        if test "${GTEST_FOUND}" != "true"; then
            AC_MSG_ERROR([Cannot find gtest in: $GTEST_PATHS])
        fi
1149

1150
    fi
1151
fi
1152 1153
AM_CONDITIONAL(HAVE_GTEST, test $enable_gtest != "no")
AM_CONDITIONAL(HAVE_GTEST_SOURCE, test "X$have_gtest_source" = "Xyes")
1154
AC_SUBST(DISTCHECK_GTEST_CONFIGURE_FLAG)
1155 1156 1157
AC_SUBST(GTEST_INCLUDES)
AC_SUBST(GTEST_LDFLAGS)
AC_SUBST(GTEST_LDADD)
1158
AC_SUBST(GTEST_SOURCE)
1159

Andrei Pavel's avatar
Andrei Pavel committed
1160 1161 1162
#
# Check availability of benchmark.
#
1163
BENCHMARK_CPPFLAGS=
Andrei Pavel's avatar
Andrei Pavel committed
1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198
BENCHMARK_LDFLAGS=
BENCHMARK_LDADD=
DISTCHECK_BENCHMARK_CONFIGURE_FLAG=
BENCHMARK_VERSION="unknown"

if test "x$enable_benchmark" = "xyes" ; then

    DISTCHECK_BENCHMARK_CONFIGURE_FLAG="--with-benchmark=$benchmark_path"

    if test -n "$with_benchmark_source" ; then

        if test "x$BENCHMARK_SOURCE" = "xyes" ; then

            AC_MSG_CHECKING([for benchmark source])
            # If not specified, try some common paths.
            BENCHMARK_SOURCE=
            for d in /usr/src/benchmark /usr/local /usr/pkg /opt /opt/local ; do
                if test -f $d/src/benchmark.cc; then
                    BENCHMARK_SOURCE=$d
                    AC_MSG_RESULT([$BENCHMARK_SOURCE])
                    break
                fi
            done
            if test -z $BENCHMARK_SOURCE ; then
                AC_MSG_ERROR([no benchmark source but it was selected])
            fi
        else
            if test ! -d $BENCHMARK_SOURCE/src; then
                BENCHMARK_SOURCE=$BENCHMARK_SOURCE/benchmark
            fi
            AC_CHECK_FILES([$BENCHMARK_SOURCE/src/benchmark.cc],
                [have_benchmark_source=yes],
                [AC_MSG_ERROR([no benchmark source at $BENCHMARK_SOURCE])])
        fi
        have_benchmark_source=yes
1199 1200
        BENCHMARK_CPPFLAGS=`cat \${BENCHMARK_SOURCE}/build/src/CMakeFiles/benchmark.dir/flags.make | grep CXX_DEFINES | cut -d "=" -f 2`
        BENCHMARK_LDADD="\$(BENCHMARK_SOURCE)/build/src/libbenchmark.a"
Andrei Pavel's avatar
Andrei Pavel committed
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212
        DISTCHECK_BENCHMARK_CONFIGURE_FLAG="--with-benchmark-source=$BENCHMARK_SOURCE"
        BENCHMARK_INCLUDES="-I$BENCHMARK_SOURCE \
                            -I$BENCHMARK_SOURCE/src \
                            -I$BENCHMARK_SOURCE/include \
                            -I$BENCHMARK_SOURCE/include/benchmark"
        BENCHMARK_VERSION="$(basename $BENCHMARK_SOURCE)"
    fi

    if test "$benchmark_path" != "no" ; then
        if test "$benchmark_path" != "yes"; then
            BENCHMARK_PATHS=$benchmark_path
        fi
1213 1214
        if test -z "${BENCHMARK_PATHS}" ; then
            BENCHMARK_PATHS="/usr /usr/local"
Andrei Pavel's avatar
Andrei Pavel committed
1215
        fi
1216 1217 1218 1219 1220 1221
        BENCHMARK_FOUND="false"
        for dir in ${BENCHMARK_PATHS}; do
            if test -f "$dir/include/benchmark/benchmark.h"; then
                if ! test -f "$dir/lib/libbenchmark.a"; then
                    AC_MSG_WARN([Found Google Benchmark include but not the library in $dir.])
                    continue
Andrei Pavel's avatar
Andrei Pavel committed
1222
                fi
1223 1224 1225 1226 1227 1228 1229
                BENCHMARK_INCLUDES="-I$dir/include"
                BENCHMARK_LDFLAGS="-L$dir/lib"
                BENCHMARK_LDADD="$dir/lib/libbenchmark.a "
                BENCHMARK_FOUND="true"
                break
            fi
        done
Andrei Pavel's avatar
Andrei Pavel committed
1230 1231 1232 1233 1234 1235 1236 1237 1238
        if test "${BENCHMARK_FOUND}" != "true"; then
            AC_MSG_ERROR([Cannot find benchmark in: $BENCHMARK_PATHS])
        fi

    fi
fi
AM_CONDITIONAL(HAVE_BENCHMARK, test $enable_benchmark != "no")
AM_CONDITIONAL(HAVE_BENCHMARK_SOURCE, test "X$have_benchmark_source" = "Xyes")
AC_SUBST(DISTCHECK_BENCHMARK_CONFIGURE_FLAG)
1239
AC_SUBST(BENCHMARK_CPPFLAGS)
Andrei Pavel's avatar
Andrei Pavel committed
1240 1241 1242 1243 1244
AC_SUBST(BENCHMARK_INCLUDES)
AC_SUBST(BENCHMARK_LDFLAGS)
AC_SUBST(BENCHMARK_LDADD)
AC_SUBST(BENCHMARK_SOURCE)

1245 1246 1247 1248 1249 1250
#
# Some Googletest versions bug with C++11 compilers
#
if test $enable_gtest != "no"; then
   AC_MSG_CHECKING([if Google Test is compatible with the compiler])
   CPPFLAGS_SAVED=$CPPFLAGS
1251
   CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES $GTEST_INCLUDES"
1252 1253
   AC_COMPILE_IFELSE(
       [AC_LANG_PROGRAM(
1254 1255 1256 1257 1258
            [#include <boost/shared_ptr.hpp>
            #include <gtest/gtest.h>
            void foo() {
                boost::shared_ptr<int> bar;
                ASSERT_TRUE(bar);
1259
            }],
1260 1261 1262
            [return 0;])],
        [AC_MSG_RESULT(yes)],
        [AC_MSG_ERROR([XXX_TRUE() Google Test macros won't compile; the most likely reason is that a later version of Google Test is required])])
1263 1264
    CPPFLAGS=$CPPFLAGS_SAVED
fi
1265

1266 1267 1268 1269 1270 1271 1272
# Check for CreateUnifiedDiff from gtest >= 1.8.0
if test $enable_gtest != "no"; then
   AC_MSG_CHECKING([for CreateUnifiedDiff in $GTEST_INCLUDES/gtest.h])
   CPPFLAGS_SAVED=$CPPFLAGS
   CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES $GTEST_INCLUDES"
   AC_COMPILE_IFELSE(
       [AC_LANG_PROGRAM(
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
            [#include <boost/algorithm/string.hpp>
            #include <gtest/gtest.h>
            #include <string>
            #include <vector>
            std::string nodiff(std::string text) {
                std::vector<std::string> lines;
                boost::split(lines, text, boost::is_any_of("\n"));
                using namespace testing::internal;
                return (edit_distance::CreateUnifiedDiff(lines, lines));
            }],
            [return 0;])],
        [AC_MSG_RESULT(yes)
        AC_DEFINE([HAVE_CREATE_UNIFIED_DIFF], [1],
        [Define to 1 if gtest defines edit_distance::CreateUnifiedDiff])],
        [AC_MSG_RESULT(no)])
1288
    CPPFLAGS=$CPPFLAGS_SAVED
1289
fi
1290

1291 1292
#
# ASIO: we extensively use it as the C++ event management module.
1293 1294 1295 1296
#
# Use our 'coroutine' header from ext
# CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/ext/coroutine"

1297
#
1298 1299
# Doesn't seem to be required?
CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_HEADER_ONLY"
1300
#
1301
# Disable threads: they seems to break things on some systems
1302 1303
# As now we use threads in boost ASIO this is commented out...
# CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_DISABLE_THREADS=1"
1304 1305 1306 1307 1308 1309 1310 1311

# We tried to stay header only
if test "x${BOOST_LIBS}" = "x"; then
   # Don't want boost system library
   CPPFLAGS="$CPPFLAGS -DBOOST_ERROR_CODE_HEADER_ONLY"
   # Avoid boost::system::throws multiple defines
   CPPFLAGS="$CPPFLAGS -DBOOST_SYSTEM_NO_DEPRECATED"
fi
1312

1313
# Check for functions that are not available on all platforms
1314
AC_CHECK_FUNCS([pselect srandomdev])
1315

1316 1317 1318 1319
# /dev/poll issue: ASIO uses /dev/poll by default if it's available (generally
# the case with Solaris).  Unfortunately its /dev/poll specific code would
# trigger the gcc's "missing-field-initializers" warning, which would
# subsequently make the build fail with -Werror.  Further, older versions of
1320
# gcc don't provide an option to selectively suppress this warning.
1321 1322 1323
# So, for the moment, we simply disable the use of /dev/poll.  Unless we
# implement recursive DNS server with randomized ports, we don't need the
# scalability that /dev/poll can provide, so this decision wouldn't affect
Jeremy C. Reed's avatar
Jeremy C. Reed committed
1324
# run time performance.  Hopefully we can find a better solution or the ASIO
1325 1326
# code will be updated by the time we really need it.
AC_CHECK_HEADERS(sys/devpoll.h, ac_cv_have_devpoll=yes, ac_cv_have_devpoll=no)
1327
if test "X$ac_cv_have_devpoll" = "Xyes" -a "X$GXX" = "Xyes"; then
1328
    CPPFLAGS="$CPPFLAGS -DBOOST_ASIO_DISABLE_DEV_POLL=1"
1329
fi
1330

1331 1332 1333 1334 1335
#
# Perl is optional; it is used only by some of the system test scripts.
#
AC_PATH_PROGS(PERL, perl5 perl)
AC_SUBST(PERL)
1336 1337
AC_PATH_PROGS(AWK, gawk awk)
AC_SUBST(AWK)
1338

1339 1340 1341 1342 1343
AC_ARG_ENABLE(generate_parser, [AC_HELP_STRING([--enable-generate-parser],
  [indicates that the parsers will be regenerated. This implies that the
   bison and flex are required [default=no]])],
   enable_generate_parser=$enableval, enable_generate_parser=no)

Josh Soref's avatar
Josh Soref committed
1344
# Check if flex is available. Flex is not needed for building Kea sources,
1345
# unless you want to regenerate grammars
1346 1347 1348
AC_PROG_LEX

# Check if bison is available. Bison is not needed for building Kea sources,
1349
# unless you want to regenerate grammars
1350 1351
AC_PROG_YACC

1352
if test "x$enable_generate_parser" != "xno"; then
1353 1354

    if test "x$LEX" == "x"; then
1355
       AC_MSG_ERROR([Flex is required for enable-generate-parser, but was not found])
1356 1357 1358
    fi

    if test "x$YACC" == "x"; then
1359
       AC_MSG_ERROR([Bison is required for enable-generate-parser, but was not found])
1360 1361 1362
    fi

# Ok, let's check if we have at least 3.0.0 version of the bison. The code used
1363
# to generate parsers is roughly based on bison 3.0 examples.
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375
   cat > bisontest.y << EOF
%require "3.0.0"
%token X
%%
%start Y;
Y: X;
EOF
# Try to compile.
    $YACC bisontest.y -o bisontest.cc

    if test $? -ne 0 ; then
        $YACC -V
1376
        $RM -f bisontest.y bisontest.cc
1377 1378
        AC_MSG_ERROR("Error with $YACC. Possibly incorrect version? Required at least 3.0.0.")
    fi
1379
    $RM -f bisontest.y bisontest.cc
1380 1381
fi

1382 1383
AM_CONDITIONAL([GENERATE_PARSER], [test x$enable_generate_parser != xno])

1384 1385 1386
AC_ARG_ENABLE(generate_docs, [AC_HELP_STRING([--enable-generate-docs],
  [regenerate documentation using Docbook [default=no]])],
  enable_generate_docs=$enableval, enable_generate_docs=no)
1387

1388
if test "x$enable_generate_docs" != xno ; then
1389 1390

# Check for xsltproc
1391 1392
  AC_PATH_PROG([XSLTPROC], [xsltproc])
  if test -z "$XSLTPROC"; then
1393
    AC_MSG_ERROR("xsltproc not found; it is required for --enable-generate-docs")
1394 1395 1396
  else
    AC_MSG_CHECKING([if $XSLTPROC works])
    # run xsltproc to see if works
1397
    $XSLTPROC --novalid --xinclude http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
1398 1399 1400
    if test $? -ne 0 ; then
      AC_MSG_ERROR("Error with $XSLTPROC using release/xsl/current/manpages/docbook.xsl")
    fi
1401
    $XSLTPROC --novalid --xinclude http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl
1402 1403 1404
    if test $? -ne 0 ; then
      AC_MSG_ERROR("Error with $XSLTPROC using release/xsl/current/html/docbook.xsl")
    fi
1405
    AC_MSG_RESULT(yes)
1406
  fi
1407 1408 1409 1410 1411

  AC_PATH_PROG([ELINKS], [elinks])
  if test -z "$ELINKS"; then
    AC_MSG_ERROR("elinks not found; it is required for --enable-generate-docs")
  fi
1412 1413
fi

1414 1415 1416
# Don't fail here if not found, used to generate PDF documentation.
AC_PATH_PROG([DBLATEX], [dblatex])
AM_CONDITIONAL(HAVE_DBLATEX, test "x$DBLATEX" != "x")
1417

1418
AM_CONDITIONAL(GENERATE_DOCS, test x$enable_generate_docs != xno)
1419

1420 1421 1422
AC_ARG_ENABLE(install-configurations,
  [AC_HELP_STRING([--disable-install-configurations],
  [do not install configuration])], install_configurations=$enableval, install_configurations=yes)
1423

1424
AM_CONDITIONAL(INSTALL_CONFIGURATIONS, test x$install_configurations = xyes || test x$install_configurations = xtrue)
1425

1426 1427 1428 1429 1430
AC_ARG_ENABLE(logger-checks, [AC_HELP_STRING([--enable-logger-checks],
  [check logger messages [default=no]])], enable_logger_checks=$enableval, enable_logger_checks=no)
AM_CONDITIONAL(ENABLE_LOGGER_CHECKS, test x$enable_logger_checks != xno)
AM_COND_IF([ENABLE_LOGGER_CHECKS], [AC_DEFINE([ENABLE_LOGGER_CHECKS], [1], [Check logger messages?])])

1431 1432 1433 1434 1435 1436 1437 1438
# Check for asciidoc
AC_PATH_PROG(ASCIIDOC, asciidoc, no)
AM_CONDITIONAL(HAVE_ASCIIDOC, test "x$ASCIIDOC" != "xno")

# Check for plantuml
AC_PATH_PROG(PLANTUML, plantuml, no)
AM_CONDITIONAL(HAVE_PLANTUML, test "x$PLANTUML" != "xno")

1439 1440 1441 1442
# Check for valgrind
AC_PATH_PROG(VALGRIND, valgrind, no)
AM_CONDITIONAL(HAVE_VALGRIND, test "x$VALGRIND" != "xno")

1443 1444 1445 1446 1447 1448 1449
# Also check for valgrind headers
# We could consider adding them to the source code tree, as this
# is the encouraged method of using them; they are BSD-licensed.
# However, until we find that this is a problem, we just use
# the system-provided ones, if available
AC_CHECK_HEADERS(valgrind/valgrind.h, [AC_DEFINE([HAVE_VALGRIND_HEADERS], [1], [Check valgrind headers])])

1450 1451 1452
found_valgrind="not found"
if test "x$VALGRIND" != "xno"; then
   found_valgrind="found"
1453 1454
fi

1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465
# Check for optreset in unistd.h. On BSD systems the optreset is
# used to reset the state of getopt() function. Resetting its state
# is required if command line arguments are parsed multiple times
# during a program. On Linux this variable will not exist because
# getopt() reset is performed by setting optind = 0. On Operating
# Systems where optreset is defined use optreset = 1 and optind = 1
# to reset internal state of getopt(). Failing to do so will result
# in unpredictable output from getopt().
AC_MSG_CHECKING([whether optreset variable is defined in unistd.h])
AC_TRY_LINK(
    [#include <unistd.h>],
1466
    [extern int optreset; optreset=1;],
1467 1468 1469 1470 1471 1472
    [ AC_MSG_RESULT(yes)
      var_optreset_exists=yes],
    [ AC_MSG_RESULT(no)
      var_optreset_exists=no]
)
AM_CONDITIONAL(HAVE_OPTRESET, test "x$var_optreset_exists" != "xno")
1473
AM_COND_IF([HAVE_OPTRESET], [AC_DEFINE([HAVE_OPTRESET], [1], [Check for optreset?])])
1474

1475 1476
AC_DEFINE([CONFIG_H_WAS_INCLUDED], [1], [config.h inclusion marker])