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 Only check this after potentially defining _GNU_SOURCE.
450 AC_FUNC_STRERROR_R
452 dnl Testing.
453 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],
454 [unit_tests="yes"], [unit_tests="no"])
456 AC_CHECK_HEADERS(libgen.h)
458 dnl Check for dependencies.
459 AC_ARG_WITH([libdbi],
460 [AS_HELP_STRING([--with-libdbi], [libdbi support (default: auto)])],
461 [with_libdbi="$withval"],
462 [with_libdbi="yes"])
463 if test "x$with_libdbi" = "xyes" || test "x$with_libdbi" = "xauto"; then
464 AC_CHECK_HEADERS([dbi/dbi.h],
465 [with_libdbi="yes"],
466 [with_libdbi="no (dbi/dbi.h not found)"])
467 else if test "x$with_libdbi" = "xno"; then
468 with_libdbi="$with_libdbi (disabled on command-line)"
469 else
470 AC_MSG_ERROR([Invalid value for option --with-libdbi=$with_libdbi (expected "yes", "no", or "auto")])
471 fi; fi
472 if test "x$with_libdbi" = "xyes"; then
473 AC_CHECK_LIB([dbi], [dbi_initialize],
474 [with_libdbi="yes"],
475 [with_libdbi="no (libdbi or symbol 'dbi_initialize' not found)"])
476 fi
477 AM_CONDITIONAL([BUILD_WITH_LIBDBI], test "x$with_libdbi" = "xyes")
479 AC_ARG_WITH([libyajl],
480 [AS_HELP_STRING([--with-liyajl], [libyajl support (default: auto)])],
481 [with_libyajl="$withval"],
482 [with_libyajl="yes"])
483 if test "x$with_libyajl" = "xyes" || test "x$with_libyajl" = "xauto"; then
484 PKG_CHECK_MODULES([YAJL], [yajl], [have_libyajl="yes"], [have_libyajl="no"])
485 fi
486 if test "x$have_libyajl" = "xyes"; then
487 AC_DEFINE([HAVE_LIBYAJL], 1, [Define to 1 if you have the 'yajl' library.])
488 fi
490 dnl Required for mocking FILE related functions.
491 orig_CFLAGS="$CFLAGS"
492 CFLAGS="$CFLAGS -D_GNU_SOURCE"
493 AC_CHECK_FUNCS([fopencookie],
494 [have_fopencookie="yes"],
495 [have_fopencookie="no (fopencookie not available)"])
496 CFLAGS="$orig_CFLAGS"
497 AM_CONDITIONAL([BUILD_WITH_FOPENCOOKIE], test "x$have_fopencookie" = "xyes")
498 if test "x$have_fopencookie" = "xyes"; then
499 AC_DEFINE([HAVE_FOPENCOOKIE], 1)
500 fi
502 dnl OpenSSL support
503 PKG_CHECK_MODULES([OPENSSL], [openssl], [have_openssl="yes"], [have_openssl="no"])
504 if test "x$have_openssl" != "xyes"; then
505 AC_MSG_ERROR([OpenSSL not found])
506 fi
508 dnl readline support
509 AC_ARG_WITH([readline],
510 [AS_HELP_STRING([--with-readline],
511 [readline support (libedit/libreadline) (default: auto, prefer libedit)])],
512 [readline_support="$withval"],
513 [readline_support="auto"])
515 if test "x$readline_support" = "xyes"; then
516 readline_support="auto"
517 else if test "x$readline_support" != "xauto" \
518 && test "x$readline_support" != "xno" \
519 && test "x$readline_support" != "xlibedit" \
520 && test "x$readline_support" != "xlibreadline"; then
521 AC_MSG_ERROR([Invalid value for option --with-readline=$readline_support (expected "yes", "no", "auto", "libedit", or "libreadline")])
522 fi; fi
524 have_libedit="no"
525 if test "x$readline_support" = "xauto" \
526 || test "x$readline_support" = "xlibedit"; then
527 PKG_CHECK_MODULES([LIBEDIT], [libedit],
528 [have_libedit="yes"], [have_libedit="no"])
529 if test "x$have_libedit" = "xyes"; then
530 AC_CHECK_HEADERS([editline/readline.h], [],
531 [AC_CHECK_HEADERS([readline.h], [],
532 [have_libedit="no (readline header not found"])])
533 fi
534 if test "x$have_libedit" = "xyes"; then
535 AC_CHECK_HEADERS([editline/history.h], [],
536 [AC_CHECK_HEADERS([history.h], [],
537 [have_libedit="no (history header not found"])])
538 fi
539 else
540 have_libedit="disabled on command-line"
541 fi
543 have_libreadline="no"
544 if test "x$have_libedit" != "xyes"; then
545 if test "x$readline_support" = "xauto" \
546 || test "x$readline_support" = "xlibreadline"; then
547 AC_CHECK_LIB([readline], [readline],
548 [have_libreadline="yes"],
549 [have_libreadline="no (libreadline or symbol 'readline' not found)"])
550 fi
551 if test "x$have_libreadline" = "xyes"; then
552 AC_CHECK_HEADERS([readline/readline.h], [],
553 [AC_CHECK_HEADERS([readline.h], [],
554 [have_libreadline="no (readline header not found"])])
555 fi
556 if test "x$have_libreadline" = "xyes"; then
557 AC_CHECK_HEADERS([readline/history.h], [],
558 [AC_CHECK_HEADERS([history.h], [],
559 [have_libreadline="no (history header not found"])])
560 fi
561 else
562 have_libreadline="unchecked (prefer libedit)"
563 fi
565 if test "x$have_libedit" = "xyes"; then
566 READLINE_LIBS="$LIBEDIT_LIBS"
567 READLINE_CFLAGS="$LIBEDIT_CFLAGS"
568 readline_support="libedit"
569 else if test "x$have_libreadline" = "xyes"; then
570 READLINE_LIBS="-lreadline -lhistory"
571 READLINE_CFLAGS=""
572 readline_support="libreadline"
573 else
574 READLINE_LIBS=""
575 READLINE_CFLAGS=""
576 if test "x$readline_support" = "xno"; then
577 AC_MSG_WARN([*** readline support disabled; disabling SysDB client])
578 else if test "x$readline_support" = "xauto"; then
579 AC_MSG_WARN([*** readline not found; disabling SysDB client])
580 else
581 AC_MSG_ERROR([readline not found])
582 fi; fi
583 readline_support="no"
584 fi; fi
585 AC_SUBST([READLINE_LIBS])
586 AC_SUBST([READLINE_CFLAGS])
587 AM_CONDITIONAL([BUILD_CLIENT], test "x$readline_support" != "no")
589 AC_LANG_PUSH(C++)
590 AC_ARG_WITH([libfacter],
591 [AS_HELP_STRING([--with-libfacter], [libfacter support (default: auto)])],
592 [with_libfacter="$withval"],
593 [with_libfacter="yes"])
594 if test "x$with_libfacter" = "xyes" || test "x$with_libfacter" = "xauto"; then
595 AC_CHECK_HEADERS([facter/facts/collection.hpp],
596 [have_libfacter="yes"],
597 [have_libfacter="no (facter/facts/collection.hpp not found)"])
598 else if test "x$with_libfacter" = "xno"; then
599 have_libfacter="$with_libfacter (disabled on command-line)"
600 else
601 AC_MSG_ERROR([Invalid value for option --with-libfacter=$with_libfacter (expected "yes", "no", or "auto")])
602 fi; fi
603 if test "x$have_libfacter" = "xyes"; then
604 AC_MSG_CHECKING([for facter::facts::collection in -lfacter])
605 AC_LINK_IFELSE(
606 [AC_LANG_PROGRAM(
607 [[ #include <facter/facts/collection.hpp> ]],
608 [[
609 facter::facts::collection facts;
610 facts.add_default_facts();
611 ]]
612 )],
613 [TEST_LIBS=$TEST_LIBS -lfacter],
614 [have_libfacter="yes"],
615 [have_libfacter="no (libfacter not found)"])
616 AC_MSG_RESULT([$have_libfacter])
617 fi
618 AC_LANG_POP(C++)
620 AC_ARG_WITH([librrd],
621 [AS_HELP_STRING([--with-librrd], [librrd support (default: auto)])],
622 [with_librrd="$withval"],
623 [with_librrd="yes"])
624 if test "x$with_librrd" = "xyes" || test "x$with_librrd" = "xauto"; then
625 PKG_CHECK_MODULES([RRD], [librrd],
626 [have_librrd="yes"], [have_librrd="no"])
627 else if test "x$with_librrd" = "xno"; then
628 have_librrd="$with_librrd (disabled on command-line)"
629 else
630 AC_MSG_ERROR([Invalid value for option --with-librrd=$with_librrd (expected "yes", "no", or "auto")])
631 fi; fi
633 if test "x$have_librrd" = "xyes"; then
634 AC_CHECK_HEADERS([rrd.h])
635 AC_CHECK_HEADERS([rrd_client.h], [], [], [[#include <rrd.h>]])
636 fi
638 dnl Feature checks.
639 build_documentation="yes"
641 have_xmlto="yes"
642 AC_PATH_PROG([XMLTO], [xmlto])
643 if test "x$XMLTO" = "x"; then
644 have_xmlto="no"
645 build_documentation="no (missing xmlto)"
646 fi
647 AC_SUBST([XMLTO])
649 have_asciidoc="yes"
650 AC_PATH_PROG([ASCIIDOC], [asciidoc])
651 if test "x$ASCIIDOC" = "x"; then
652 have_asciidoc="no"
653 build_documentation="no (missing asciidoc)"
654 fi
655 AC_SUBST([ASCIIDOC])
657 AC_ARG_VAR([ADOCFLAGS], [AsciiDoc flags])
659 integration_tests="yes"
660 AC_PATH_PROG([VALGRIND], [valgrind])
661 if test "x$VALGRIND" = "x"; then
662 integration_tests="no (missing valgrind)"
663 fi
664 AM_CONDITIONAL([INTEGRATION_TESTING], test "x$integration_tests" = "xyes")
666 dnl Plugin checks.
667 facter_default=$have_libfacter
668 if test "x$facter_default" != "xyes"; then
669 facter_default="no (requires libfacter)"
670 fi
671 puppet_storeconfigs_default=$with_libdbi
672 if test "x$puppet_storeconfigs_default" != "xyes"; then
673 puppet_storeconfigs_default="no (requires libdbi)"
674 fi
675 rrdtool_default=$have_librrd
676 if test "x$rrdtool_default" != "xyes"; then
677 rrdtool_default="no (required librrd)"
678 fi
680 m4_divert_once([HELP_ENABLE], [
681 Backends:])
683 AC_SDB_PLUGIN_INIT
684 AC_SDB_PLUGIN([collectd-unixsock], [yes],
685 [backend accessing the system statistics collection daemon])
686 AC_SDB_PLUGIN([facter], [$facter_default],
687 [backend retrieving local facter facts])
688 AC_SDB_PLUGIN([mk-livestatus], [yes],
689 [backend accessing Nagios/Icinga/Shinken using MK Livestatus])
690 AC_SDB_PLUGIN([puppet-storeconfigs], [$puppet_storeconfigs_default],
691 [backend accessing the Puppet stored configuration database])
693 m4_divert_once([HELP_ENABLE], [
694 Time-series fetchers:])
695 AC_SDB_PLUGIN([timeseries-rrdtool], [$rrdtool_default],
696 [fetch time-series data from RRD files])
698 m4_divert_once([HELP_ENABLE], [
699 Store implementations:])
700 AC_SDB_PLUGIN([store-memory], [yes],
701 [store objects in a volatile, in-memory database (read/write)])
702 AC_SDB_PLUGIN([store-network], [yes],
703 [send stored objects to a remote instance (write only)])
705 m4_divert_once([HELP_ENABLE], [
706 Plugins:])
708 AC_SDB_PLUGIN([cname-dns], [yes],
709 [canonicalize hostnames by querying DNS])
710 AC_SDB_PLUGIN([syslog], [yes],
711 [plugin logging to syslog])
713 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
714 AM_CONDITIONAL([UNIT_TESTING], test "x$unit_tests" = "xyes")
716 AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile
717 src/liboconfig/Makefile t/Makefile])
718 AC_OUTPUT
720 BUILD_DATE="`date --utc '+%F %T'` (UTC)"
722 asciidoc_info="$have_asciidoc"
723 if test "x$have_asciidoc" = "xyes"; then
724 asciidoc_info="`$ASCIIDOC --version`"
725 fi
726 xmlto_info="$have_xmlto"
727 if test "x$have_xmlto" = "xyes"; then
728 xmlto_info="`$XMLTO --version`"
729 fi
731 if test "x$unit_tests" = "xyes"; then
732 unit_tests="yes (check `$PKG_CONFIG --modversion check`)"
733 fi
735 openssl_info="$have_openssl"
736 if test "x$have_openssl" = "xyes"; then
737 openssl_info="yes (version `$PKG_CONFIG --modversion openssl`)"
738 fi
739 libedit_info="$have_libedit"
740 if test "x$have_libedit" = "xyes"; then
741 libedit_info="yes (version `$PKG_CONFIG --modversion libedit`)"
742 fi
743 librrd_info="$have_librrd"
744 if test "x$have_librrd" = "xyes"; then
745 librrd_info="yes (version `$PKG_CONFIG --modversion librrd`)"
746 fi
747 libyajl_info="$have_libyajl"
748 if test "x$have_libyajl" = "xyes"; then
749 libyajl_info="yes (version `$PKG_CONFIG --modversion yajl`)"
750 fi
752 AC_MSG_RESULT()
753 AC_MSG_RESULT([$PACKAGE_NAME has been configured successfully.])
754 AC_MSG_RESULT()
755 AC_MSG_RESULT([Run 'make' to compile the software and use 'make install' to])
756 AC_MSG_RESULT([install the package into $prefix.])
757 AC_MSG_RESULT()
758 AC_MSG_RESULT([Configuration summary:])
759 AC_MSG_RESULT()
760 AC_MSG_RESULT([ package version: $PACKAGE_VERSION])
761 AC_MSG_RESULT([ build date: $BUILD_DATE])
762 AC_MSG_RESULT()
763 AC_MSG_RESULT([ Tools:])
764 AC_MSG_RESULT([ AsciiDoc: . . . . . . . . . $asciidoc_info])
765 AC_MSG_RESULT([ xmlto: . . . . . . . . . . $xmlto_info])
766 AC_MSG_RESULT()
767 AC_MSG_RESULT([ Features:])
768 AC_MSG_RESULT([ documentation: . . . . . . $build_documentation])
769 AC_MSG_RESULT([ unit testing: . . . . . . . $unit_tests])
770 AC_MSG_RESULT([ stdio mocking: . . . . . $have_fopencookie])
771 AC_MSG_RESULT([ coverage testing: . . . . . $enable_gcov])
772 AC_MSG_RESULT([ integration testing: . . . $integration_tests])
773 AC_MSG_RESULT([ profiling: . . . . . . . . $enable_gprof])
774 AC_MSG_RESULT()
775 AC_MSG_RESULT([ Libraries:])
776 AC_MSG_RESULT([ libdbi: . . . . . . . . . . $with_libdbi])
777 AC_MSG_RESULT([ libedit: . . . . . . . . . $libedit_info])
778 AC_MSG_RESULT([ libopenssl: . . . . . . . . $openssl_info])
779 AC_MSG_RESULT([ libreadline: . . . . . . . $have_libreadline])
780 AC_MSG_RESULT([ librrd: . . . . . . . . . . $librrd_info])
781 AC_MSG_RESULT([ libyajl: . . . . . . . . . $libyajl_info])
782 AC_MSG_RESULT()
783 AC_MSG_RESULT([ Backends:])
784 AC_MSG_RESULT([ collectd::unixsock: . . . . $enable_collectd_unixsock])
785 AC_MSG_RESULT([ facter . . . . . . . . . . $enable_facter])
786 AC_MSG_RESULT([ mk-livestatus: . . . . . . $enable_mk_livestatus])
787 AC_MSG_RESULT([ puppet::storeconfigs: . . . $enable_puppet_storeconfigs])
788 AC_MSG_RESULT()
789 AC_MSG_RESULT([ Time-series fetchers:])
790 AC_MSG_RESULT([ rrdtool: . . . . . . . . . $enable_timeseries_rrdtool])
791 AC_MSG_RESULT()
792 AC_MSG_RESULT([ Store implementations:])
793 AC_MSG_RESULT([ memory: . . . . . . . . . . $enable_store_memory])
794 AC_MSG_RESULT([ network (writer): . . . . . $enable_store_network])
795 AC_MSG_RESULT()
796 AC_MSG_RESULT([ Plugins:])
797 AC_MSG_RESULT([ cname::dns: . . . . . . . . $enable_cname_dns])
798 AC_MSG_RESULT([ syslog: . . . . . . . . . . $enable_syslog])
799 AC_MSG_RESULT()
800 AC_MSG_RESULT([This package is maintained by $PACKAGE_MAINTAINER.])
801 AC_MSG_RESULT([Please report bugs to $PACKAGE_BUGREPORT.])
802 AC_MSG_RESULT()
804 dnl vim: set tw=78 sw=4 ts=4 noexpandtab :