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 [sh@tokkee.org],
31 [sysdb],
32 [http://git.tokkee.org/?p=sysdb.git])
33 PACKAGE_MAINTAINER="Sebastian 'tokkee' Harl <sh@tokkee.org>"
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 -Wall])
42 AC_LANG(C)
44 AC_SYS_LARGEFILE
46 AC_PROG_CC
47 AC_PROG_CPP
48 AC_PROG_INSTALL
49 AC_PROG_LN_S
50 AC_PROG_MAKE_SET
52 AM_PROG_CC_C_O
53 AM_PROG_LEX
54 AC_PROG_YACC
56 m4_ifdef([LT_INIT],
57 [
58 LT_CONFIG_LTDL_DIR([libltdl])
59 LT_INIT([dlopen])
60 LTDL_INIT([convenience])
61 ],
62 # else
63 # (older libtools)
64 [
65 AC_CONFIG_SUBDIRS(libltdl)
66 AC_LIBLTDL_CONVENIENCE
67 AC_SUBST(LTDLINCL)
68 AC_SUBST(LIBLTDL)
69 AC_LIBTOOL_DLOPEN
70 ]
71 )
73 test_cc_flags() {
74 AC_LANG_CONFTEST([AC_LANG_PROGRAM([[ ]], [[ ]])])
75 $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
76 ret=$?
77 rm -f conftest.o
78 return $ret
79 }
81 m4_divert_once([HELP_ENABLE], [
82 Build options:])
84 dnl Optionally stick to standard C99 and POSIX:2001 as close as possible.
85 AC_ARG_ENABLE([standards],
86 AS_HELP_STRING([--enable-standards],
87 [C99 / POSIX standards compliance mode @<:@default=no@:>@]),
88 [enable_standards="$enableval"],
89 [enable_standards="no"])
91 if test "x$enable_standards" = "xyes"; then
92 AC_DEFINE([_ISOC99_SOURCE], 1,
93 [Define to enforce ISO/IEC 9899:1999 (C99) compliance.])
94 AC_DEFINE([_POSIX_C_SOURCE], 200112L,
95 [Define to enforce IEEE 1003.1-2001 (POSIX:2001) compliance.])
96 AC_DEFINE([_XOPEN_SOURCE], 600,
97 [Define to enforce X/Open 6 (XSI) compliance.])
98 AC_DEFINE([_REENTRANT], 1,
99 [Define to enable reentrant interfaces.])
100 AC_DEFINE([_THREAD_SAFE], 1,
101 [Define to enable reentrant interfaces.])
103 for flag in -std=c99 -pedantic; do
104 AC_MSG_CHECKING([whether $CC accepts $flag])
106 if test_cc_flags $flag; then
107 CFLAGS="$CFLAGS $flag"
108 AC_MSG_RESULT([yes])
109 else
110 AC_MSG_RESULT([no])
111 fi
112 done
113 fi
115 dnl Hardening (see e.g. http://wiki.debian.org/Hardening for a motivation).
116 AC_DEFINE([_FORTIFY_SOURCE], 2,
117 [Define to enable protection against static sized buffer overflows.])
118 AC_ARG_ENABLE([hardening],
119 AS_HELP_STRING([--disable-hardening],
120 [hardening options @<:@default=yes@:>@]),
121 [enable_hardening="$enableval"],
122 [enable_hardening="yes"])
124 if test "x$enable_hardening" = "xyes"; then
125 hardening=0
126 hardening_tests=0
127 for flag in -Wformat -Wformat-security; do
128 hardening_tests=$(($hardening_tests + 1))
129 AC_MSG_CHECKING([whether $CC accepts $flag])
131 if test_cc_flags $flag; then
132 CFLAGS="$CFLAGS $flag"
133 hardening=$(($hardening + 1))
134 AC_MSG_RESULT([yes])
135 else
136 AC_MSG_RESULT([no])
137 fi
138 done
139 if test $hardening -ne $hardening_tests; then
140 AC_MSG_WARN(
141 [Some hardening options are not supported by your compiler!])
142 fi
143 fi
145 dnl Strict checking for potential problems.
146 AC_ARG_ENABLE([strict-checks],
147 AS_HELP_STRING([--disable-strict-checks],
148 [strict compiler checks @<:@default=yes@:>@]),
149 [enable_strict_checks="$enableval"],
150 [enable_strict_checks="yes"])
152 STRICT_CFLAGS=""
153 for flag in -Wall -Werror; do
154 AC_MSG_CHECKING([whether $CC accepts $flag])
156 if test_cc_flags $flag; then
157 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
158 AC_MSG_RESULT([yes])
159 else
160 AC_MSG_RESULT([no])
161 fi
162 done
164 if test "x$enable_strict_checks" = "xyes"; then
165 for flag in -Wextra \
166 -Wbad-function-cast \
167 -Wcast-align \
168 -Wcast-qual \
169 -Wconversion \
170 -Wdeclaration-after-statement \
171 -Wmissing-prototypes \
172 -Wpointer-arith \
173 -Wshadow \
174 -Wstrict-prototypes; do
175 AC_MSG_CHECKING([whether $CC accepts $flag])
177 if test_cc_flags $flag; then
178 STRICT_CFLAGS="$STRICT_CFLAGS $flag"
179 AC_MSG_RESULT([yes])
180 else
181 AC_MSG_RESULT([no])
182 fi
183 done
184 fi
185 AC_SUBST([STRICT_CFLAGS])
187 m4_divert_once([HELP_ENABLE], [
188 Build dependencies:])
190 dnl Testing.
191 PKG_CHECK_MODULES([CHECK], [check >= 0.9.4],
192 [build_testing="yes"], [build_testing="no"])
194 AC_CHECK_HEADERS(libgen.h)
196 dnl Check for dependencies.
197 AC_ARG_WITH([libdbi],
198 [AS_HELP_STRING([--with-libdbi], [libdbi support (default: auto)])],
199 [with_libdbi="$withval"],
200 [with_libdbi="yes"])
201 if test "x$with_libdbi" = "xyes"; then
202 AC_CHECK_HEADERS([dbi/dbi.h],
203 [with_libdbi="yes"],
204 [with_libdbi="no (dbi/dbi.h) not found"])
205 fi
206 if test "x$with_libdbi" = "xyes"; then
207 AC_CHECK_LIB([dbi], [dbi_initialize],
208 [with_libdbi="yes"],
209 [with_libdbi="no (libdbi or symbol 'dbi_initialize' not found)"])
210 fi
211 AM_CONDITIONAL([BUILD_WITH_LIBDBI], test "x$with_libdbi" = "xyes")
213 dnl Required for mocking FILE related functions.
214 orig_CFLAGS="$CFLAGS"
215 CFLAGS="$CFLAGS -D_GNU_SOURCE"
216 AC_CHECK_FUNCS([fopencookie],
217 [have_fopencookie="yes"],
218 [have_fopencookie="no (fopencookie not available)"])
219 CFLAGS="$orig_CFLAGS"
220 AM_CONDITIONAL([BUILD_WITH_FOPENCOOKIE], test "x$have_fopencookie" = "xyes")
221 if test "x$have_fopencookie" = "xyes"; then
222 AC_DEFINE([HAVE_FOPENCOOKIE], 1)
223 fi
225 dnl readline support
226 AC_ARG_WITH([readline],
227 [AS_HELP_STRING([--with-readline],
228 [readline support (libedit/libreadline) (default: auto, prefer libedit)])],
229 [readline_support="$withval"],
230 [readline_support="auto"])
232 if test "x$readline_support" = "xyes"; then
233 readline_support="auto"
234 fi
236 have_libedit="no"
237 if test "x$readline_support" = "xauto" \
238 || test "x$readline_support" = "xlibedit"; then
239 PKG_CHECK_MODULES([LIBEDIT], [libedit],
240 [have_libedit="yes"], [have_libedit="no"])
241 if test "x$have_libedit" = "xyes"; then
242 AC_CHECK_HEADERS([editline/readline.h], [],
243 [AC_CHECK_HEADERS([readline.h], [],
244 [have_libedit="no (readline header not found"])])
245 fi
246 if test "x$have_libedit" = "xyes"; then
247 AC_CHECK_HEADERS([editline/history.h], [],
248 [AC_CHECK_HEADERS([history.h], [],
249 [have_libedit="no (history header not found"])])
250 fi
251 else
252 have_libedit="disabled on command-line"
253 fi
255 have_libreadline="no"
256 if test "x$have_libedit" = "xno"; then
257 if test "x$readline_support" = "xauto" \
258 || test "x$readline_support" = "xlibreadline"; then
259 AC_CHECK_LIB([readline], [readline],
260 [have_libreadline="yes"],
261 [have_libreadline="no (libreadline or symbol 'readline' not found)"])
262 fi
263 if test "x$have_libreadline" = "xyes"; then
264 AC_CHECK_HEADERS([readline/readline.h], [],
265 [AC_CHECK_HEADERS([readline.h], [],
266 [have_libreadline="no (readline header not found"])])
267 fi
268 if test "x$have_libreadline" = "xyes"; then
269 AC_CHECK_HEADERS([readline/history.h], [],
270 [AC_CHECK_HEADERS([history.h], [],
271 [have_libreadline="no (history header not found"])])
272 fi
273 else
274 have_libreadline="unchecked (prefer libedit)"
275 fi
277 if test "x$have_libedit" = "xyes"; then
278 READLINE_LIBS="$LIBEDIT_LIBS"
279 READLINE_CFLAGS="$LIBEDIT_CFLAGS"
280 readline_support="libedit"
281 else if test "x$have_libreadline" = "xyes"; then
282 READLINE_LIBS="-lreadline -lhistory"
283 READLINE_CFLAGS=""
284 readline_support="libreadline"
285 else
286 READLINE_LIBS=""
287 READLINE_CFLAGS=""
288 if test "x$readline_support" = "xno"; then
289 AC_MSG_WARN([*** readline support disabled; disabling SysDB client])
290 else if test "x$readline_support" = "xauto"; then
291 AC_MSG_WARN([*** readline not found; disabling SysDB client])
292 else
293 AC_MSG_ERROR([readline not found])
294 fi; fi
295 readline_support="no"
296 fi; fi
297 AC_SUBST([READLINE_LIBS])
298 AC_SUBST([READLINE_CFLAGS])
299 AM_CONDITIONAL([BUILD_CLIENT], test "x$readline_support" != "no")
301 dnl Feature checks.
302 build_documentation="yes"
304 have_xmlto="yes"
305 AC_PATH_PROG([XMLTO], [xmlto])
306 if test "x$XMLTO" = "x"; then
307 have_xmlto="no"
308 build_documentation="no (missing xmlto)"
309 fi
311 have_xsltproc="yes"
312 AC_PATH_PROG([XSLTPROC], [xsltproc])
313 if test "x$XSLTPROC" = "x"; then
314 have_xsltproc="no"
315 build_documentation="no (missing xsltproc)"
316 fi
318 have_a2x="yes"
319 AC_PATH_PROG([A2X], [a2x])
320 if test "x$A2X" = "x"; then
321 have_a2x="no"
322 build_documentation="no (missing a2x)"
323 fi
324 AC_SUBST([A2X])
326 dnl Plugin checks.
327 puppet_storeconfigs_default=$with_libdbi
328 if test "x$puppet_storeconfigs_default" != "xyes"; then
329 puppet_storeconfigs_default="no (requires libdbi)"
330 fi
332 m4_divert_once([HELP_ENABLE], [
333 Backends:])
335 AC_SDB_PLUGIN_INIT
336 AC_SDB_PLUGIN([collectd], [yes],
337 [backend accessing the system statistics collection daemon])
338 AC_SDB_PLUGIN([mk-livestatus], [yes],
339 [backend accessing Nagios/Icinga/Shinken using MK Livestatus])
340 AC_SDB_PLUGIN([puppet-storeconfigs], [$puppet_storeconfigs_default],
341 [backend accessing the Puppet stored configuration database])
342 AC_SDB_PLUGIN([syslog], [yes],
343 [plugin logging to syslog])
344 AC_SDB_PLUGIN([cname-dns], [yes],
345 [canonicalize hostnames by querying DNS])
347 AM_CONDITIONAL([BUILD_DOCUMENTATION], test "x$build_documentation" = "xyes")
348 AM_CONDITIONAL([BUILD_TESTING], test "x$build_testing" = "xyes")
350 AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile
351 src/liboconfig/Makefile t/Makefile])
352 AC_OUTPUT
354 BUILD_DATE="`date --utc '+%F %T'` (UTC)"
356 AC_MSG_RESULT()
357 AC_MSG_RESULT([$PACKAGE_NAME has been configured successfully.])
358 AC_MSG_RESULT()
359 AC_MSG_RESULT([Run 'make' to compile the software and use 'make install' to])
360 AC_MSG_RESULT([install the package into $prefix.])
361 AC_MSG_RESULT()
362 AC_MSG_RESULT([Configuration summary:])
363 AC_MSG_RESULT()
364 AC_MSG_RESULT([ package version: $PACKAGE_VERSION])
365 AC_MSG_RESULT([ build date: $BUILD_DATE])
366 AC_MSG_RESULT()
367 AC_MSG_RESULT([ Tools:])
368 AC_MSG_RESULT([ AsciiDoc (a2x): . . . . . . $have_a2x])
369 AC_MSG_RESULT([ xmlto / xsltproc: . . . . . $have_xmlto / $have_xsltproc])
370 AC_MSG_RESULT()
371 AC_MSG_RESULT([ Features:])
372 AC_MSG_RESULT([ documentation: . . . . . . $build_documentation])
373 AC_MSG_RESULT([ unit testing: . . . . . . . $build_testing])
374 AC_MSG_RESULT([ stdio mocking: . . . . . $have_fopencookie])
375 AC_MSG_RESULT()
376 AC_MSG_RESULT([ Libraries:])
377 AC_MSG_RESULT([ libdbi: . . . . . . . . . . $with_libdbi])
378 AC_MSG_RESULT([ libedit: . . . . . . . . . $have_libedit])
379 AC_MSG_RESULT([ libreadline: . . . . . . . $have_libreadline])
380 AC_MSG_RESULT()
381 AC_MSG_RESULT([ Backends:])
382 AC_MSG_RESULT([ collectd: . . . . . . . . . $enable_collectd])
383 AC_MSG_RESULT([ mk-livestatus: . . . . . . $enable_mk_livestatus])
384 AC_MSG_RESULT([ puppet-storeconfigs: . . . $enable_puppet_storeconfigs])
385 AC_MSG_RESULT()
386 AC_MSG_RESULT([ Plugins:])
387 AC_MSG_RESULT([ cname::dns: . . . . . . . . $enable_cname_dns])
388 AC_MSG_RESULT()
389 AC_MSG_RESULT([This package is maintained by $PACKAGE_MAINTAINER.])
390 AC_MSG_RESULT([Please report bugs to $PACKAGE_BUGREPORT.])
391 AC_MSG_RESULT()
393 dnl vim: set tw=78 sw=4 ts=4 noexpandtab :