[Check]: Disable the document to correct build error.
[platform/upstream/check.git] / 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.14.0], [check-devel at lists dot sourceforge dot net])
8 CHECK_MAJOR_VERSION=0
9 CHECK_MINOR_VERSION=14
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 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 ])
83
84 AM_CONDITIONAL(NO_TIMEOUT_TESTS, test x"$enable_timeout_tests" = "xfalse")
85
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
90   yes)
91     enable_subunit=true
92     echo "Enabled subunit support"
93     ;;
94   no)
95     enable_subunit=false
96     echo "Disabled subunit support"
97     ;;
98   autodetect)
99     echo "Subunit support will enable automatically."
100     ;;
101   *)   AC_MSG_ERROR(bad value ${enableval} for --enable-subunit) ;;
102 esac], 
103 [echo "Subunit support will enable automatically."
104  enable_subunit=autodetect])
105
106 AC_ARG_ENABLE(fork,
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 ])
114
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 ])
122
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 ])
130
131
132 # Checks for programs.
133 AC_PROG_SED
134 AC_PROG_AWK
135 AC_PROG_CC
136 # Automake wants this for per-target CFLAGS
137 AM_PROG_CC_C_O
138 AC_PROG_INSTALL
139 AC_PROG_LN_S
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])
143 AC_PROG_LIBTOOL
144
145 # initialize libtool to build .la files
146 LT_INIT
147
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
170 case "${host_os}" in
171     *aix*)
172     if ! test "$GCC" = "yes"; then
173         AX_CFLAGS_ADD([-qlanglvl=stdc99])
174     fi
175     ;;
176     *)
177     ;;
178 esac
179
180 AC_CHECK_PROGS(GCOV, gcov, false)
181 AC_CHECK_PROGS(LCOV, lcov, false)
182 AC_CHECK_PROGS(GENHTML, genhtml, false)
183
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
189         # anyway.
190         AC_MSG_WARN(makeinfo not installed: cannot rebuild HTML documentation.)
191     fi
192
193     AM_CONDITIONAL(MAKE_DOCS, [test x"$MAKEINFO" != "xfalse"])
194 else
195    AM_CONDITIONAL(MAKE_DOCS, [false])
196 fi
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
201     # reproducible.
202     AC_MSG_WARN(filterdiff not installed; build will not be reproducible.)
203 fi
204
205 AM_CONDITIONAL(USE_FILTERDIFF, [test x"$FILTERDIFF" = x"filterdiff"])
206
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"])
212
213 # Checks for pthread implementation.
214 ACX_PTHREAD
215 CC="$PTHREAD_CC"
216
217 # Check if floor is in the math library, and if so add -lm to LIBS
218 AC_CHECK_LIB([m], [floor])
219
220 # Check if clock_gettime, timer_create, timer_settime, and timer_delete are available in lib rt, and if so,
221 # add -lrt to LIBS
222 AC_CHECK_LIB([rt], [clock_gettime, timer_create, timer_settime, timer_delete])
223
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
227 # definition.
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")], [
229 #include <time.h>
230 #if defined(HAVE_PTHREAD)
231 #include <pthread.h>
232 #endif /* HAVE_PTHREAD */
233 ])
234
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
238 # definition.
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")], [
240 #include <time.h>
241 #if defined(HAVE_PTHREAD)
242 #include <pthread.h>
243 #endif /* HAVE_PTHREAD */
244 ])
245
246 # Checks for header files.
247 AC_HEADER_STDC
248 AC_HEADER_SYS_WAIT
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)
251
252 AS_IF([test x"$enable_subunit" != "xfalse" && test x"$enable_subunit" != "xtrue"], [
253         PKG_CHECK_EXISTS([libsubunit], [:], [enable_subunit=false])
254         ])
255 AS_IF([test x"$enable_subunit" != "xfalse"], [
256         PKG_CHECK_MODULES([LIBSUBUNIT], [libsubunit])
257         ])
258 if test "xfalse" = x"$enable_subunit"; then
259 ENABLE_SUBUNIT="0"
260 LIBSUBUNIT_PC=""
261 else
262 ENABLE_SUBUNIT="1"
263 LIBSUBUNIT_PC="libsubunit"
264 fi
265 AC_SUBST(ENABLE_SUBUNIT)
266 AC_SUBST([LIBSUBUNIT_PC])
267 AC_DEFINE_UNQUOTED(ENABLE_SUBUNIT, $ENABLE_SUBUNIT, [Subunit protocol result output])
268
269 AM_CONDITIONAL(SUBUNIT, test x"$enable_subunit" != "xfalse")
270
271 # Check for POSIX regular expressions support.
272 AC_CHECK_HEADERS([regex.h], HAVE_REGEX_H=1, HAVE_REGEX_H=0)
273
274 if test "x$HAVE_REGEX_H" = "x1"; then
275     AC_CHECK_FUNCS([regcomp regexec], HAVE_REGEX=1, HAVE_REGEX=0)
276 else
277     HAVE_REGEX=0
278 fi
279 AC_SUBST(HAVE_REGEX)
280 AC_DEFINE_UNQUOTED(HAVE_REGEX, $HAVE_REGEX, "Regular expressions are supported")
281
282 if test "x$HAVE_REGEX" = "x1"; then
283     ENABLE_REGEX="1"
284 else
285     ENABLE_REGEX="0"
286 fi
287 AC_SUBST(ENABLE_REGEX)
288 AC_DEFINE_UNQUOTED(ENABLE_REGEX, $ENABLE_REGEX, "Regular expressions are supported and enabled")
289
290 # Checks for typedefs, structures, and compiler characteristics.
291 AC_C_CONST
292 AC_TYPE_PID_T
293 AC_TYPE_SIZE_T
294 AC_TYPE_INTMAX_T
295 AC_TYPE_UINTMAX_T
296 AC_TYPE_UINT32_T
297 AC_HEADER_TIME
298 AC_STRUCT_TM
299
300 AC_CHECK_SIZEOF(int, 4)
301 AC_CHECK_SIZEOF(short, 2)
302 AC_CHECK_SIZEOF(long, 4)
303
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
308 # definitions.
309 AC_CHECK_TYPE(clockid_t, [], [AC_DEFINE([clockid_t], [int], [clockid_t])], [
310 AC_INCLUDES_DEFAULT
311 #if defined(HAVE_PTHREAD)
312 #include <pthread.h>
313 #endif /* HAVE_PTHREAD */
314 ])
315 AC_CHECK_TYPE(timer_t, [], [AC_DEFINE([timer_t], [int], [timer_t])], [
316 AC_INCLUDES_DEFAULT
317 #if defined(HAVE_PTHREAD)
318 #include <pthread.h>
319 #endif /* HAVE_PTHREAD */
320 ])
321
322 # Checks for library functions.
323 AC_FUNC_MALLOC
324 AC_FUNC_REALLOC
325
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.
329 HW_LIBRT_TIMERS
330
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])
334
335 # The following checks are to only detect if the functions exist, but
336 # not replace them
337 AC_CHECK_DECLS([setenv])
338
339 AC_CHECK_FUNCS([setitimer])
340
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)
344 else
345         HAVE_FORK=0
346 fi
347 AC_SUBST(HAVE_FORK)
348 AC_CHECK_FUNCS([sigaction])
349 AC_CHECK_FUNCS([mkstemp])
350
351 # Check if the system's snprintf (and its variations) are C99 compliant.
352 # If they are not, use the version in libcompat.
353 HW_FUNC_VSNPRINTF
354 HW_FUNC_SNPRINTF
355
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*'])
360
361 # Certain awk implementations disagree with each other on how to
362 # substitute doubled backslashes in gsub()
363 AC_SUBST(AWK_GSUB_DBL_BSLASH, '\\\\')
364
365 AS_IF([test "x$AWK_PATH" = 'x*NO AWK*'],
366       [AC_MSG_WARN([Couldn't find a usable awk; won't install checkmk.])],
367
368       # Determine correct number of backslashes for gsub's replacement
369       # value.
370       [AS_IF([echo '\' |
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])])
375
376 # Output files
377 AC_CONFIG_HEADERS([config.h])
378
379 AC_CONFIG_FILES([check.pc
380                  Makefile
381                  checkmk/Makefile
382                  doc/Makefile
383                  lib/Makefile
384                  src/check.h
385                  src/Makefile
386                  tests/Makefile
387                  tests/test_vars])
388
389 AC_OUTPUT
390
391 # Finally, print a summary of the Check's compile options
392
393 echo
394 echo "=========================================="
395 echo "Summary of Check $CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION options:"
396 echo
397
398 if test "x0" = x"$HAVE_FORK"; then
399     result="no"
400 else
401     result="yes"
402 fi
403 echo "fork mode ............................ $result"
404
405 case "$hw_cv_librt_timers_posix" in
406     "yes")
407         result="no"
408         ;;
409     "no")
410         result="yes"
411         ;;
412     *)
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
416             result="yes"
417         else
418             result="no"
419         fi
420         ;;
421 esac
422 echo "high resolution timer replacement .... $result"
423
424 if test "xno" = x"$hw_cv_func_snprintf_c99"; then
425     result="yes"
426 else
427     result="no"
428 fi
429 echo "snprintf replacement ................. $result"
430
431 if test "xfalse" = x"$enable_subunit"; then
432     result="no"
433 else
434     result="yes"
435 fi
436 echo "subunit support....................... $result"
437
438 if test "xtrue" = x"$enable_timeout_tests"; then
439     result="yes"
440 else
441     result="no"
442 fi
443 echo "timeout unit tests ................... $result"
444
445 if test "x0" = x"$ENABLE_REGEX"; then
446     result="no"
447 else
448     result="yes"
449 fi
450 echo "POSIX regular expressions ............ $result"
451
452 if test "xtrue" = x"$enable_build_docs"; then
453     result="yes"
454 else
455     result="no"
456 fi
457 echo "build docs ........................... $result"
458
459 echo "=========================================="