Code

sysdb: Don't pretty-print JSON in non-interactive mode.
[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])
47 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
49 AC_LANG(C)
51 AC_SYS_LARGEFILE
53 AC_PROG_CC
54 AC_PROG_CXX
55 AC_PROG_CPP
56 AC_PROG_INSTALL
57 AC_PROG_LN_S
58 AC_PROG_MAKE_SET
59 m4_ifdef([AM_PROG_AR],[AM_PROG_AR],[])
61 AM_PROG_CC_C_O
62 AM_PROG_LEX
63 AC_PROG_YACC
65 m4_ifdef([LT_INIT],
66         [
67          LT_CONFIG_LTDL_DIR([libltdl])
68          LT_INIT([dlopen])
69          LTDL_INIT([convenience])
70         ],
71         # else
72         # (older libtools)
73         [
74          AC_CONFIG_SUBDIRS(libltdl)
75          AC_LIBLTDL_CONVENIENCE
76          AC_SUBST(LTDLINCL)
77          AC_SUBST(LIBLTDL)
78          AC_LIBTOOL_DLOPEN
79         ]
80 )
82 test_cc_flags() {
83         AC_LANG_CONFTEST([int main(void){}])
84         $CC -c conftest.c $CFLAGS $STRICT_CFLAGS $@ > /dev/null 2> /dev/null
85         ret=$?
86         rm -f conftest.o conftest.c
87         return $ret
88 }
90 test_cxx_flags() {
91         AC_LANG_PUSH(C++)
92         AC_LANG_CONFTEST([int main(void){}])
93         $CXX -c conftest.cpp $CXXFLAGS $STRICT_CXXFLAGS $@ > /dev/null 2> /dev/null
94         ret=$?
95         rm -f conftest.o conftest.cpp
96         AC_LANG_POP(C++)
97         return $ret
98 }
100 STRICT_CFLAGS=""
101 STRICT_CXXFLAGS=""
103 m4_divert_once([HELP_ENABLE], [
104 Build options:])
106 dnl Optionally stick to standard C99 and POSIX:2001 as close as possible.
107 AC_ARG_ENABLE([standards],
108                 AS_HELP_STRING([--enable-standards],
109                                 [C99 / POSIX standards compliance mode @<:@default=no@:>@]),
110                 [enable_standards="$enableval"],
111                 [enable_standards="no"])
113 if test "x$enable_standards" = "xyes"; then
114         AC_DEFINE([_ISOC99_SOURCE], 1,
115                         [Define to enforce ISO/IEC 9899:1999 (C99) compliance.])
116         AC_DEFINE([_POSIX_C_SOURCE], 200809L,
117                         [Define to enforce IEEE 1003.1-2008 (POSIX:2008) compliance.])
118         AC_DEFINE([_XOPEN_SOURCE], 700,
119                         [Define to enforce X/Open 7 (XSI) compliance.])
120         AC_DEFINE([_REENTRANT], 1,
121                         [Define to enable reentrant interfaces.])
122         AC_DEFINE([_THREAD_SAFE], 1,
123                         [Define to enable reentrant interfaces.])
125         for flag in -std=c99; do
126                 AC_MSG_CHECKING([whether $CC accepts $flag])
128                 if test_cc_flags $flag; then
129                         STRICT_CFLAGS="$STRICT_CFLAGS $flag"
130                         AC_MSG_RESULT([yes])
131                 else
132                         AC_MSG_RESULT([no])
133                 fi
134         done
135 fi
137 dnl We need C++11 for facter.
138 AC_MSG_CHECKING([whether $CXX accepts -std=c++11])
139 if test_cxx_flags -std=c++11; then
140         CXXFLAGS="$CXXFLAGS -std=c++11"
141         AC_MSG_RESULT([yes])
142 else
143         # Oh well, the header check will determine if it works anyway.
144         AC_MSG_RESULT([no])
145 fi
147 dnl Hardening (see e.g. http://wiki.debian.org/Hardening for a motivation).
148 AC_DEFINE([_FORTIFY_SOURCE], 2,
149                 [Define to enable protection against static sized buffer overflows.])
150 AC_ARG_ENABLE([hardening],
151                 AS_HELP_STRING([--disable-hardening],
152                                 [hardening options @<:@default=yes@:>@]),
153                 [enable_hardening="$enableval"],
154                 [enable_hardening="yes"])
156 if test "x$enable_hardening" = "xyes"; then
157         hardening_cc=0
158         hardening_cxx=0
159         hardening_tests=0
160         for flag in -Wformat -Wformat-security; do
161                 hardening_tests=$(($hardening_tests + 1))
163                 AC_MSG_CHECKING([whether $CC accepts $flag])
164                 if test_cc_flags $flag; then
165                         STRICT_CFLAGS="$STRICT_CFLAGS $flag"
166                         hardening_cc=$(($hardening_cc + 1))
167                         AC_MSG_RESULT([yes])
168                 else
169                         AC_MSG_RESULT([no])
170                 fi
172                 AC_MSG_CHECKING([whether $CXX accepts $flag])
173                 if test_cxx_flags $flag; then
174                         STRICT_CXXFLAGS="$STRICT_CXXFLAGS $flag"
175                         hardening_cxx=$(($hardening_cxx + 1))
176                         AC_MSG_RESULT([yes])
177                 else
178                         AC_MSG_RESULT([no])
179                 fi
180         done
181         if test $hardening_cc -ne $hardening_tests; then
182                 AC_MSG_WARN(
183                                 [Some hardening options are not supported by your C compiler!])
184         fi
185         if test $hardening_cxx -ne $hardening_tests; then
186                 AC_MSG_WARN(
187                                 [Some hardening options are not supported by your C++ compiler!])
188         fi
189 fi
191 dnl Strict checking for potential problems.
192 AC_ARG_ENABLE([strict-checks],
193                 AS_HELP_STRING([--disable-strict-checks],
194                                 [strict compiler checks @<:@default=yes@:>@]),
195                 [enable_strict_checks="$enableval"],
196                 [enable_strict_checks="yes"])
198 for flag in -Wall -Werror; do
199         AC_MSG_CHECKING([whether $CC accepts $flag])
200         if test_cc_flags $flag; then
201                 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
202                 AC_MSG_RESULT([yes])
203         else
204                 AC_MSG_RESULT([no])
205         fi
207         AC_MSG_CHECKING([whether $CXX accepts $flag])
208         if test_cxx_flags $flag; then
209                 STRICT_CXXFLAGS="$STRICT_CXXFLAGS $flag"
210                 AC_MSG_RESULT([yes])
211         else
212                 AC_MSG_RESULT([no])
213         fi
214 done
216 if test "x$enable_strict_checks" = "xyes"; then
217         dnl -Wsign-conversion may cause problems in expanded macros from libc
218         for flag in -Wextra \
219                         -Wbad-function-cast \
220                         -Wcast-align \
221                         -Wcast-qual \
222                         -Wconversion \
223                         -Wno-sign-conversion \
224                         -Wdeclaration-after-statement \
225                         -Wmissing-prototypes \
226                         -Wpointer-arith \
227                         -Wshadow \
228                         -Wstrict-prototypes; do
229                 AC_MSG_CHECKING([whether $CC accepts $flag])
230                 if test_cc_flags $flag; then
231                         STRICT_CFLAGS="$STRICT_CFLAGS $flag"
232                         AC_MSG_RESULT([yes])
233                 else
234                         AC_MSG_RESULT([no])
235                 fi
237                 dnl -Wshadow produces unnecessary warnings/errors in case a
238                 dnl C function name "shadows" a struct constructor.
239                 if test "x$flag" != "x-Wshadow"; then
240                         AC_MSG_CHECKING([whether $CXX accepts $flag])
241                         if test_cxx_flags $flag; then
242                                 STRICT_CXXFLAGS="$STRICT_CXXFLAGS $flag"
243                                 AC_MSG_RESULT([yes])
244                         else
245                                 AC_MSG_RESULT([no])
246                         fi
247                 fi
248         done
249 fi
250 AC_SUBST([STRICT_CFLAGS])
251 AC_SUBST([STRICT_CXXFLAGS])
253 AC_ARG_ENABLE([gcov],
254                 AS_HELP_STRING([--enable-gcov],
255                                 [Gcov coverage statistics @<:@default=no@:>@]),
256                 [enable_gcov="$enableval"],
257                 [enable_gcov="no"])
259 dnl $GCC is based on some heuristics which might apply to clang as well.
260 dnl However, clang does not support gcov.
261 cc_is_gcc="no"
262 case "x$CC" in
263         xgcc)
264                 cc_is_gcc="yes"
265                 ;;
266         xgcc-*)
267                 cc_is_gcc="yes"
268                 ;;
269 esac
271 COVERAGE_CFLAGS=""
272 COVERAGE_LDFLAGS=""
273 if test "x$enable_gcov" = "xyes" && test "x$GCC$cc_is_gcc" == "xyesyes"; then
274         COVERAGE_CFLAGS="-O0"
275         cov_flag_have_problem="no"
277         AC_MSG_CHECKING([whether $CC accepts --coverage])
278         if test_cc_flags --coverage; then
279                 COVERAGE_CFLAGS="$COVERAGE_CFLAGS --coverage"
280                 COVERAGE_LDFLAGS="$COVERAGE_LDFLAGS --coverage"
281                 AC_MSG_RESULT([yes])
282         else
283                 AC_MSG_RESULT([no])
284                 cov_flag_have_problem="yes"
285         fi
287         for flag in -fno-inline; do
288                 AC_MSG_CHECKING([whether $CC accepts $flag])
289                 if test_cc_flags $flag; then
290                         COVERAGE_CFLAGS="$COVERAGE_CFLAGS $flag"
291                         AC_MSG_RESULT([yes])
292                 else
293                         AC_MSG_RESULT([no])
294                         cov_flag_have_problem="yes"
295                 fi
296         done
298         if test "x$cov_flag_have_problem" != "xno"; then
299                 AC_MSG_WARN([Some coverage flags are not supported by your compiler!])
300         fi
301 else if test "x$enable_gcov" = "xyes"; then
302         AC_MSG_WARN([Your compiler ($CC) is not known to support Gcov!])
303         enable_gcov="no (requires GCC)"
304 fi; fi
305 AC_SUBST([COVERAGE_CFLAGS])
306 AC_SUBST([COVERAGE_LDFLAGS])
308 AC_ARG_ENABLE([gprof],
309                 AS_HELP_STRING([--enable-gprof],
310                                 [Gprof profiling @<:@default=no@:>@]),
311                 [enable_gprof="$enableval"],
312                 [enable_gprof="no"])
314 PROFILING_CFLAGS=""
315 PROFILING_LDFLAGS=""
316 if test "x$enable_gprof" = "xyes"; then
317         PROFILING_CFLAGS="-O0"
318         profiling_flag_have_problem="no"
320         AC_MSG_CHECKING([whether $CC accepts -pg])
321         if test_cc_flags -pg; then
322                 PROFILING_CFLAGS="$PROFILING_CFLAGS -pg"
323                 PROFILING_LDFLAGS="$PROFILING_LDFLAGS -pg"
324                 AC_MSG_RESULT([yes])
325         else
326                 AC_MSG_RESULT([no])
327                 profiling_flag_have_problem="yes"
328         fi
330         for flag in -fprofile-arcs; do
331                 AC_MSG_CHECKING([whether $CC accepts $flag])
332                 if test_cc_flags $flag; then
333                         PROFILING_CFLAGS="$PROFILING_CFLAGS $flag"
334                         AC_MSG_RESULT([yes])
335                 fi
336                 # else: this is not a serious problem
337         done
339         if test "x$profiling_flag_have_problem" != "xno"; then
340                 AC_MSG_WARN([Some profiling flags are not supported by your compiler!])
341         fi
342 fi
343 AC_SUBST([PROFILING_CFLAGS])
344 AC_SUBST([PROFILING_LDFLAGS])
346 ieee754_layout="unknown"
347 AC_MSG_CHECKING([the memory layout of double precision values])
348 AC_COMPILE_IFELSE(
349                 [AC_LANG_PROGRAM(
350                         [[
351 #include <string.h>
352 #include <inttypes.h>
353                         ]],
354                         [[
355 double d = 3.141592653e130;
356 char c[8];
357 if (sizeof(d) != 8)
358         return 2;
359 memcpy(&c, &d, 8);
360 if (c[0] == '\x04' && c[1] == '\x10' && c[2] == '\x1E' && c[3] == '\x66' &&
361         c[4] == '\x40' && c[5] == '\xA9' && c[6] == '\x06' && c[7] == '\x5B')
362         return 0;
363 else
364         return 1;
365                         ]]
366                 )],
367                 [ieee754_layout="little-endian"], [ieee754_layout="unknown"])
368 if test "x$ieee754_layout" = "xunknown"; then
369         AC_COMPILE_IFELSE(
370                         [AC_LANG_PROGRAM(
371                                 [[
372 #include <string.h>
373 #include <inttypes.h>
374                                 ]],
375                                 [[
376 double d = 3.141592653e130;
377 char c[8];
378 if (sizeof(d) != 8)
379         return 2;
380 memcpy(&c, &d, 8);
381 if (c[7] == '\x04' && c[6] == '\x10' && c[5] == '\x1E' && c[4] == '\x66' &&
382         c[3] == '\x40' && c[2] == '\xA9' && c[1] == '\x06' && c[0] == '\x5B')
383         return 0;
384 else
385         return 1;
386                                 ]]
387                         )],
388                         [ieee754_layout="big-endian"], [ieee754_layout="unknown"])
389 fi
390 AC_MSG_RESULT([IEEE-754 $ieee754_layout])
392 AC_DEFINE([IEEE754_DOUBLE_LITTLE_ENDIAN], 1234,
393                 [Identifier for IEEE-754 little-endian encoding of double precision values])
394 AC_DEFINE([IEEE754_DOUBLE_BIG_ENDIAN], 4321,
395                 [Identifier for IEEE-754 big-endian encoding of double precision values])
396 if test "x$ieee754_layout" = "xlittle-endian"; then
397         AC_DEFINE([IEEE754_DOUBLE_BYTE_ORDER], 1234,
398                         [Define to 1 if double precision values use IEEE-754 little-endian encoding])
399 else if test "x$ieee754_layout" = "xbig-endian"; then
400         AC_DEFINE([IEEE754_DOUBLE_BYTE_ORDER], 4321,
401                         [Define to 1 if double precision values use IEEE-754 little-endian encoding])
402 else
403         AC_MSG_ERROR([Unknown memory layout of double precision values])
404 fi; fi
406 m4_divert_once([HELP_ENABLE], [
407 Build dependencies:])
409 AC_CHECK_HEADERS([ucred.h])
410 dnl On OpenBSD, sys/param.h is required for sys/ucred.h.
411 AC_CHECK_HEADERS([sys/ucred.h], [], [],
412                 [[ #include <sys/param.h> ]])
414 AC_CHECK_TYPES([struct ucred],
415                 [have_struct_ucred="yes"], [have_struct_ucred="no"],
416                 [[
417 #include <sys/socket.h>
418 #include <sys/param.h>
419 #if HAVE_UCRED_H
420 #       include <ucred.h>
421 #endif
422                 ]])
424 if test "x$have_struct_ucred" != "xyes"; then
425         AC_MSG_CHECKING([for struct ucred when using _GNU_SOURCE])
426         orig_CFLAGS="$CFLAGS"
427         CFLAGS="$CFLAGS -D_GNU_SOURCE"
428         dnl Don't reuse AC_CHECK_HEADERS; for one it'll use the cached value
429         dnl but also, it will print the "checking for" message a second time.
430         AC_COMPILE_IFELSE(
431                         [AC_LANG_PROGRAM(
432                                 [[
433 #include <sys/socket.h>
434 #include <sys/param.h>
435 #if HAVE_UCRED_H
436 #       include <ucred.h>
437 #endif
438                                 ]],
439                                 [if (sizeof(struct ucred)) return 0;]
440                         )],
441                         [have_struct_ucred="yes"], [have_struct_ucred="no"])
442         CFLAGS="$orig_CFLAGS"
443         if test "x$have_struct_ucred" = "xyes"; then
444                 AC_DEFINE([_GNU_SOURCE], 1, [Define to enable GNU features.])
445         fi
446         AC_MSG_RESULT([$have_struct_ucred])
447 fi
449 dnl Testing.
450 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],
451                 [unit_tests="yes"], [unit_tests="no"])
453 AC_CHECK_HEADERS(libgen.h)
455 dnl Check for dependencies.
456 AC_ARG_WITH([libdbi],
457                 [AS_HELP_STRING([--with-libdbi], [libdbi support (default: auto)])],
458                 [with_libdbi="$withval"],
459                 [with_libdbi="yes"])
460 if test "x$with_libdbi" = "xyes" || test "x$with_libdbi" = "xauto"; then
461         AC_CHECK_HEADERS([dbi/dbi.h],
462                         [with_libdbi="yes"],
463                         [with_libdbi="no (dbi/dbi.h not found)"])
464 else if test "x$with_libdbi" = "xno"; then
465         with_libdbi="$with_libdbi (disabled on command-line)"
466 else
467         AC_MSG_ERROR([Invalid value for option --with-libdbi=$with_libdbi (expected "yes", "no", or "auto")])
468 fi; fi
469 if test "x$with_libdbi" = "xyes"; then
470         AC_CHECK_LIB([dbi], [dbi_initialize],
471                         [with_libdbi="yes"],
472                         [with_libdbi="no (libdbi or symbol 'dbi_initialize' not found)"])
473 fi
474 AM_CONDITIONAL([BUILD_WITH_LIBDBI], test "x$with_libdbi" = "xyes")
476 AC_ARG_WITH([libyajl],
477                 [AS_HELP_STRING([--with-liyajl], [libyajl support (default: auto)])],
478                 [with_libyajl="$withval"],
479                 [with_libyajl="yes"])
480 if test "x$with_libyajl" = "xyes" || test "x$with_libyajl" = "xauto"; then
481         PKG_CHECK_MODULES([YAJL], [yajl], [have_libyajl="yes"], [have_libyajl="no"])
482 fi
483 if test "x$with_libyajl" = "xyes"; then
484         AC_DEFINE([HAVE_LIBYAJL], 1, [Define to 1 if you have the 'yajl' library.])
485 fi
487 dnl Required for mocking FILE related functions.
488 orig_CFLAGS="$CFLAGS"
489 CFLAGS="$CFLAGS -D_GNU_SOURCE"
490 AC_CHECK_FUNCS([fopencookie],
491                 [have_fopencookie="yes"],
492                 [have_fopencookie="no (fopencookie not available)"])
493 CFLAGS="$orig_CFLAGS"
494 AM_CONDITIONAL([BUILD_WITH_FOPENCOOKIE], test "x$have_fopencookie" = "xyes")
495 if test "x$have_fopencookie" = "xyes"; then
496         AC_DEFINE([HAVE_FOPENCOOKIE], 1)
497 fi
499 dnl OpenSSL support
500 PKG_CHECK_MODULES([OPENSSL], [openssl], [have_openssl="yes"], [have_openssl="no"])
501 if test "x$have_openssl" != "xyes"; then
502         AC_MSG_ERROR([OpenSSL not found])
503 fi
505 dnl readline support
506 AC_ARG_WITH([readline],
507                 [AS_HELP_STRING([--with-readline],
508                         [readline support (libedit/libreadline) (default: auto, prefer libedit)])],
509                 [readline_support="$withval"],
510                 [readline_support="auto"])
512 if test "x$readline_support" = "xyes"; then
513         readline_support="auto"
514 else if test "x$readline_support" != "xauto" \
515                 && test "x$readline_support" != "xno" \
516                 && test "x$readline_support" != "xlibedit" \
517                 && test "x$readline_support" != "xlibreadline"; then
518         AC_MSG_ERROR([Invalid value for option --with-readline=$readline_support (expected "yes", "no", "auto", "libedit", or "libreadline")])
519 fi; fi
521 have_libedit="no"
522 if test "x$readline_support" = "xauto" \
523                 || test "x$readline_support" = "xlibedit"; then
524         PKG_CHECK_MODULES([LIBEDIT], [libedit],
525                         [have_libedit="yes"], [have_libedit="no"])
526         if test "x$have_libedit" = "xyes"; then
527                 AC_CHECK_HEADERS([editline/readline.h], [],
528                                 [AC_CHECK_HEADERS([readline.h], [],
529                                                 [have_libedit="no (readline header not found"])])
530         fi
531         if test "x$have_libedit" = "xyes"; then
532                 AC_CHECK_HEADERS([editline/history.h], [],
533                                 [AC_CHECK_HEADERS([history.h], [],
534                                                 [have_libedit="no (history header not found"])])
535         fi
536 else
537         have_libedit="disabled on command-line"
538 fi
540 have_libreadline="no"
541 if test "x$have_libedit" != "xyes"; then
542         if test "x$readline_support" = "xauto" \
543                         || test "x$readline_support" = "xlibreadline"; then
544                 AC_CHECK_LIB([readline], [readline],
545                                 [have_libreadline="yes"],
546                                 [have_libreadline="no (libreadline or symbol 'readline' not found)"])
547         fi
548         if test "x$have_libreadline" = "xyes"; then
549                 AC_CHECK_HEADERS([readline/readline.h], [],
550                                 [AC_CHECK_HEADERS([readline.h], [],
551                                                 [have_libreadline="no (readline header not found"])])
552         fi
553         if test "x$have_libreadline" = "xyes"; then
554                 AC_CHECK_HEADERS([readline/history.h], [],
555                                 [AC_CHECK_HEADERS([history.h], [],
556                                                 [have_libreadline="no (history header not found"])])
557         fi
558 else
559         have_libreadline="unchecked (prefer libedit)"
560 fi
562 if test "x$have_libedit" = "xyes"; then
563         READLINE_LIBS="$LIBEDIT_LIBS"
564         READLINE_CFLAGS="$LIBEDIT_CFLAGS"
565         readline_support="libedit"
566 else if test "x$have_libreadline" = "xyes"; then
567         READLINE_LIBS="-lreadline -lhistory"
568         READLINE_CFLAGS=""
569         readline_support="libreadline"
570 else
571         READLINE_LIBS=""
572         READLINE_CFLAGS=""
573         if test "x$readline_support" = "xno"; then
574                 AC_MSG_WARN([*** readline support disabled; disabling SysDB client])
575         else if test "x$readline_support" = "xauto"; then
576                 AC_MSG_WARN([*** readline not found; disabling SysDB client])
577         else
578                 AC_MSG_ERROR([readline not found])
579         fi; fi
580         readline_support="no"
581 fi; fi
582 AC_SUBST([READLINE_LIBS])
583 AC_SUBST([READLINE_CFLAGS])
584 AM_CONDITIONAL([BUILD_CLIENT], test "x$readline_support" != "no")
586 AC_LANG_PUSH(C++)
587 AC_ARG_WITH([libfacter],
588                 [AS_HELP_STRING([--with-libfacter], [libfacter support (default: auto)])],
589                 [with_libfacter="$withval"],
590                 [with_libfacter="yes"])
591 if test "x$with_libfacter" = "xyes" || test "x$with_libfacter" = "xauto"; then
592         AC_CHECK_HEADERS([facter/facts/collection.hpp],
593                         [have_libfacter="yes"],
594                         [have_libfacter="no (facter/facts/collection.hpp not found)"])
595 else if test "x$with_libfacter" = "xno"; then
596         have_libfacter="$with_libfacter (disabled on command-line)"
597 else
598         AC_MSG_ERROR([Invalid value for option --with-libfacter=$with_libfacter (expected "yes", "no", or "auto")])
599 fi; fi
600 if test "x$have_libfacter" = "xyes"; then
601         AC_MSG_CHECKING([for facter::facts::collection in -lfacter])
602         AC_LINK_IFELSE(
603                         [AC_LANG_PROGRAM(
604                                 [[ #include <facter/facts/collection.hpp> ]],
605                                 [[
606                                         facter::facts::collection facts;
607                                         facts.add_default_facts();
608                                 ]]
609                         )],
610                         [TEST_LIBS=$TEST_LIBS -lfacter],
611                         [have_libfacter="yes"],
612                         [have_libfacter="no (libfacter not found)"])
613         AC_MSG_RESULT([$have_libfacter])
614 fi
615 AC_LANG_POP(C++)
617 AC_ARG_WITH([librrd],
618                 [AS_HELP_STRING([--with-librrd], [librrd support (default: auto)])],
619                 [with_librrd="$withval"],
620                 [with_librrd="yes"])
621 if test "x$with_librrd" = "xyes" || test "x$with_librrd" = "xauto"; then
622         PKG_CHECK_MODULES([RRD], [librrd],
623                         [have_librrd="yes"], [have_librrd="no"])
624 else if test "x$with_librrd" = "xno"; then
625         have_librrd="$with_librrd (disabled on command-line)"
626 else
627         AC_MSG_ERROR([Invalid value for option --with-librrd=$with_librrd (expected "yes", "no", or "auto")])
628 fi; fi
630 if test "x$have_librrd" = "xyes"; then
631         AC_CHECK_HEADERS([rrd.h])
632         AC_CHECK_HEADERS([rrd_client.h], [], [], [[#include <rrd.h>]])
633 fi
635 dnl Feature checks.
636 build_documentation="yes"
638 have_xmlto="yes"
639 AC_PATH_PROG([XMLTO], [xmlto])
640 if test "x$XMLTO" = "x"; then
641         have_xmlto="no"
642         build_documentation="no (missing xmlto)"
643 fi
644 AC_SUBST([XMLTO])
646 have_asciidoc="yes"
647 AC_PATH_PROG([ASCIIDOC], [asciidoc])
648 if test "x$ASCIIDOC" = "x"; then
649        have_asciidoc="no"
650        build_documentation="no (missing asciidoc)"
651 fi
652 AC_SUBST([ASCIIDOC])
654 AC_ARG_VAR([ADOCFLAGS], [AsciiDoc flags])
656 integration_tests="yes"
657 AC_PATH_PROG([VALGRIND], [valgrind])
658 if test "x$VALGRIND" = "x"; then
659         integration_tests="no (missing valgrind)"
660 fi
661 AM_CONDITIONAL([INTEGRATION_TESTING], test "x$integration_tests" = "xyes")
663 dnl Plugin checks.
664 facter_default=$have_libfacter
665 if test "x$facter_default" != "xyes"; then
666         facter_default="no (requires libfacter)"
667 fi
668 puppet_storeconfigs_default=$with_libdbi
669 if test "x$puppet_storeconfigs_default" != "xyes"; then
670         puppet_storeconfigs_default="no (requires libdbi)"
671 fi
672 rrdtool_default=$have_librrd
673 if test "x$rrdtool_default" != "xyes"; then
674         rrdtool_default="no (required librrd)"
675 fi
677 m4_divert_once([HELP_ENABLE], [
678 Backends:])
680 AC_SDB_PLUGIN_INIT
681 AC_SDB_PLUGIN([collectd-unixsock], [yes],
682                 [backend accessing the system statistics collection daemon])
683 AC_SDB_PLUGIN([facter], [$facter_default],
684                 [backend retrieving local facter facts])
685 AC_SDB_PLUGIN([mk-livestatus], [yes],
686                 [backend accessing Nagios/Icinga/Shinken using MK Livestatus])
687 AC_SDB_PLUGIN([puppet-storeconfigs], [$puppet_storeconfigs_default],
688                 [backend accessing the Puppet stored configuration database])
690 m4_divert_once([HELP_ENABLE], [
691 Time-series fetchers:])
692 AC_SDB_PLUGIN([timeseries-rrdtool], [$rrdtool_default],
693                 [fetch time-series data from RRD files])
695 m4_divert_once([HELP_ENABLE], [
696 Store implementations:])
697 AC_SDB_PLUGIN([store-memory], [yes],
698                 [store objects in a volatile, in-memory database (read/write)])
699 AC_SDB_PLUGIN([store-network], [yes],
700                 [send stored objects to a remote instance (write only)])
702 m4_divert_once([HELP_ENABLE], [
703 Plugins:])
705 AC_SDB_PLUGIN([cname-dns], [yes],
706                 [canonicalize hostnames by querying DNS])
707 AC_SDB_PLUGIN([syslog], [yes],
708                 [plugin logging to syslog])
710 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
711 AM_CONDITIONAL([UNIT_TESTING], test "x$unit_tests" = "xyes")
713 AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile
714                 src/liboconfig/Makefile t/Makefile])
715 AC_OUTPUT
717 BUILD_DATE="`date --utc '+%F %T'` (UTC)"
719 asciidoc_info="$have_asciidoc"
720 if test "x$have_asciidoc" = "xyes"; then
721         asciidoc_info="`$ASCIIDOC --version`"
722 fi
723 xmlto_info="$have_xmlto"
724 if test "x$have_xmlto" = "xyes"; then
725         xmlto_info="`$XMLTO --version`"
726 fi
728 if test "x$unit_tests" = "xyes"; then
729         unit_tests="yes (check `$PKG_CONFIG --modversion check`)"
730 fi
732 openssl_info="$have_openssl"
733 if test "x$have_openssl" = "xyes"; then
734         openssl_info="yes (version `$PKG_CONFIG --modversion openssl`)"
735 fi
736 libedit_info="$have_libedit"
737 if test "x$have_libedit" = "xyes"; then
738         libedit_info="yes (version `$PKG_CONFIG --modversion libedit`)"
739 fi
740 librrd_info="$have_librrd"
741 if test "x$have_librrd" = "xyes"; then
742         librrd_info="yes (version `$PKG_CONFIG --modversion librrd`)"
743 fi
744 libyajl_info="$have_libyajl"
745 if test "x$have_libyajl" = "xyes"; then
746         libyajl_info="yes (version `$PKG_CONFIG --modversion yajl`)"
747 fi
749 AC_MSG_RESULT()
750 AC_MSG_RESULT([$PACKAGE_NAME has been configured successfully.])
751 AC_MSG_RESULT()
752 AC_MSG_RESULT([Run 'make' to compile the software and use 'make install' to])
753 AC_MSG_RESULT([install the package into $prefix.])
754 AC_MSG_RESULT()
755 AC_MSG_RESULT([Configuration summary:])
756 AC_MSG_RESULT()
757 AC_MSG_RESULT([  package version: $PACKAGE_VERSION])
758 AC_MSG_RESULT([  build date: $BUILD_DATE])
759 AC_MSG_RESULT()
760 AC_MSG_RESULT([  Tools:])
761 AC_MSG_RESULT([    AsciiDoc: . . . . . . . . . $asciidoc_info])
762 AC_MSG_RESULT([    xmlto:  . . . . . . . . . . $xmlto_info])
763 AC_MSG_RESULT()
764 AC_MSG_RESULT([  Features:])
765 AC_MSG_RESULT([    documentation:  . . . . . . $build_documentation])
766 AC_MSG_RESULT([    unit testing: . . . . . . . $unit_tests])
767 AC_MSG_RESULT([      stdio mocking:  . . . . . $have_fopencookie])
768 AC_MSG_RESULT([    coverage testing: . . . . . $enable_gcov])
769 AC_MSG_RESULT([    integration testing:  . . . $integration_tests])
770 AC_MSG_RESULT([    profiling:  . . . . . . . . $enable_gprof])
771 AC_MSG_RESULT()
772 AC_MSG_RESULT([  Libraries:])
773 AC_MSG_RESULT([    libdbi: . . . . . . . . . . $with_libdbi])
774 AC_MSG_RESULT([    libedit:  . . . . . . . . . $libedit_info])
775 AC_MSG_RESULT([    libopenssl: . . . . . . . . $openssl_info])
776 AC_MSG_RESULT([    libreadline:  . . . . . . . $have_libreadline])
777 AC_MSG_RESULT([    librrd: . . . . . . . . . . $librrd_info])
778 AC_MSG_RESULT([    libyajl:  . . . . . . . . . $libyajl_info])
779 AC_MSG_RESULT()
780 AC_MSG_RESULT([  Backends:])
781 AC_MSG_RESULT([    collectd::unixsock: . . . . $enable_collectd_unixsock])
782 AC_MSG_RESULT([    facter  . . . . . . . . . . $enable_facter])
783 AC_MSG_RESULT([    mk-livestatus:  . . . . . . $enable_mk_livestatus])
784 AC_MSG_RESULT([    puppet::storeconfigs: . . . $enable_puppet_storeconfigs])
785 AC_MSG_RESULT()
786 AC_MSG_RESULT([  Time-series fetchers:])
787 AC_MSG_RESULT([    rrdtool:  . . . . . . . . . $enable_timeseries_rrdtool])
788 AC_MSG_RESULT()
789 AC_MSG_RESULT([  Store implementations:])
790 AC_MSG_RESULT([    memory: . . . . . . . . . . $enable_store_memory])
791 AC_MSG_RESULT([    network (writer): . . . . . $enable_store_network])
792 AC_MSG_RESULT()
793 AC_MSG_RESULT([  Plugins:])
794 AC_MSG_RESULT([    cname::dns: . . . . . . . . $enable_cname_dns])
795 AC_MSG_RESULT([    syslog: . . . . . . . . . . $enable_syslog])
796 AC_MSG_RESULT()
797 AC_MSG_RESULT([This package is maintained by $PACKAGE_MAINTAINER.])
798 AC_MSG_RESULT([Please report bugs to $PACKAGE_BUGREPORT.])
799 AC_MSG_RESULT()
801 dnl vim: set tw=78 sw=4 ts=4 noexpandtab :