Code

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