Code

store: Don't report an error if a missing writer callback isn't used.
[sysdb.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl This is the SysDB configure script.
4 dnl
5 dnl Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
6 dnl All rights reserved.
7 dnl
8 dnl Redistribution and use in source and binary forms, with or without
9 dnl modification, are permitted provided that the following conditions
10 dnl are met:
11 dnl 1. Redistributions of source code must retain the above copyright
12 dnl    notice, this list of conditions and the following disclaimer.
13 dnl 2. Redistributions in binary form must reproduce the above copyright
14 dnl    notice, this list of conditions and the following disclaimer in the
15 dnl    documentation and/or other materials provided with the distribution.
16 dnl
17 dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 dnl PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21 dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 dnl OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 dnl WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 dnl ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 AC_INIT([System DataBase],[m4_esyscmd(./version-gen.sh)],
30                 [sysdb@sysdb.io],
31                 [sysdb],
32                 [https://sysdb.io/])
33 PACKAGE_MAINTAINER="Sebastian 'tokkee' Harl <tokkee@sysdb.io>"
34 AC_DEFINE_UNQUOTED([PACKAGE_MAINTAINER], ["$PACKAGE_MAINTAINER"],
35                 [Define to the name of the maintainer of this package.])
36 if test "x$PACKAGE_URL" = "x"; then
37         PACKAGE_URL="https://sysdb.io/"
38         AC_DEFINE_UNQUOTED([PACKAGE_URL], ["$PACKAGE_URL"],
39                         [Define to the home page for this package.])
40 fi
42 AC_CONFIG_SRCDIR([src/sysdb.c])
43 AC_CONFIG_HEADERS([src/config.h])
44 AC_PREFIX_DEFAULT([/opt/sysdb])
46 AM_INIT_AUTOMAKE([foreign subdir-objects -Wall])
48 AC_LANG(C)
50 AC_SYS_LARGEFILE
52 AC_PROG_CC
53 AC_PROG_CXX
54 AC_PROG_CPP
55 AC_PROG_INSTALL
56 AC_PROG_LN_S
57 AC_PROG_MAKE_SET
58 m4_ifdef([AM_PROG_AR],[AM_PROG_AR],[])
60 AM_PROG_CC_C_O
61 AM_PROG_LEX
62 AC_PROG_YACC
64 m4_ifdef([LT_INIT],
65         [
66          LT_CONFIG_LTDL_DIR([libltdl])
67          LT_INIT([dlopen])
68          LTDL_INIT([convenience])
69         ],
70         # else
71         # (older libtools)
72         [
73          AC_CONFIG_SUBDIRS(libltdl)
74          AC_LIBLTDL_CONVENIENCE
75          AC_SUBST(LTDLINCL)
76          AC_SUBST(LIBLTDL)
77          AC_LIBTOOL_DLOPEN
78         ]
79 )
81 test_cc_flags() {
82         AC_LANG_CONFTEST([int main(void){}])
83         $CC -c conftest.c $CFLAGS $STRICT_CFLAGS $@ > /dev/null 2> /dev/null
84         ret=$?
85         rm -f conftest.o
86         return $ret
87 }
89 test_cxx_flags() {
90         AC_LANG_PUSH(C++)
91         AC_LANG_CONFTEST([int main(void){}])
92         $CXX -c conftest.c $CXXFLAGS $STRICT_CXXFLAGS $@ > /dev/null 2> /dev/null
93         ret=$?
94         rm -f conftest.o
95         AC_LANG_POP(C++)
96         return $ret
97 }
99 STRICT_CFLAGS=""
100 STRICT_CXXFLAGS=""
102 m4_divert_once([HELP_ENABLE], [
103 Build options:])
105 dnl Optionally stick to standard C99 and POSIX:2001 as close as possible.
106 AC_ARG_ENABLE([standards],
107                 AS_HELP_STRING([--enable-standards],
108                                 [C99 / POSIX standards compliance mode @<:@default=no@:>@]),
109                 [enable_standards="$enableval"],
110                 [enable_standards="no"])
112 if test "x$enable_standards" = "xyes"; then
113         AC_DEFINE([_ISOC99_SOURCE], 1,
114                         [Define to enforce ISO/IEC 9899:1999 (C99) compliance.])
115         AC_DEFINE([_POSIX_C_SOURCE], 200112L,
116                         [Define to enforce IEEE 1003.1-2001 (POSIX:2001) compliance.])
117         AC_DEFINE([_XOPEN_SOURCE], 700,
118                         [Define to enforce X/Open 7 (XSI) compliance.])
119         AC_DEFINE([_REENTRANT], 1,
120                         [Define to enable reentrant interfaces.])
121         AC_DEFINE([_THREAD_SAFE], 1,
122                         [Define to enable reentrant interfaces.])
124         dnl GNU libc defines strcasecmp() only when using _BSD_SOURCE even though
125         dnl the function is conforming to POSIX.1-2001 as well. Let's weaken
126         dnl strict standards compliance a bit to work around this.
127         AC_DEFINE([_BSD_SOURCE], 1, [Define to enable 4.3BSD support.])
129         for flag in -std=c99; do
130                 AC_MSG_CHECKING([whether $CC accepts $flag])
132                 if test_cc_flags $flag; then
133                         STRICT_CFLAGS="$STRICT_CFLAGS $flag"
134                         AC_MSG_RESULT([yes])
135                 else
136                         AC_MSG_RESULT([no])
137                 fi
138         done
139 fi
141 dnl We need C++11 for facter.
142 AC_MSG_CHECKING([whether $CXX accepts -std=c++11])
143 if test_cxx_flags -std=c++11; then
144         CXXFLAGS="$CXXFLAGS -std=c++11"
145         AC_MSG_RESULT([yes])
146 else
147         # Oh well, the header check will determine if it works anyway.
148         AC_MSG_RESULT([no])
149 fi
151 dnl Hardening (see e.g. http://wiki.debian.org/Hardening for a motivation).
152 AC_DEFINE([_FORTIFY_SOURCE], 2,
153                 [Define to enable protection against static sized buffer overflows.])
154 AC_ARG_ENABLE([hardening],
155                 AS_HELP_STRING([--disable-hardening],
156                                 [hardening options @<:@default=yes@:>@]),
157                 [enable_hardening="$enableval"],
158                 [enable_hardening="yes"])
160 if test "x$enable_hardening" = "xyes"; then
161         hardening_cc=0
162         hardening_cxx=0
163         hardening_tests=0
164         for flag in -Wformat -Wformat-security; do
165                 hardening_tests=$(($hardening_tests + 1))
167                 AC_MSG_CHECKING([whether $CC accepts $flag])
168                 if test_cc_flags $flag; then
169                         STRICT_CFLAGS="$STRICT_CFLAGS $flag"
170                         hardening_cc=$(($hardening_cc + 1))
171                         AC_MSG_RESULT([yes])
172                 else
173                         AC_MSG_RESULT([no])
174                 fi
176                 AC_MSG_CHECKING([whether $CXX accepts $flag])
177                 if test_cxx_flags $flag; then
178                         STRICT_CXXFLAGS="$STRICT_CXXFLAGS $flag"
179                         hardening_cxx=$(($hardening_cxx + 1))
180                         AC_MSG_RESULT([yes])
181                 else
182                         AC_MSG_RESULT([no])
183                 fi
184         done
185         if test $hardening_cc -ne $hardening_tests; then
186                 AC_MSG_WARN(
187                                 [Some hardening options are not supported by your C compiler!])
188         fi
189         if test $hardening_cxx -ne $hardening_tests; then
190                 AC_MSG_WARN(
191                                 [Some hardening options are not supported by your C++ compiler!])
192         fi
193 fi
195 dnl Strict checking for potential problems.
196 AC_ARG_ENABLE([strict-checks],
197                 AS_HELP_STRING([--disable-strict-checks],
198                                 [strict compiler checks @<:@default=yes@:>@]),
199                 [enable_strict_checks="$enableval"],
200                 [enable_strict_checks="yes"])
202 for flag in -Wall -Werror; do
203         AC_MSG_CHECKING([whether $CC accepts $flag])
204         if test_cc_flags $flag; then
205                 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
206                 AC_MSG_RESULT([yes])
207         else
208                 AC_MSG_RESULT([no])
209         fi
211         AC_MSG_CHECKING([whether $CXX accepts $flag])
212         if test_cxx_flags $flag; then
213                 STRICT_CXXFLAGS="$STRICT_CXXFLAGS $flag"
214                 AC_MSG_RESULT([yes])
215         else
216                 AC_MSG_RESULT([no])
217         fi
218 done
220 if test "x$enable_strict_checks" = "xyes"; then
221         dnl -Wsign-conversion may cause problems in expanded macros from libc
222         for flag in -Wextra \
223                         -Wbad-function-cast \
224                         -Wcast-align \
225                         -Wcast-qual \
226                         -Wconversion \
227                         -Wno-sign-conversion \
228                         -Wdeclaration-after-statement \
229                         -Wmissing-prototypes \
230                         -Wpointer-arith \
231                         -Wshadow \
232                         -Wstrict-prototypes; do
233                 AC_MSG_CHECKING([whether $CC accepts $flag])
234                 if test_cc_flags $flag; then
235                         STRICT_CFLAGS="$STRICT_CFLAGS $flag"
236                         AC_MSG_RESULT([yes])
237                 else
238                         AC_MSG_RESULT([no])
239                 fi
241                 dnl -Wshadow produces unnecessary warnings/errors in case a
242                 dnl C function name "shadows" a struct constructor.
243                 if test "x$flag" != "x-Wshadow"; then
244                         AC_MSG_CHECKING([whether $CXX accepts $flag])
245                         if test_cxx_flags $flag; then
246                                 STRICT_CXXFLAGS="$STRICT_CXXFLAGS $flag"
247                                 AC_MSG_RESULT([yes])
248                         else
249                                 AC_MSG_RESULT([no])
250                         fi
251                 fi
252         done
253 fi
254 AC_SUBST([STRICT_CFLAGS])
255 AC_SUBST([STRICT_CXXFLAGS])
257 AC_ARG_ENABLE([gcov],
258                 AS_HELP_STRING([--enable-gcov],
259                                 [Gcov coverage statistics @<:@default=no@:>@]),
260                 [enable_gcov="$enableval"],
261                 [enable_gcov="no"])
263 dnl $GCC is based on some heuristics which might apply to clang as well.
264 dnl However, clang does not support gcov.
265 cc_is_gcc="no"
266 case "x$CC" in
267         xgcc)
268                 cc_is_gcc="yes"
269                 ;;
270         xgcc-*)
271                 cc_is_gcc="yes"
272                 ;;
273 esac
275 COVERAGE_CFLAGS=""
276 COVERAGE_LDFLAGS=""
277 if test "x$enable_gcov" = "xyes" && test "x$GCC$cc_is_gcc" == "xyesyes"; then
278         COVERAGE_CFLAGS="-O0"
279         cov_flag_have_problem="no"
281         AC_MSG_CHECKING([whether $CC accepts --coverage])
282         if test_cc_flags --coverage; then
283                 COVERAGE_CFLAGS="$COVERAGE_CFLAGS --coverage"
284                 COVERAGE_LDFLAGS="$COVERAGE_LDFLAGS --coverage"
285                 AC_MSG_RESULT([yes])
286         else
287                 AC_MSG_RESULT([no])
288                 cov_flag_have_problem="yes"
289         fi
291         for flag in -fno-inline; do
292                 AC_MSG_CHECKING([whether $CC accepts $flag])
293                 if test_cc_flags $flag; then
294                         COVERAGE_CFLAGS="$COVERAGE_CFLAGS $flag"
295                         AC_MSG_RESULT([yes])
296                 else
297                         AC_MSG_RESULT([no])
298                         cov_flag_have_problem="yes"
299                 fi
300         done
302         if test "x$cov_flag_have_problem" != "xno"; then
303                 AC_MSG_WARN([Some coverage flags are not supported by your compiler!])
304         fi
305 else if test "x$enable_gcov" = "xyes"; then
306         AC_MSG_WARN([Your compiler ($CC) is not known to support Gcov!])
307         enable_gcov="no (requires GCC)"
308 fi; fi
309 AC_SUBST([COVERAGE_CFLAGS])
310 AC_SUBST([COVERAGE_LDFLAGS])
312 AC_ARG_ENABLE([gprof],
313                 AS_HELP_STRING([--enable-gprof],
314                                 [Gprof profiling @<:@default=no@:>@]),
315                 [enable_gprof="$enableval"],
316                 [enable_gprof="no"])
318 PROFILING_CFLAGS=""
319 PROFILING_LDFLAGS=""
320 if test "x$enable_gprof" = "xyes"; then
321         PROFILING_CFLAGS="-O0"
322         profiling_flag_have_problem="no"
324         AC_MSG_CHECKING([whether $CC accepts -pg])
325         if test_cc_flags -pg; then
326                 PROFILING_CFLAGS="$PROFILING_CFLAGS -pg"
327                 PROFILING_LDFLAGS="$PROFILING_LDFLAGS -pg"
328                 AC_MSG_RESULT([yes])
329         else
330                 AC_MSG_RESULT([no])
331                 profiling_flag_have_problem="yes"
332         fi
334         for flag in -fprofile-arcs; do
335                 AC_MSG_CHECKING([whether $CC accepts $flag])
336                 if test_cc_flags $flag; then
337                         PROFILING_CFLAGS="$PROFILING_CFLAGS $flag"
338                         AC_MSG_RESULT([yes])
339                 fi
340                 # else: this is not a serious problem
341         done
343         if test "x$profiling_flag_have_problem" != "xno"; then
344                 AC_MSG_WARN([Some profiling flags are not supported by your compiler!])
345         fi
346 fi
347 AC_SUBST([PROFILING_CFLAGS])
348 AC_SUBST([PROFILING_LDFLAGS])
350 ieee754_layout="unknown"
351 AC_MSG_CHECKING([the memory layout of double precision values])
352 AC_COMPILE_IFELSE(
353                 [AC_LANG_PROGRAM(
354                         [[
355 #include <string.h>
356 #include <inttypes.h>
357                         ]],
358                         [[
359 double d = 3.141592653e130;
360 char c[8];
361 if (sizeof(d) != 8)
362         return 2;
363 memcpy(&c, &d, 8);
364 if (c[0] == '\x04' && c[1] == '\x10' && c[2] == '\x1E' && c[3] == '\x66' &&
365         c[4] == '\x40' && c[5] == '\xA9' && c[6] == '\x06' && c[7] == '\x5B')
366         return 0;
367 else
368         return 1;
369                         ]]
370                 )],
371                 [ieee754_layout="little-endian"], [ieee754_layout="unknown"])
372 if test "x$ieee754_layout" = "xunknown"; then
373         AC_COMPILE_IFELSE(
374                         [AC_LANG_PROGRAM(
375                                 [[
376 #include <string.h>
377 #include <inttypes.h>
378                                 ]],
379                                 [[
380 double d = 3.141592653e130;
381 char c[8];
382 if (sizeof(d) != 8)
383         return 2;
384 memcpy(&c, &d, 8);
385 if (c[7] == '\x04' && c[6] == '\x10' && c[5] == '\x1E' && c[4] == '\x66' &&
386         c[3] == '\x40' && c[2] == '\xA9' && c[1] == '\x06' && c[0] == '\x5B')
387         return 0;
388 else
389         return 1;
390                                 ]]
391                         )],
392                         [ieee754_layout="big-endian"], [ieee754_layout="unknown"])
393 fi
394 AC_MSG_RESULT([IEEE-754 $ieee754_layout])
396 AC_DEFINE([IEEE754_DOUBLE_LITTLE_ENDIAN], 1234,
397                 [Identifier for IEEE-754 little-endian encoding of double precision values])
398 AC_DEFINE([IEEE754_DOUBLE_BIG_ENDIAN], 4321,
399                 [Identifier for IEEE-754 big-endian encoding of double precision values])
400 if test "x$ieee754_layout" = "xlittle-endian"; then
401         AC_DEFINE([IEEE754_DOUBLE_BYTE_ORDER], 1234,
402                         [Define to 1 if double precision values use IEEE-754 little-endian encoding])
403 else if test "x$ieee754_layout" = "xbig-endian"; then
404         AC_DEFINE([IEEE754_DOUBLE_BYTE_ORDER], 4321,
405                         [Define to 1 if double precision values use IEEE-754 little-endian encoding])
406 else
407         AC_MSG_ERROR([Unknown memory layout of double precision values])
408 fi; fi
410 m4_divert_once([HELP_ENABLE], [
411 Build dependencies:])
413 AC_CHECK_HEADERS([ucred.h])
414 dnl On OpenBSD, sys/param.h is required for sys/ucred.h.
415 AC_CHECK_HEADERS([sys/ucred.h], [], [],
416                 [[ #include <sys/param.h> ]])
418 AC_CHECK_TYPES([struct ucred],
419                 [have_struct_ucred="yes"], [have_struct_ucred="no"],
420                 [[
421 #include <sys/socket.h>
422 #include <sys/param.h>
423 #if HAVE_UCRED_H
424 #       include <ucred.h>
425 #endif
426                 ]])
428 if test "x$have_struct_ucred" != "xyes"; then
429         AC_MSG_CHECKING([for struct ucred when using _GNU_SOURCE])
430         orig_CFLAGS="$CFLAGS"
431         CFLAGS="$CFLAGS -D_GNU_SOURCE"
432         dnl Don't reuse AC_CHECK_HEADERS; for one it'll use the cached value
433         dnl but also, it will print the "checking for" message a second time.
434         AC_COMPILE_IFELSE(
435                         [AC_LANG_PROGRAM(
436                                 [[
437 #include <sys/socket.h>
438 #include <sys/param.h>
439 #if HAVE_UCRED_H
440 #       include <ucred.h>
441 #endif
442                                 ]],
443                                 [if (sizeof(struct ucred)) return 0;]
444                         )],
445                         [have_struct_ucred="yes"], [have_struct_ucred="no"])
446         CFLAGS="$orig_CFLAGS"
447         if test "x$have_struct_ucred" = "xyes"; then
448                 AC_DEFINE([_GNU_SOURCE], 1, [Define to enable GNU features.])
449         fi
450         AC_MSG_RESULT([$have_struct_ucred])
451 fi
453 dnl Testing.
454 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],
455                 [unit_tests="yes"], [unit_tests="no"])
457 AC_CHECK_HEADERS(libgen.h)
459 dnl Check for dependencies.
460 AC_ARG_WITH([libdbi],
461                 [AS_HELP_STRING([--with-libdbi], [libdbi support (default: auto)])],
462                 [with_libdbi="$withval"],
463                 [with_libdbi="yes"])
464 if test "x$with_libdbi" = "xyes" || test "x$with_libdbi" = "xauto"; then
465         AC_CHECK_HEADERS([dbi/dbi.h],
466                         [with_libdbi="yes"],
467                         [with_libdbi="no (dbi/dbi.h not found)"])
468 else if test "x$with_libdbi" = "xno"; then
469         with_libdbi="$with_libdbi (disabled on command-line)"
470 else
471         AC_MSG_ERROR([Invalid value for option --with-libdbi=$with_libdbi (expected "yes", "no", or "auto")])
472 fi; fi
473 if test "x$with_libdbi" = "xyes"; then
474         AC_CHECK_LIB([dbi], [dbi_initialize],
475                         [with_libdbi="yes"],
476                         [with_libdbi="no (libdbi or symbol 'dbi_initialize' not found)"])
477 fi
478 AM_CONDITIONAL([BUILD_WITH_LIBDBI], test "x$with_libdbi" = "xyes")
480 dnl Required for mocking FILE related functions.
481 orig_CFLAGS="$CFLAGS"
482 CFLAGS="$CFLAGS -D_GNU_SOURCE"
483 AC_CHECK_FUNCS([fopencookie],
484                 [have_fopencookie="yes"],
485                 [have_fopencookie="no (fopencookie not available)"])
486 CFLAGS="$orig_CFLAGS"
487 AM_CONDITIONAL([BUILD_WITH_FOPENCOOKIE], test "x$have_fopencookie" = "xyes")
488 if test "x$have_fopencookie" = "xyes"; then
489         AC_DEFINE([HAVE_FOPENCOOKIE], 1)
490 fi
492 dnl OpenSSL support
493 PKG_CHECK_MODULES([OPENSSL], [openssl], [have_openssl="yes"], [have_openssl="no"])
494 if test "x$have_openssl" != "xyes"; then
495         AC_MSG_ERROR([OpenSSL not found])
496 fi
498 dnl readline support
499 AC_ARG_WITH([readline],
500                 [AS_HELP_STRING([--with-readline],
501                         [readline support (libedit/libreadline) (default: auto, prefer libedit)])],
502                 [readline_support="$withval"],
503                 [readline_support="auto"])
505 if test "x$readline_support" = "xyes"; then
506         readline_support="auto"
507 else if test "x$readline_support" != "xauto" \
508                 && test "x$readline_support" != "xno" \
509                 && test "x$readline_support" != "xlibedit" \
510                 && test "x$readline_support" != "xlibreadline"; then
511         AC_MSG_ERROR([Invalid value for option --with-readline=$readline_support (expected "yes", "no", "auto", "libedit", or "libreadline")])
512 fi; fi
514 have_libedit="no"
515 if test "x$readline_support" = "xauto" \
516                 || test "x$readline_support" = "xlibedit"; then
517         PKG_CHECK_MODULES([LIBEDIT], [libedit],
518                         [have_libedit="yes"], [have_libedit="no"])
519         if test "x$have_libedit" = "xyes"; then
520                 AC_CHECK_HEADERS([editline/readline.h], [],
521                                 [AC_CHECK_HEADERS([readline.h], [],
522                                                 [have_libedit="no (readline header not found"])])
523         fi
524         if test "x$have_libedit" = "xyes"; then
525                 AC_CHECK_HEADERS([editline/history.h], [],
526                                 [AC_CHECK_HEADERS([history.h], [],
527                                                 [have_libedit="no (history header not found"])])
528         fi
529 else
530         have_libedit="disabled on command-line"
531 fi
533 have_libreadline="no"
534 if test "x$have_libedit" != "xyes"; then
535         if test "x$readline_support" = "xauto" \
536                         || test "x$readline_support" = "xlibreadline"; then
537                 AC_CHECK_LIB([readline], [readline],
538                                 [have_libreadline="yes"],
539                                 [have_libreadline="no (libreadline or symbol 'readline' not found)"])
540         fi
541         if test "x$have_libreadline" = "xyes"; then
542                 AC_CHECK_HEADERS([readline/readline.h], [],
543                                 [AC_CHECK_HEADERS([readline.h], [],
544                                                 [have_libreadline="no (readline header not found"])])
545         fi
546         if test "x$have_libreadline" = "xyes"; then
547                 AC_CHECK_HEADERS([readline/history.h], [],
548                                 [AC_CHECK_HEADERS([history.h], [],
549                                                 [have_libreadline="no (history header not found"])])
550         fi
551 else
552         have_libreadline="unchecked (prefer libedit)"
553 fi
555 if test "x$have_libedit" = "xyes"; then
556         READLINE_LIBS="$LIBEDIT_LIBS"
557         READLINE_CFLAGS="$LIBEDIT_CFLAGS"
558         readline_support="libedit"
559 else if test "x$have_libreadline" = "xyes"; then
560         READLINE_LIBS="-lreadline -lhistory"
561         READLINE_CFLAGS=""
562         readline_support="libreadline"
563 else
564         READLINE_LIBS=""
565         READLINE_CFLAGS=""
566         if test "x$readline_support" = "xno"; then
567                 AC_MSG_WARN([*** readline support disabled; disabling SysDB client])
568         else if test "x$readline_support" = "xauto"; then
569                 AC_MSG_WARN([*** readline not found; disabling SysDB client])
570         else
571                 AC_MSG_ERROR([readline not found])
572         fi; fi
573         readline_support="no"
574 fi; fi
575 AC_SUBST([READLINE_LIBS])
576 AC_SUBST([READLINE_CFLAGS])
577 AM_CONDITIONAL([BUILD_CLIENT], test "x$readline_support" != "no")
579 AC_LANG_PUSH(C++)
580 AC_ARG_WITH([libfacter],
581                 [AS_HELP_STRING([--with-libfacter], [libfacter support (default: auto)])],
582                 [with_libfacter="$withval"],
583                 [with_libfacter="yes"])
584 if test "x$with_libfacter" = "xyes" || test "x$with_libfacter" = "xauto"; then
585         AC_CHECK_HEADERS([facter/facts/collection.hpp],
586                         [have_libfacter="yes"],
587                         [have_libfacter="no (facter/facts/collection.hpp not found)"])
588 else if test "x$with_libfacter" = "xno"; then
589         have_libfacter="$with_libfacter (disabled on command-line)"
590 else
591         AC_MSG_ERROR([Invalid value for option --with-libfacter=$with_libfacter (expected "yes", "no", or "auto")])
592 fi; fi
593 if test "x$have_libfacter" = "xyes"; then
594         AC_MSG_CHECKING([for facter::facts::collection in -lfacter])
595         AC_LINK_IFELSE(
596                         [AC_LANG_PROGRAM(
597                                 [[ #include <facter/facts/collection.hpp> ]],
598                                 [[
599                                         facter::facts::collection facts;
600                                         facts.add_default_facts();
601                                 ]]
602                         )],
603                         [TEST_LIBS=$TEST_LIBS -lfacter],
604                         [have_libfacter="yes"],
605                         [have_libfacter="no (libfacter not found)"])
606         AC_MSG_RESULT([$have_libfacter])
607 fi
608 AC_LANG_POP(C++)
610 AC_ARG_WITH([librrd],
611                 [AS_HELP_STRING([--with-librrd], [librrd support (default: auto)])],
612                 [with_librrd="$withval"],
613                 [with_librrd="yes"])
614 if test "x$with_librrd" = "xyes" || test "x$with_librrd" = "xauto"; then
615         PKG_CHECK_MODULES([RRD], [librrd],
616                         [have_librrd="yes"], [have_librrd="no"])
617 else if test "x$with_librrd" = "xno"; then
618         have_librrd="$with_librrd (disabled on command-line)"
619 else
620         AC_MSG_ERROR([Invalid value for option --with-librrd=$with_librrd (expected "yes", "no", or "auto")])
621 fi; fi
623 if test "x$have_librrd" = "xyes"; then
624         AC_CHECK_HEADERS([rrd_client.h])
625 fi
627 dnl Feature checks.
628 build_documentation="yes"
630 have_xmlto="yes"
631 AC_PATH_PROG([XMLTO], [xmlto])
632 if test "x$XMLTO" = "x"; then
633         have_xmlto="no"
634         build_documentation="no (missing xmlto)"
635 fi
636 AC_SUBST([XMLTO])
638 have_asciidoc="yes"
639 AC_PATH_PROG([ASCIIDOC], [asciidoc])
640 if test "x$ASCIIDOC" = "x"; then
641        have_asciidoc="no"
642        build_documentation="no (missing asciidoc)"
643 fi
644 AC_SUBST([ASCIIDOC])
646 AC_ARG_VAR([ADOCFLAGS], [AsciiDoc flags])
648 integration_tests="yes"
649 AC_PATH_PROG([VALGRIND], [valgrind])
650 if test "x$VALGRIND" = "x"; then
651         integration_tests="no (missing valgrind)"
652 fi
653 AM_CONDITIONAL([INTEGRATION_TESTING], test "x$integration_tests" = "xyes")
655 dnl Plugin checks.
656 facter_default=$have_libfacter
657 if test "x$facter_default" != "xyes"; then
658         facter_default="no (requires libfacter)"
659 fi
660 puppet_storeconfigs_default=$with_libdbi
661 if test "x$puppet_storeconfigs_default" != "xyes"; then
662         puppet_storeconfigs_default="no (requires libdbi)"
663 fi
664 rrdtool_default=$have_librrd
665 if test "x$rrdtool_default" != "xyes"; then
666         rrdtool_default="no (required librrd)"
667 fi
669 m4_divert_once([HELP_ENABLE], [
670 Backends:])
672 AC_SDB_PLUGIN_INIT
673 AC_SDB_PLUGIN([collectd-unixsock], [yes],
674                 [backend accessing the system statistics collection daemon])
675 AC_SDB_PLUGIN([facter], [$facter_default],
676                 [backend retrieving local facter facts])
677 AC_SDB_PLUGIN([mk-livestatus], [yes],
678                 [backend accessing Nagios/Icinga/Shinken using MK Livestatus])
679 AC_SDB_PLUGIN([puppet-storeconfigs], [$puppet_storeconfigs_default],
680                 [backend accessing the Puppet stored configuration database])
682 m4_divert_once([HELP_ENABLE], [
683 Time-series fetchers:])
684 AC_SDB_PLUGIN([timeseries-rrdtool], [$rrdtool_default],
685                 [fetch time-series data from RRD files])
687 m4_divert_once([HELP_ENABLE], [
688 Store implementations:])
689 AC_SDB_PLUGIN([store-memory], [yes],
690                 [store objects in a volatile, in-memory database (read/write)])
691 AC_SDB_PLUGIN([store-network], [yes],
692                 [send stored objects to a remote instance (write only)])
694 m4_divert_once([HELP_ENABLE], [
695 Plugins:])
697 AC_SDB_PLUGIN([cname-dns], [yes],
698                 [canonicalize hostnames by querying DNS])
699 AC_SDB_PLUGIN([syslog], [yes],
700                 [plugin logging to syslog])
702 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
703 AM_CONDITIONAL([UNIT_TESTING], test "x$unit_tests" = "xyes")
705 AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile
706                 src/liboconfig/Makefile t/Makefile])
707 AC_OUTPUT
709 BUILD_DATE="`date --utc '+%F %T'` (UTC)"
711 asciidoc_info="$have_asciidoc"
712 if test "x$have_asciidoc" = "xyes"; then
713         asciidoc_info="`$ASCIIDOC --version`"
714 fi
715 xmlto_info="$have_xmlto"
716 if test "x$have_xmlto" = "xyes"; then
717         xmlto_info="`$XMLTO --version`"
718 fi
720 if test "x$unit_tests" = "xyes"; then
721         unit_tests="yes (check `$PKG_CONFIG --modversion check`)"
722 fi
724 openssl_info="$have_openssl"
725 if test "x$have_openssl" = "xyes"; then
726         openssl_info="yes (version `$PKG_CONFIG --modversion openssl`)"
727 fi
728 libedit_info="$have_libedit"
729 if test "x$have_libedit" = "xyes"; then
730         libedit_info="yes (version `$PKG_CONFIG --modversion libedit`)"
731 fi
732 librrd_info="$have_librrd"
733 if test "x$have_librrd" = "xyes"; then
734         librrd_info="yes (version `$PKG_CONFIG --modversion librrd`)"
735 fi
737 AC_MSG_RESULT()
738 AC_MSG_RESULT([$PACKAGE_NAME has been configured successfully.])
739 AC_MSG_RESULT()
740 AC_MSG_RESULT([Run 'make' to compile the software and use 'make install' to])
741 AC_MSG_RESULT([install the package into $prefix.])
742 AC_MSG_RESULT()
743 AC_MSG_RESULT([Configuration summary:])
744 AC_MSG_RESULT()
745 AC_MSG_RESULT([  package version: $PACKAGE_VERSION])
746 AC_MSG_RESULT([  build date: $BUILD_DATE])
747 AC_MSG_RESULT()
748 AC_MSG_RESULT([  Tools:])
749 AC_MSG_RESULT([    AsciiDoc: . . . . . . . . . $asciidoc_info])
750 AC_MSG_RESULT([    xmlto:  . . . . . . . . . . $xmlto_info])
751 AC_MSG_RESULT()
752 AC_MSG_RESULT([  Features:])
753 AC_MSG_RESULT([    documentation:  . . . . . . $build_documentation])
754 AC_MSG_RESULT([    unit testing: . . . . . . . $unit_tests])
755 AC_MSG_RESULT([      stdio mocking:  . . . . . $have_fopencookie])
756 AC_MSG_RESULT([    coverage testing: . . . . . $enable_gcov])
757 AC_MSG_RESULT([    integration testing:  . . . $integration_tests])
758 AC_MSG_RESULT([    profiling:  . . . . . . . . $enable_gprof])
759 AC_MSG_RESULT()
760 AC_MSG_RESULT([  Libraries:])
761 AC_MSG_RESULT([    libdbi: . . . . . . . . . . $with_libdbi])
762 AC_MSG_RESULT([    libedit:  . . . . . . . . . $libedit_info])
763 AC_MSG_RESULT([    libopenssl: . . . . . . . . $openssl_info])
764 AC_MSG_RESULT([    libreadline:  . . . . . . . $have_libreadline])
765 AC_MSG_RESULT([    librrd: . . . . . . . . . . $librrd_info])
766 AC_MSG_RESULT()
767 AC_MSG_RESULT([  Backends:])
768 AC_MSG_RESULT([    collectd::unixsock: . . . . $enable_collectd_unixsock])
769 AC_MSG_RESULT([    facter  . . . . . . . . . . $enable_facter])
770 AC_MSG_RESULT([    mk-livestatus:  . . . . . . $enable_mk_livestatus])
771 AC_MSG_RESULT([    puppet::storeconfigs: . . . $enable_puppet_storeconfigs])
772 AC_MSG_RESULT()
773 AC_MSG_RESULT([  Time-series fetchers:])
774 AC_MSG_RESULT([    rrdtool:  . . . . . . . . . $enable_timeseries_rrdtool])
775 AC_MSG_RESULT()
776 AC_MSG_RESULT([  Store implementations:])
777 AC_MSG_RESULT([    memory: . . . . . . . . . . $enable_store_memory])
778 AC_MSG_RESULT([    network (writer): . . . . . $enable_store_network])
779 AC_MSG_RESULT()
780 AC_MSG_RESULT([  Plugins:])
781 AC_MSG_RESULT([    cname::dns: . . . . . . . . $enable_cname_dns])
782 AC_MSG_RESULT([    syslog: . . . . . . . . . . $enable_syslog])
783 AC_MSG_RESULT()
784 AC_MSG_RESULT([This package is maintained by $PACKAGE_MAINTAINER.])
785 AC_MSG_RESULT([Please report bugs to $PACKAGE_BUGREPORT.])
786 AC_MSG_RESULT()
788 dnl vim: set tw=78 sw=4 ts=4 noexpandtab :