2 # Process this file with autoconf to produce a configure script.
7 AC_INIT([Check], [0.13.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 AM_CONDITIONAL(NO_TIMEOUT_TESTS, test x"$enable_timeout_tests" = "xfalse")
77 AC_ARG_ENABLE(subunit,
78 AC_HELP_STRING([--enable-subunit],
79 [enable support for the subunit test protocol @<:@default=autodetect@:>@]),
80 [case "${enableval}" in
83 echo "Enabled subunit support"
87 echo "Disabled subunit support"
90 echo "Subunit support will enable automatically."
92 *) AC_MSG_ERROR(bad value ${enableval} for --enable-subunit) ;;
94 [echo "Subunit support will enable automatically."
95 enable_subunit=autodetect])
98 AC_HELP_STRING([--enable-fork],
99 [enable support for fork @<:@default=autodetect@:>@]),
100 [case "${enableval}" in
101 yes) enable_fork=true ;;
102 no) enable_fork=false ;;
103 *) AC_MSG_ERROR(bad value ${enableval} for --enable-fork) ;;
104 esac], [enable_fork=true ])
106 AC_ARG_ENABLE(snprintf-replacement,
107 AC_HELP_STRING([--enable-snprintf-replacement],
108 [enable check snprintf replacement, (even if the system provides a C99 compliant version) @<:@default=autodetect@:>@]),
109 [case "${enableval}" in
110 yes) enable_snprintf_replacement=true ;;
111 *) AC_MSG_ERROR(bad value ${enableval} for --enable-snprintf-replacement) ;;
112 esac], [enable_snprintf_replacement=autodetect ])
114 AC_ARG_ENABLE(timer-replacement,
115 AC_HELP_STRING([--enable-timer-replacement],
116 [enable check timer replacement, (even if the system provides timer_create, timer_settime, and timer_delete) @<:@default=autodetect@:>@]),
117 [case "${enableval}" in
118 yes) enable_timer_replacement=true ;;
119 *) AC_MSG_ERROR(bad value ${enableval} for --enable-timer-replacement) ;;
120 esac], [enable_timer_replacement=autodetect ])
123 # Checks for programs.
127 # Automake wants this for per-target CFLAGS
131 # for non-POSIX archivers like the one on OS X
132 # use m4_ifdef to work on older automake (1.11)
133 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
136 # initialize libtool to build .la files
139 # add these options to CFLAGS if the compiler supports them
140 AC_DEFUN([AX_CFLAGS_ADD],[AX_C_CHECK_FLAG($1, , , CFLAGS="$CFLAGS $1")])
141 # Do not use the -ansi flag, currently there is a bug in MinGW/MinGW-w64
142 # which prevents Check from compiling. Add after this is resolved:
143 # sourceforge.net/p/mingw/bugs/2024
144 #AX_CFLAGS_WARN_ALL_ANSI
145 # Do not use the -pedantic flag, as on solaris it has a different
146 # meaning than on gcc. Using the flag causes the build to fail.
147 AX_CFLAGS_ADD([-Wextra])
148 AX_CFLAGS_ADD([-Wstrict-prototypes])
149 AX_CFLAGS_ADD([-Wmissing-prototypes])
150 AX_CFLAGS_ADD([-Wwrite-strings])
151 AX_CFLAGS_ADD([-Wno-variadic-macros])
152 AX_CFLAGS_ADD([-Wimport])
153 AX_CFLAGS_ADD([-Wfatal-errors])
154 AX_CFLAGS_ADD([-Wformat=2])
155 AX_CFLAGS_ADD([-Winit-self])
156 AX_CFLAGS_ADD([-Wmissing-include-dirs])
157 AX_CFLAGS_ADD([-Wswitch-default])
158 AX_CFLAGS_ADD([-Wunknown-pragmas])
159 # The following flag is to enable C99 support on AIX, which is
160 # necessary for variable macros in check.h
163 if ! test "$GCC" = "yes"; then
164 AX_CFLAGS_ADD([-qlanglvl=stdc99])
171 AC_CHECK_PROGS(GCOV, gcov, false)
172 AC_CHECK_PROGS(LCOV, lcov, false)
173 AC_CHECK_PROGS(GENHTML, genhtml, false)
174 AC_CHECK_PROGS(TEX, tex, false)
175 if test "$TEX" = "false"; then
176 # Make it [somewhat] clear to maintainers that tex is missing. Not an error
177 # though because 'make install' (which users need) does not build the docs
179 AC_MSG_WARN(tex not installed: cannot rebuild HTML documentation.)
181 AC_CHECK_PROGS(FILTERDIFF, filterdiff, false)
182 if test "$FILTERDIFF" = "false"; then
183 # Make it [somewhat] clear to maintainers that filterdiff is missing.
184 # This is not an error, but will prevent builds from being
186 AC_MSG_WARN(filterdiff not installed; build will not be reproducible.)
189 AM_CONDITIONAL(USE_FILTERDIFF, [test x"$FILTERDIFF" = x"filterdiff"])
191 AC_CHECK_PROGS(GRAPHVIZ, dot, false)
192 # If graphviz doesn't exist 'make doc/doxygen-devel' will skip rendering graphs
193 # and inform the developer about it. This target is optional and it aims
194 # developers of libcheck, not users.
195 AM_CONDITIONAL(USE_GRAPHVIZ, [test x"$GRAPHVIZ" = x"dot"])
197 # Checks for pthread implementation.
201 # Check if floor is in the math library, and if so add -lm to LIBS
202 AC_CHECK_LIB([m], [floor])
204 # Check if clock_gettime, timer_create, timer_settime, and timer_delete are available in lib rt, and if so,
206 AC_CHECK_LIB([rt], [clock_gettime, timer_create, timer_settime, timer_delete])
208 # check that struct timespec is defined in time.h. If not, we need to
209 # define it in libcompat.h. Note the optional inclusion of pthread.h.
210 # On MinGW and MinGW-w64, the pthread.h file contains the timespec
212 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")], [
214 #if defined(HAVE_PTHREAD)
216 #endif /* HAVE_PTHREAD */
219 # check that struct itimerspec is defined in time.h. If not, we need to
220 # define it in libcompat.h. Note the optional inclusion of pthread.h.
221 # On MinGW and MinGW-w64, the pthread.h file contains the itimerspec
223 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")], [
225 #if defined(HAVE_PTHREAD)
227 #endif /* HAVE_PTHREAD */
230 # Checks for header files.
233 AC_CHECK_HEADERS([fcntl.h stddef.h stdlib.h string.h sys/time.h unistd.h])
234 AX_CREATE_STDINT_H(check_stdint.h)
236 AS_IF([test x"$enable_subunit" != "xfalse" && test x"$enable_subunit" != "xtrue"], [
237 PKG_CHECK_EXISTS([libsubunit], [:], [enable_subunit=false])
239 AS_IF([test x"$enable_subunit" != "xfalse"], [
240 PKG_CHECK_MODULES([LIBSUBUNIT], [libsubunit])
242 if test "xfalse" = x"$enable_subunit"; then
247 LIBSUBUNIT_PC="libsubunit"
249 AC_SUBST(ENABLE_SUBUNIT)
250 AC_SUBST([LIBSUBUNIT_PC])
251 AC_DEFINE_UNQUOTED(ENABLE_SUBUNIT, $ENABLE_SUBUNIT, [Subunit protocol result output])
253 AM_CONDITIONAL(SUBUNIT, test x"$enable_subunit" != "xfalse")
255 # Check for POSIX regular expressions support.
256 AC_CHECK_HEADERS([regex.h], HAVE_REGEX_H=1, HAVE_REGEX_H=0)
258 if test "x$HAVE_REGEX_H" = "x1"; then
259 AC_CHECK_FUNCS([regcomp regexec], HAVE_REGEX=1, HAVE_REGEX=0)
264 AC_DEFINE_UNQUOTED(HAVE_REGEX, $HAVE_REGEX, "Regular expressions are supported")
266 if test "x$HAVE_REGEX" = "x1"; then
271 AC_SUBST(ENABLE_REGEX)
272 AC_DEFINE_UNQUOTED(ENABLE_REGEX, $ENABLE_REGEX, "Regular expressions are supported and enabled")
274 # Checks for typedefs, structures, and compiler characteristics.
284 AC_CHECK_SIZEOF(int, 4)
285 AC_CHECK_SIZEOF(short, 2)
286 AC_CHECK_SIZEOF(long, 4)
288 # The following two checks will attempt to include pthread.h. The
289 # reason is MinGW and MinGW-w64 have been known to put the time
290 # related definitions in the pthread headers. Without include
291 # pthread.h, these checks may mistakenly fail to find the
293 AC_CHECK_TYPE(clockid_t, [], [AC_DEFINE([clockid_t], [int], [clockid_t])], [
295 #if defined(HAVE_PTHREAD)
297 #endif /* HAVE_PTHREAD */
299 AC_CHECK_TYPE(timer_t, [], [AC_DEFINE([timer_t], [int], [timer_t])], [
301 #if defined(HAVE_PTHREAD)
303 #endif /* HAVE_PTHREAD */
306 # Checks for library functions.
310 # Check if the timer_create(), timer_settime(), and timer_delete()
311 # functions on the system are available and suitable, or need to be
312 # replaced with Check's replacement of these functions.
315 # The following checks will replace missing functions from libcompat
316 AC_REPLACE_FUNCS([alarm clock_gettime getline gettimeofday localtime_r strdup strsignal])
317 AC_CHECK_DECLS([alarm, clock_gettime, getline, gettimeofday, localtime_r, strdup, strsignal])
319 # The following checks are to only detect if the functions exist, but
321 AC_CHECK_DECLS([setenv])
323 AC_CHECK_FUNCS([setitimer])
325 # Checks for functions not available in Windows
326 if test "xtrue" = x"$enable_fork"; then
327 AC_CHECK_FUNCS([fork], HAVE_FORK=1, HAVE_FORK=0)
332 AC_CHECK_FUNCS([sigaction])
333 AC_CHECK_FUNCS([mkstemp])
335 # Check if the system's snprintf (and its variations) are C99 compliant.
336 # If they are not, use the version in libcompat.
340 # Check for whether we can install checkmk (we have a usable awk)
341 AC_ARG_VAR([AWK_PATH],[Awk interpreter command])
342 AC_PATH_PROG(AWK_PATH, $AWK, [*NO AWK*])
343 AM_CONDITIONAL([INSTALL_CHECKMK], [test "x$AWK_PATH" != 'x*NO AWK*'])
345 # Certain awk implementations disagree with each other on how to
346 # substitute doubled backslashes in gsub()
347 AC_SUBST(AWK_GSUB_DBL_BSLASH, '\\\\')
349 AS_IF([test "x$AWK_PATH" = 'x*NO AWK*'],
350 [AC_MSG_WARN([Couldn't find a usable awk; won't install checkmk.])],
352 # Determine correct number of backslashes for gsub's replacement
355 "$AWK_PATH" '{ gsub("\\\\", "\\\\", $0); print }' |
356 grep '^\\$' >/dev/null 2>&1], AWK_GSUB_DBL_BSLASH='\\\\\\\\')
357 AC_CONFIG_FILES(checkmk/checkmk)
358 AC_CONFIG_COMMANDS([checkmk-x], [chmod +x checkmk/checkmk])])
361 AC_CONFIG_HEADERS([config.h])
363 AC_CONFIG_FILES([check.pc
375 # Finally, print a summary of the Check's compile options
378 echo "=========================================="
379 echo "Summary of Check $CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION options:"
382 if test "x0" = x"$HAVE_FORK"; then
387 echo "fork mode ............................ $result"
389 case "$hw_cv_librt_timers_posix" in
397 # The AC_REPLACE_FUNCS macro was invoked,
398 # meaning we are cross compiling.
399 if test "xno" = x"$ac_cv_func_timer_create"; then
406 echo "high resolution timer replacement .... $result"
408 if test "xno" = x"$hw_cv_func_snprintf_c99"; then
413 echo "snprintf replacement ................. $result"
415 if test "xfalse" = x"$enable_subunit"; then
420 echo "subunit support....................... $result"
422 if test "xtrue" = x"$enable_timeout_tests"; then
427 echo "timeout unit tests ................... $result"
429 if test "x0" = x"$ENABLE_REGEX"; then
434 echo "POSIX regular expressions ............ $result"
436 echo "=========================================="