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