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 readline support
487 AC_ARG_WITH([readline],
488 [AS_HELP_STRING([--with-readline],
489 [readline support (libedit/libreadline) (default: auto, prefer libedit)])],
490 [readline_support="$withval"],
491 [readline_support="auto"])
493 if test "x$readline_support" = "xyes"; then
494 readline_support="auto"
495 else if test "x$readline_support" != "xauto" \
496 && test "x$readline_support" != "xno" \
497 && test "x$readline_support" != "xlibedit" \
498 && test "x$readline_support" != "xlibreadline"; then
499 AC_MSG_ERROR([Invalid value for option --with-readline=$readline_support (expected "yes", "no", "auto", "libedit", or "libreadline")])
500 fi; fi
502 have_libedit="no"
503 if test "x$readline_support" = "xauto" \
504 || test "x$readline_support" = "xlibedit"; then
505 PKG_CHECK_MODULES([LIBEDIT], [libedit],
506 [have_libedit="yes"], [have_libedit="no"])
507 if test "x$have_libedit" = "xyes"; then
508 AC_CHECK_HEADERS([editline/readline.h], [],
509 [AC_CHECK_HEADERS([readline.h], [],
510 [have_libedit="no (readline header not found"])])
511 fi
512 if test "x$have_libedit" = "xyes"; then
513 AC_CHECK_HEADERS([editline/history.h], [],
514 [AC_CHECK_HEADERS([history.h], [],
515 [have_libedit="no (history header not found"])])
516 fi
517 else
518 have_libedit="disabled on command-line"
519 fi
521 have_libreadline="no"
522 if test "x$have_libedit" != "xyes"; then
523 if test "x$readline_support" = "xauto" \
524 || test "x$readline_support" = "xlibreadline"; then
525 AC_CHECK_LIB([readline], [readline],
526 [have_libreadline="yes"],
527 [have_libreadline="no (libreadline or symbol 'readline' not found)"])
528 fi
529 if test "x$have_libreadline" = "xyes"; then
530 AC_CHECK_HEADERS([readline/readline.h], [],
531 [AC_CHECK_HEADERS([readline.h], [],
532 [have_libreadline="no (readline header not found"])])
533 fi
534 if test "x$have_libreadline" = "xyes"; then
535 AC_CHECK_HEADERS([readline/history.h], [],
536 [AC_CHECK_HEADERS([history.h], [],
537 [have_libreadline="no (history header not found"])])
538 fi
539 else
540 have_libreadline="unchecked (prefer libedit)"
541 fi
543 if test "x$have_libedit" = "xyes"; then
544 READLINE_LIBS="$LIBEDIT_LIBS"
545 READLINE_CFLAGS="$LIBEDIT_CFLAGS"
546 readline_support="libedit"
547 else if test "x$have_libreadline" = "xyes"; then
548 READLINE_LIBS="-lreadline -lhistory"
549 READLINE_CFLAGS=""
550 readline_support="libreadline"
551 else
552 READLINE_LIBS=""
553 READLINE_CFLAGS=""
554 if test "x$readline_support" = "xno"; then
555 AC_MSG_WARN([*** readline support disabled; disabling SysDB client])
556 else if test "x$readline_support" = "xauto"; then
557 AC_MSG_WARN([*** readline not found; disabling SysDB client])
558 else
559 AC_MSG_ERROR([readline not found])
560 fi; fi
561 readline_support="no"
562 fi; fi
563 AC_SUBST([READLINE_LIBS])
564 AC_SUBST([READLINE_CFLAGS])
565 AM_CONDITIONAL([BUILD_CLIENT], test "x$readline_support" != "no")
567 AC_LANG_PUSH(C++)
568 AC_ARG_WITH([libfacter],
569 [AS_HELP_STRING([--with-libfacter], [libfacter support (default: auto)])],
570 [with_libfacter="$withval"],
571 [with_libfacter="yes"])
572 if test "x$with_libfacter" = "xyes" || test "x$with_libfacter" = "xauto"; then
573 AC_CHECK_HEADERS([facter/facts/collection.hpp],
574 [have_libfacter="yes"],
575 [have_libfacter="no (facter/facts/collection.hpp not found)"])
576 else if test "x$with_libfacter" = "xno"; then
577 have_libfacter="$with_libfacter (disabled on command-line)"
578 else
579 AC_MSG_ERROR([Invalid value for option --with-libfacter=$with_libfacter (expected "yes", "no", or "auto")])
580 fi; fi
581 if test "x$have_libfacter" = "xyes"; then
582 AC_MSG_CHECKING([for facter::facts::collection in -lfacter])
583 AC_LINK_IFELSE(
584 [AC_LANG_PROGRAM(
585 [[ #include <facter/facts/collection.hpp> ]],
586 [[
587 facter::facts::collection facts;
588 facts.add_default_facts();
589 ]]
590 )],
591 [TEST_LIBS=$TEST_LIBS -lfacter],
592 [have_libfacter="yes"],
593 [have_libfacter="no (libfacter not found)"])
594 AC_MSG_RESULT([$have_libfacter])
595 fi
596 AC_LANG_POP(C++)
598 AC_ARG_WITH([librrd],
599 [AS_HELP_STRING([--with-librrd], [librrd support (default: auto)])],
600 [with_librrd="$withval"],
601 [with_librrd="yes"])
602 if test "x$with_librrd" = "xyes" || test "x$with_librrd" = "xauto"; then
603 PKG_CHECK_MODULES([RRD], [librrd],
604 [have_librrd="yes"], [have_librrd="no"])
605 else if test "x$with_librrd" = "xno"; then
606 have_librrd="$with_librrd (disabled on command-line)"
607 else
608 AC_MSG_ERROR([Invalid value for option --with-librrd=$with_librrd (expected "yes", "no", or "auto")])
609 fi; fi
611 if test "x$have_librrd" = "xyes"; then
612 AC_CHECK_HEADERS([rrd_client.h])
613 fi
615 dnl Feature checks.
616 build_documentation="yes"
618 have_xmlto="yes"
619 AC_PATH_PROG([XMLTO], [xmlto])
620 if test "x$XMLTO" = "x"; then
621 have_xmlto="no"
622 build_documentation="no (missing xmlto)"
623 fi
624 AC_SUBST([XMLTO])
626 have_asciidoc="yes"
627 AC_PATH_PROG([ASCIIDOC], [asciidoc])
628 if test "x$ASCIIDOC" = "x"; then
629 have_asciidoc="no"
630 build_documentation="no (missing asciidoc)"
631 fi
632 AC_SUBST([ASCIIDOC])
634 AC_ARG_VAR([ADOCFLAGS], [AsciiDoc flags])
636 integration_tests="yes"
637 AC_PATH_PROG([VALGRIND], [valgrind])
638 if test "x$VALGRIND" = "x"; then
639 integration_tests="no (missing valgrind)"
640 fi
641 AM_CONDITIONAL([INTEGRATION_TESTING], test "x$integration_tests" = "xyes")
643 dnl Plugin checks.
644 facter_default=$have_libfacter
645 if test "x$facter_default" != "xyes"; then
646 facter_default="no (requires libfacter)"
647 fi
648 puppet_storeconfigs_default=$with_libdbi
649 if test "x$puppet_storeconfigs_default" != "xyes"; then
650 puppet_storeconfigs_default="no (requires libdbi)"
651 fi
652 rrdtool_default=$have_librrd
653 if test "x$rrdtool_default" != "xyes"; then
654 rrdtool_default="no (required librrd)"
655 fi
657 m4_divert_once([HELP_ENABLE], [
658 Backends:])
660 AC_SDB_PLUGIN_INIT
661 AC_SDB_PLUGIN([collectd-unixsock], [yes],
662 [backend accessing the system statistics collection daemon])
663 AC_SDB_PLUGIN([facter], [$facter_default],
664 [backend retrieving local facter facts])
665 AC_SDB_PLUGIN([mk-livestatus], [yes],
666 [backend accessing Nagios/Icinga/Shinken using MK Livestatus])
667 AC_SDB_PLUGIN([puppet-storeconfigs], [$puppet_storeconfigs_default],
668 [backend accessing the Puppet stored configuration database])
670 m4_divert_once([HELP_ENABLE], [
671 Time-series fetchers:])
672 AC_SDB_PLUGIN([timeseries-rrdtool], [$rrdtool_default],
673 [fetch time-series data from RRD files])
675 m4_divert_once([HELP_ENABLE], [
676 Plugins:])
678 AC_SDB_PLUGIN([cname-dns], [yes],
679 [canonicalize hostnames by querying DNS])
680 AC_SDB_PLUGIN([syslog], [yes],
681 [plugin logging to syslog])
683 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
684 AM_CONDITIONAL([UNIT_TESTING], test "x$unit_tests" = "xyes")
686 AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile
687 src/liboconfig/Makefile t/Makefile])
688 AC_OUTPUT
690 BUILD_DATE="`date --utc '+%F %T'` (UTC)"
692 AC_MSG_RESULT()
693 AC_MSG_RESULT([$PACKAGE_NAME has been configured successfully.])
694 AC_MSG_RESULT()
695 AC_MSG_RESULT([Run 'make' to compile the software and use 'make install' to])
696 AC_MSG_RESULT([install the package into $prefix.])
697 AC_MSG_RESULT()
698 AC_MSG_RESULT([Configuration summary:])
699 AC_MSG_RESULT()
700 AC_MSG_RESULT([ package version: $PACKAGE_VERSION])
701 AC_MSG_RESULT([ build date: $BUILD_DATE])
702 AC_MSG_RESULT()
703 AC_MSG_RESULT([ Tools:])
704 AC_MSG_RESULT([ AsciiDoc: . . . . . . . . . $have_asciidoc])
705 AC_MSG_RESULT([ xmlto: . . . . . . . . . . $have_xmlto])
706 AC_MSG_RESULT()
707 AC_MSG_RESULT([ Features:])
708 AC_MSG_RESULT([ documentation: . . . . . . $build_documentation])
709 AC_MSG_RESULT([ unit testing: . . . . . . . $unit_tests])
710 AC_MSG_RESULT([ stdio mocking: . . . . . $have_fopencookie])
711 AC_MSG_RESULT([ coverage testing: . . . . . $enable_gcov])
712 AC_MSG_RESULT([ integration testing: . . . $integration_tests])
713 AC_MSG_RESULT([ profiling: . . . . . . . . $enable_gprof])
714 AC_MSG_RESULT()
715 AC_MSG_RESULT([ Libraries:])
716 AC_MSG_RESULT([ libdbi: . . . . . . . . . . $with_libdbi])
717 AC_MSG_RESULT([ libedit: . . . . . . . . . $have_libedit])
718 AC_MSG_RESULT([ libreadline: . . . . . . . $have_libreadline])
719 AC_MSG_RESULT([ librrd: . . . . . . . . . . $have_librrd])
720 AC_MSG_RESULT()
721 AC_MSG_RESULT([ Backends:])
722 AC_MSG_RESULT([ collectd::unixsock: . . . . $enable_collectd_unixsock])
723 AC_MSG_RESULT([ facter . . . . . . . . . . $enable_facter])
724 AC_MSG_RESULT([ mk-livestatus: . . . . . . $enable_mk_livestatus])
725 AC_MSG_RESULT([ puppet::storeconfigs: . . . $enable_puppet_storeconfigs])
726 AC_MSG_RESULT()
727 AC_MSG_RESULT([ Time-series fetchers:])
728 AC_MSG_RESULT([ rrdtool: . . . . . . . . . $enable_timeseries_rrdtool])
729 AC_MSG_RESULT()
730 AC_MSG_RESULT([ Plugins:])
731 AC_MSG_RESULT([ cname::dns: . . . . . . . . $enable_cname_dns])
732 AC_MSG_RESULT([ syslog: . . . . . . . . . . $enable_syslog])
733 AC_MSG_RESULT()
734 AC_MSG_RESULT([This package is maintained by $PACKAGE_MAINTAINER.])
735 AC_MSG_RESULT([Please report bugs to $PACKAGE_BUGREPORT.])
736 AC_MSG_RESULT()
738 dnl vim: set tw=78 sw=4 ts=4 noexpandtab :