]> granicus.if.org Git - check/blob - configure.ac
Add issue #196 to NEWS
[check] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 # Prelude.
5 AC_PREREQ([2.59])
6
7 AC_INIT([Check], [0.13.0], [check-devel at lists dot sourceforge dot net])
8 CHECK_MAJOR_VERSION=0
9 CHECK_MINOR_VERSION=13
10 CHECK_MICRO_VERSION=0
11 CHECK_VERSION=$CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION
12
13 # unique source file --- primitive safety check 
14 AC_CONFIG_SRCDIR([src/check.c])
15
16 # place where extra autoconf macros are kept
17 AC_CONFIG_MACRO_DIR([m4])
18
19 # place where portability library functions are kept
20 AC_CONFIG_LIBOBJ_DIR([lib])
21
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])
26
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
30
31 AC_SUBST(CHECK_MAJOR_VERSION)
32 AC_SUBST(CHECK_MINOR_VERSION)
33 AC_SUBST(CHECK_MICRO_VERSION)
34 AC_SUBST(CHECK_VERSION)
35
36 # Configure options.
37 # allow `./configure --enable-silent-rules' and `make V=0'
38 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
39
40 AC_ARG_ENABLE(gcov,
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 ])
48
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])
52   fi
53
54   GCOV_CFLAGS="-fprofile-arcs -ftest-coverage"
55   AC_SUBST(GCOV_CFLAGS)
56
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
60   GCOV_LIBS=-lgcov
61   AC_SUBST(GCOV_LIBS)
62 fi
63
64 AM_CONDITIONAL(ENABLE_GCOV, test x"$enable_gcov" = "xtrue")
65
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 ])
74
75 AM_CONDITIONAL(NO_TIMEOUT_TESTS, test x"$enable_timeout_tests" = "xfalse")
76
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
81   yes)
82     enable_subunit=true
83     echo "Enabled subunit support"
84     ;;
85   no)
86     enable_subunit=false
87     echo "Disabled subunit support"
88     ;;
89   autodetect)
90     echo "Subunit support will enable automatically."
91     ;;
92   *)   AC_MSG_ERROR(bad value ${enableval} for --enable-subunit) ;;
93 esac], 
94 [echo "Subunit support will enable automatically."
95  enable_subunit=autodetect])
96
97 AC_ARG_ENABLE(fork,
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 ])
105
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 ])
113
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 ])
121
122
123 # Checks for programs.
124 AC_PROG_SED
125 AC_PROG_AWK
126 AC_PROG_CC
127 # Automake wants this for per-target CFLAGS
128 AM_PROG_CC_C_O
129 AC_PROG_INSTALL
130 AC_PROG_LN_S
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])
134 AC_PROG_LIBTOOL
135
136 # initialize libtool to build .la files
137 LT_INIT
138
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
161 case "${host_os}" in
162     *aix*)
163     if ! test "$GCC" = "yes"; then
164         AX_CFLAGS_ADD([-qlanglvl=stdc99])
165     fi
166     ;;
167     *)
168     ;;
169 esac
170
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
178     # anyway.
179     AC_MSG_WARN(tex not installed: cannot rebuild HTML documentation.)
180 fi
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
185     # reproducible.
186     AC_MSG_WARN(filterdiff not installed; build will not be reproducible.)
187 fi
188
189 AM_CONDITIONAL(USE_FILTERDIFF, [test x"$FILTERDIFF" = x"filterdiff"])
190
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"])
196
197 # Checks for pthread implementation.
198 ACX_PTHREAD
199 CC="$PTHREAD_CC"
200
201 # Check if floor is in the math library, and if so add -lm to LIBS
202 AC_CHECK_LIB([m], [floor])
203
204 # Check if clock_gettime, timer_create, timer_settime, and timer_delete are available in lib rt, and if so,
205 # add -lrt to LIBS
206 AC_CHECK_LIB([rt], [clock_gettime, timer_create, timer_settime, timer_delete])
207
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
211 # definition.
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")], [
213 #include <time.h>
214 #if defined(HAVE_PTHREAD)
215 #include <pthread.h>
216 #endif /* HAVE_PTHREAD */
217 ])
218
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
222 # definition.
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")], [
224 #include <time.h>
225 #if defined(HAVE_PTHREAD)
226 #include <pthread.h>
227 #endif /* HAVE_PTHREAD */
228 ])
229
230 # Checks for header files.
231 AC_HEADER_STDC
232 AC_HEADER_SYS_WAIT
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)
235
236 AS_IF([test x"$enable_subunit" != "xfalse" && test x"$enable_subunit" != "xtrue"], [
237         PKG_CHECK_EXISTS([libsubunit], [:], [enable_subunit=false])
238         ])
239 AS_IF([test x"$enable_subunit" != "xfalse"], [
240         PKG_CHECK_MODULES([LIBSUBUNIT], [libsubunit])
241         ])
242 if test "xfalse" = x"$enable_subunit"; then
243 ENABLE_SUBUNIT="0"
244 LIBSUBUNIT_PC=""
245 else
246 ENABLE_SUBUNIT="1"
247 LIBSUBUNIT_PC="libsubunit"
248 fi
249 AC_SUBST(ENABLE_SUBUNIT)
250 AC_SUBST([LIBSUBUNIT_PC])
251 AC_DEFINE_UNQUOTED(ENABLE_SUBUNIT, $ENABLE_SUBUNIT, [Subunit protocol result output])
252
253 AM_CONDITIONAL(SUBUNIT, test x"$enable_subunit" != "xfalse")
254
255 # Check for POSIX regular expressions support.
256 AC_CHECK_HEADERS([regex.h], HAVE_REGEX_H=1, HAVE_REGEX_H=0)
257
258 if test "x$HAVE_REGEX_H" = "x1"; then
259     AC_CHECK_FUNCS([regcomp regexec], HAVE_REGEX=1, HAVE_REGEX=0)
260 else
261     HAVE_REGEX=0
262 fi
263 AC_SUBST(HAVE_REGEX)
264 AC_DEFINE_UNQUOTED(HAVE_REGEX, $HAVE_REGEX, "Regular expressions are supported")
265
266 if test "x$HAVE_REGEX" = "x1"; then
267     ENABLE_REGEX="1"
268 else
269     ENABLE_REGEX="0"
270 fi
271 AC_SUBST(ENABLE_REGEX)
272 AC_DEFINE_UNQUOTED(ENABLE_REGEX, $ENABLE_REGEX, "Regular expressions are supported and enabled")
273
274 # Checks for typedefs, structures, and compiler characteristics.
275 AC_C_CONST
276 AC_TYPE_PID_T
277 AC_TYPE_SIZE_T
278 AC_TYPE_INTMAX_T
279 AC_TYPE_UINTMAX_T
280 AC_TYPE_UINT32_T
281 AC_HEADER_TIME
282 AC_STRUCT_TM
283
284 AC_CHECK_SIZEOF(int, 4)
285 AC_CHECK_SIZEOF(short, 2)
286 AC_CHECK_SIZEOF(long, 4)
287
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
292 # definitions.
293 AC_CHECK_TYPE(clockid_t, [], [AC_DEFINE([clockid_t], [int], [clockid_t])], [
294 AC_INCLUDES_DEFAULT
295 #if defined(HAVE_PTHREAD)
296 #include <pthread.h>
297 #endif /* HAVE_PTHREAD */
298 ])
299 AC_CHECK_TYPE(timer_t, [], [AC_DEFINE([timer_t], [int], [timer_t])], [
300 AC_INCLUDES_DEFAULT
301 #if defined(HAVE_PTHREAD)
302 #include <pthread.h>
303 #endif /* HAVE_PTHREAD */
304 ])
305
306 # Checks for library functions.
307 AC_FUNC_MALLOC
308 AC_FUNC_REALLOC
309
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.
313 HW_LIBRT_TIMERS
314
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])
318
319 # The following checks are to only detect if the functions exist, but
320 # not replace them
321 AC_CHECK_DECLS([setenv])
322
323 AC_CHECK_FUNCS([setitimer])
324
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)
328 else
329         HAVE_FORK=0
330 fi
331 AC_SUBST(HAVE_FORK)
332 AC_CHECK_FUNCS([sigaction])
333 AC_CHECK_FUNCS([mkstemp])
334
335 # Check if the system's snprintf (and its variations) are C99 compliant.
336 # If they are not, use the version in libcompat.
337 HW_FUNC_VSNPRINTF
338 HW_FUNC_SNPRINTF
339
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*'])
344
345 # Certain awk implementations disagree with each other on how to
346 # substitute doubled backslashes in gsub()
347 AC_SUBST(AWK_GSUB_DBL_BSLASH, '\\\\')
348
349 AS_IF([test "x$AWK_PATH" = 'x*NO AWK*'],
350       [AC_MSG_WARN([Couldn't find a usable awk; won't install checkmk.])],
351
352       # Determine correct number of backslashes for gsub's replacement
353       # value.
354       [AS_IF([echo '\' |
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])])
359
360 # Output files
361 AC_CONFIG_HEADERS([config.h])
362
363 AC_CONFIG_FILES([check.pc
364                  Makefile
365                  checkmk/Makefile
366                  doc/Makefile
367                  lib/Makefile
368                  src/check.h
369                  src/Makefile
370                  tests/Makefile
371                  tests/test_vars])
372
373 AC_OUTPUT
374
375 # Finally, print a summary of the Check's compile options
376
377 echo
378 echo "=========================================="
379 echo "Summary of Check $CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION options:"
380 echo
381
382 if test "x0" = x"$HAVE_FORK"; then
383     result="no"
384 else
385     result="yes"
386 fi
387 echo "fork mode ............................ $result"
388
389 case "$hw_cv_librt_timers_posix" in
390     "yes")
391         result="no"
392         ;;
393     "no")
394         result="yes"
395         ;;
396     *)
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
400             result="yes"
401         else
402             result="no"
403         fi
404         ;;
405 esac
406 echo "high resolution timer replacement .... $result"
407
408 if test "xno" = x"$hw_cv_func_snprintf_c99"; then
409     result="yes"
410 else
411     result="no"
412 fi
413 echo "snprintf replacement ................. $result"
414
415 if test "xfalse" = x"$enable_subunit"; then
416     result="no"
417 else
418     result="yes"
419 fi
420 echo "subunit support....................... $result"
421
422 if test "xtrue" = x"$enable_timeout_tests"; then
423     result="yes"
424 else
425     result="no"
426 fi
427 echo "timeout unit tests ................... $result"
428
429 if test "x0" = x"$ENABLE_REGEX"; then
430     result="no"
431 else
432     result="yes"
433 fi
434 echo "POSIX regular expressions ............ $result"
435
436 echo "=========================================="