2 # Process this file with autoconf to produce a configure script.
7 AC_INIT([Check], [0.14.0], [check-devel at lists dot sourceforge dot net])
11 CHECK_VERSION=$CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION
13 # unique source file --- primitive safety check
14 AC_CONFIG_SRCDIR([src/check.c])
16 # place where extra autoconf macros are kept
17 AC_CONFIG_MACRO_DIR([m4])
19 # place where portability library functions are kept
20 AC_CONFIG_LIBOBJ_DIR([lib])
22 # really severe build strictness
23 AM_INIT_AUTOMAKE([-Wall gnits 1.11.2])
24 # Change to using into-in-builddir in the future:
25 #AM_INIT_AUTOMAKE([info-in-builddir -Wall -Werror gnits 1.14])
27 # define things like _GNU_SOURCE appropriately
28 # From patch 2803433, request system extensions to generate 64-bit safe code
29 AC_USE_SYSTEM_EXTENSIONS
31 AC_SUBST(CHECK_MAJOR_VERSION)
32 AC_SUBST(CHECK_MINOR_VERSION)
33 AC_SUBST(CHECK_MICRO_VERSION)
34 AC_SUBST(CHECK_VERSION)
37 # allow `./configure --enable-silent-rules' and `make V=0'
38 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
41 AC_HELP_STRING([--enable-gcov],
42 [turn on test coverage @<:@default=no@:>@]),
43 [case "${enableval}" in
44 yes) enable_gcov=true ;;
45 no) enable_gcov=false ;;
46 *) AC_MSG_ERROR(bad value ${enableval} for --enable-gcov) ;;
47 esac], [enable_gcov=false ])
49 if test x$enable_gcov = xtrue ; then
50 if test x"$GCC" != xyes; then
51 AC_MSG_ERROR([gcov only works if gcc is used])
54 GCOV_CFLAGS="-fprofile-arcs -ftest-coverage"
57 dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
58 dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
59 dnl links in -lgcov, so we do it explicitly here for the same effect
64 AM_CONDITIONAL(ENABLE_GCOV, test x"$enable_gcov" = "xtrue")
66 AC_ARG_ENABLE(timeout-tests,
67 AC_HELP_STRING([--enable-timeout-tests],
68 [turn on timeout tests @<:@default=yes@:>@]),
69 [case "${enableval}" in
70 yes) enable_timeout_tests=true ;;
71 no) enable_timeout_tests=false ;;
72 *) AC_MSG_ERROR(bad value ${enableval} for --enable-timeout-tests) ;;
73 esac], [enable_timeout_tests=true ])
75 AC_ARG_ENABLE(build-docs,
76 AC_HELP_STRING([--enable-build-docs],
77 [turn on building documentation @<:@default=yes@:>@]),
78 [case "${enableval}" in
79 yes) enable_build_docs=true ;;
80 no) enable_build_docs=false ;;
81 *) AC_MSG_ERROR(bad value ${enableval} for --enable-build-docs) ;;
82 esac], [enable_build_docs=true ])
84 AM_CONDITIONAL(NO_TIMEOUT_TESTS, test x"$enable_timeout_tests" = "xfalse")
86 AC_ARG_ENABLE(subunit,
87 AC_HELP_STRING([--enable-subunit],
88 [enable support for the subunit test protocol @<:@default=autodetect@:>@]),
89 [case "${enableval}" in
92 echo "Enabled subunit support"
96 echo "Disabled subunit support"
99 echo "Subunit support will enable automatically."
101 *) AC_MSG_ERROR(bad value ${enableval} for --enable-subunit) ;;
103 [echo "Subunit support will enable automatically."
104 enable_subunit=autodetect])
107 AC_HELP_STRING([--enable-fork],
108 [enable support for fork @<:@default=autodetect@:>@]),
109 [case "${enableval}" in
110 yes) enable_fork=true ;;
111 no) enable_fork=false ;;
112 *) AC_MSG_ERROR(bad value ${enableval} for --enable-fork) ;;
113 esac], [enable_fork=true ])
115 AC_ARG_ENABLE(snprintf-replacement,
116 AC_HELP_STRING([--enable-snprintf-replacement],
117 [enable check snprintf replacement, (even if the system provides a C99 compliant version) @<:@default=autodetect@:>@]),
118 [case "${enableval}" in
119 yes) enable_snprintf_replacement=true ;;
120 *) AC_MSG_ERROR(bad value ${enableval} for --enable-snprintf-replacement) ;;
121 esac], [enable_snprintf_replacement=autodetect ])
123 AC_ARG_ENABLE(timer-replacement,
124 AC_HELP_STRING([--enable-timer-replacement],
125 [enable check timer replacement, (even if the system provides timer_create, timer_settime, and timer_delete) @<:@default=autodetect@:>@]),
126 [case "${enableval}" in
127 yes) enable_timer_replacement=true ;;
128 *) AC_MSG_ERROR(bad value ${enableval} for --enable-timer-replacement) ;;
129 esac], [enable_timer_replacement=autodetect ])
132 # Checks for programs.
136 # Automake wants this for per-target CFLAGS
140 # for non-POSIX archivers like the one on OS X
141 # use m4_ifdef to work on older automake (1.11)
142 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
145 # initialize libtool to build .la files
148 # add these options to CFLAGS if the compiler supports them
149 AC_DEFUN([AX_CFLAGS_ADD],[AX_C_CHECK_FLAG($1, , , CFLAGS="$CFLAGS $1")])
150 # Do not use the -ansi flag, currently there is a bug in MinGW/MinGW-w64
151 # which prevents Check from compiling. Add after this is resolved:
152 # sourceforge.net/p/mingw/bugs/2024
153 #AX_CFLAGS_WARN_ALL_ANSI
154 # Do not use the -pedantic flag, as on solaris it has a different
155 # meaning than on gcc. Using the flag causes the build to fail.
156 AX_CFLAGS_ADD([-Wextra])
157 AX_CFLAGS_ADD([-Wstrict-prototypes])
158 AX_CFLAGS_ADD([-Wmissing-prototypes])
159 AX_CFLAGS_ADD([-Wwrite-strings])
160 AX_CFLAGS_ADD([-Wno-variadic-macros])
161 AX_CFLAGS_ADD([-Wimport])
162 AX_CFLAGS_ADD([-Wfatal-errors])
163 AX_CFLAGS_ADD([-Wformat=2])
164 AX_CFLAGS_ADD([-Winit-self])
165 AX_CFLAGS_ADD([-Wmissing-include-dirs])
166 AX_CFLAGS_ADD([-Wswitch-default])
167 AX_CFLAGS_ADD([-Wunknown-pragmas])
168 # The following flag is to enable C99 support on AIX, which is
169 # necessary for variable macros in check.h
172 if ! test "$GCC" = "yes"; then
173 AX_CFLAGS_ADD([-qlanglvl=stdc99])
180 AC_CHECK_PROGS(GCOV, gcov, false)
181 AC_CHECK_PROGS(LCOV, lcov, false)
182 AC_CHECK_PROGS(GENHTML, genhtml, false)
184 if test "xtrue" = x"$enable_build_docs"; then
185 AC_CHECK_PROGS(MAKEINFO, makeinfo, false)
186 if test "$MAKEINFO" = "false"; then
187 # Make it [somewhat] clear to maintainers that makeinfo is missing. Not an error
188 # though because 'make install' (which users need) does not build the docs
190 AC_MSG_WARN(makeinfo not installed: cannot rebuild HTML documentation.)
193 AM_CONDITIONAL(MAKE_DOCS, [test x"$MAKEINFO" != "xfalse"])
195 AM_CONDITIONAL(MAKE_DOCS, [false])
197 AC_CHECK_PROGS(FILTERDIFF, filterdiff, false)
198 if test "$FILTERDIFF" = "false"; then
199 # Make it [somewhat] clear to maintainers that filterdiff is missing.
200 # This is not an error, but will prevent builds from being
202 AC_MSG_WARN(filterdiff not installed; build will not be reproducible.)
205 AM_CONDITIONAL(USE_FILTERDIFF, [test x"$FILTERDIFF" = x"filterdiff"])
207 AC_CHECK_PROGS(GRAPHVIZ, dot, false)
208 # If graphviz doesn't exist 'make doc/doxygen-devel' will skip rendering graphs
209 # and inform the developer about it. This target is optional and it aims
210 # developers of libcheck, not users.
211 AM_CONDITIONAL(USE_GRAPHVIZ, [test x"$GRAPHVIZ" = x"dot"])
213 # Checks for pthread implementation.
217 # Check if floor is in the math library, and if so add -lm to LIBS
218 AC_CHECK_LIB([m], [floor])
220 # Check if clock_gettime, timer_create, timer_settime, and timer_delete are available in lib rt, and if so,
222 AC_CHECK_LIB([rt], [clock_gettime, timer_create, timer_settime, timer_delete])
224 # check that struct timespec is defined in time.h. If not, we need to
225 # define it in libcompat.h. Note the optional inclusion of pthread.h.
226 # On MinGW and MinGW-w64, the pthread.h file contains the timespec
228 AC_CHECK_MEMBERS([struct timespec.tv_sec, struct timespec.tv_nsec], [], [AC_DEFINE_UNQUOTED(STRUCT_TIMESPEC_DEFINITION_MISSING, 1, "Need to define the timespec structure")], [
230 #if defined(HAVE_PTHREAD)
232 #endif /* HAVE_PTHREAD */
235 # check that struct itimerspec is defined in time.h. If not, we need to
236 # define it in libcompat.h. Note the optional inclusion of pthread.h.
237 # On MinGW and MinGW-w64, the pthread.h file contains the itimerspec
239 AC_CHECK_MEMBERS([struct itimerspec.it_interval, struct itimerspec.it_value], [], [AC_DEFINE_UNQUOTED(STRUCT_ITIMERSPEC_DEFINITION_MISSING, 1, "Need to define the itimerspec structure")], [
241 #if defined(HAVE_PTHREAD)
243 #endif /* HAVE_PTHREAD */
246 # Checks for header files.
249 AC_CHECK_HEADERS([fcntl.h stddef.h stdlib.h string.h sys/time.h unistd.h])
250 AX_CREATE_STDINT_H(check_stdint.h)
252 AS_IF([test x"$enable_subunit" != "xfalse" && test x"$enable_subunit" != "xtrue"], [
253 PKG_CHECK_EXISTS([libsubunit], [:], [enable_subunit=false])
255 AS_IF([test x"$enable_subunit" != "xfalse"], [
256 PKG_CHECK_MODULES([LIBSUBUNIT], [libsubunit])
258 if test "xfalse" = x"$enable_subunit"; then
263 LIBSUBUNIT_PC="libsubunit"
265 AC_SUBST(ENABLE_SUBUNIT)
266 AC_SUBST([LIBSUBUNIT_PC])
267 AC_DEFINE_UNQUOTED(ENABLE_SUBUNIT, $ENABLE_SUBUNIT, [Subunit protocol result output])
269 AM_CONDITIONAL(SUBUNIT, test x"$enable_subunit" != "xfalse")
271 # Check for POSIX regular expressions support.
272 AC_CHECK_HEADERS([regex.h], HAVE_REGEX_H=1, HAVE_REGEX_H=0)
274 if test "x$HAVE_REGEX_H" = "x1"; then
275 AC_CHECK_FUNCS([regcomp regexec], HAVE_REGEX=1, HAVE_REGEX=0)
280 AC_DEFINE_UNQUOTED(HAVE_REGEX, $HAVE_REGEX, "Regular expressions are supported")
282 if test "x$HAVE_REGEX" = "x1"; then
287 AC_SUBST(ENABLE_REGEX)
288 AC_DEFINE_UNQUOTED(ENABLE_REGEX, $ENABLE_REGEX, "Regular expressions are supported and enabled")
290 # Checks for typedefs, structures, and compiler characteristics.
300 AC_CHECK_SIZEOF(int, 4)
301 AC_CHECK_SIZEOF(short, 2)
302 AC_CHECK_SIZEOF(long, 4)
304 # The following two checks will attempt to include pthread.h. The
305 # reason is MinGW and MinGW-w64 have been known to put the time
306 # related definitions in the pthread headers. Without include
307 # pthread.h, these checks may mistakenly fail to find the
309 AC_CHECK_TYPE(clockid_t, [], [AC_DEFINE([clockid_t], [int], [clockid_t])], [
311 #if defined(HAVE_PTHREAD)
313 #endif /* HAVE_PTHREAD */
315 AC_CHECK_TYPE(timer_t, [], [AC_DEFINE([timer_t], [int], [timer_t])], [
317 #if defined(HAVE_PTHREAD)
319 #endif /* HAVE_PTHREAD */
322 # Checks for library functions.
326 # Check if the timer_create(), timer_settime(), and timer_delete()
327 # functions on the system are available and suitable, or need to be
328 # replaced with Check's replacement of these functions.
331 # The following checks will replace missing functions from libcompat
332 AC_REPLACE_FUNCS([alarm clock_gettime getline gettimeofday localtime_r strdup strsignal])
333 AC_CHECK_DECLS([alarm, clock_gettime, getline, gettimeofday, localtime_r, strdup, strsignal])
335 # The following checks are to only detect if the functions exist, but
337 AC_CHECK_DECLS([setenv])
339 AC_CHECK_FUNCS([setitimer])
341 # Checks for functions not available in Windows
342 if test "xtrue" = x"$enable_fork"; then
343 AC_CHECK_FUNCS([fork], HAVE_FORK=1, HAVE_FORK=0)
348 AC_CHECK_FUNCS([sigaction])
349 AC_CHECK_FUNCS([mkstemp])
351 # Check if the system's snprintf (and its variations) are C99 compliant.
352 # If they are not, use the version in libcompat.
356 # Check for whether we can install checkmk (we have a usable awk)
357 AC_ARG_VAR([AWK_PATH],[Awk interpreter command])
358 AC_PATH_PROG(AWK_PATH, $AWK, [*NO AWK*])
359 AM_CONDITIONAL([INSTALL_CHECKMK], [test "x$AWK_PATH" != 'x*NO AWK*'])
361 # Certain awk implementations disagree with each other on how to
362 # substitute doubled backslashes in gsub()
363 AC_SUBST(AWK_GSUB_DBL_BSLASH, '\\\\')
365 AS_IF([test "x$AWK_PATH" = 'x*NO AWK*'],
366 [AC_MSG_WARN([Couldn't find a usable awk; won't install checkmk.])],
368 # Determine correct number of backslashes for gsub's replacement
371 "$AWK_PATH" '{ gsub("\\\\", "\\\\", $0); print }' |
372 grep '^\\$' >/dev/null 2>&1], AWK_GSUB_DBL_BSLASH='\\\\\\\\')
373 AC_CONFIG_FILES(checkmk/checkmk)
374 AC_CONFIG_COMMANDS([checkmk-x], [chmod +x checkmk/checkmk])])
377 AC_CONFIG_HEADERS([config.h])
379 AC_CONFIG_FILES([check.pc
391 # Finally, print a summary of the Check's compile options
394 echo "=========================================="
395 echo "Summary of Check $CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION options:"
398 if test "x0" = x"$HAVE_FORK"; then
403 echo "fork mode ............................ $result"
405 case "$hw_cv_librt_timers_posix" in
413 # The AC_REPLACE_FUNCS macro was invoked,
414 # meaning we are cross compiling.
415 if test "xno" = x"$ac_cv_func_timer_create"; then
422 echo "high resolution timer replacement .... $result"
424 if test "xno" = x"$hw_cv_func_snprintf_c99"; then
429 echo "snprintf replacement ................. $result"
431 if test "xfalse" = x"$enable_subunit"; then
436 echo "subunit support....................... $result"
438 if test "xtrue" = x"$enable_timeout_tests"; then
443 echo "timeout unit tests ................... $result"
445 if test "x0" = x"$ENABLE_REGEX"; then
450 echo "POSIX regular expressions ............ $result"
452 if test "xtrue" = x"$enable_build_docs"; then
457 echo "build docs ........................... $result"
459 echo "=========================================="