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