-
Notifications
You must be signed in to change notification settings - Fork 211
/
configure.ac
481 lines (410 loc) · 14.8 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# Prelude.
AC_PREREQ([2.59])
AC_INIT([Check], [0.15.2], [check-devel at lists dot sourceforge dot net])
CHECK_MAJOR_VERSION=0
CHECK_MINOR_VERSION=15
CHECK_MICRO_VERSION=2
CHECK_VERSION=$CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION
# unique source file --- primitive safety check
AC_CONFIG_SRCDIR([src/check.c])
# place where extra autoconf macros are kept
AC_CONFIG_MACRO_DIR([m4])
# place where portability library functions are kept
AC_CONFIG_LIBOBJ_DIR([lib])
# really severe build strictness
AM_INIT_AUTOMAKE([-Wall gnits 1.11.2])
# Change to using into-in-builddir in the future:
#AM_INIT_AUTOMAKE([info-in-builddir -Wall -Werror gnits 1.14])
# define things like _GNU_SOURCE appropriately
# From patch 2803433, request system extensions to generate 64-bit safe code
AC_USE_SYSTEM_EXTENSIONS
AC_SUBST(CHECK_MAJOR_VERSION)
AC_SUBST(CHECK_MINOR_VERSION)
AC_SUBST(CHECK_MICRO_VERSION)
AC_SUBST(CHECK_VERSION)
# The PROJECT_VERSION variable definition is required for
# compatibility with the CMake configuration interface.
#
AC_SUBST([PROJECT_VERSION], $CHECK_VERSION)
# Configure options.
# allow `./configure --enable-silent-rules' and `make V=0'
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])])
AC_ARG_ENABLE(gcov,
AC_HELP_STRING([--enable-gcov],
[turn on test coverage @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_gcov=true ;;
no) enable_gcov=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-gcov) ;;
esac], [enable_gcov=false ])
if test x$enable_gcov = xtrue ; then
if test x"$GCC" != xyes; then
AC_MSG_ERROR([gcov only works if gcc is used])
fi
GCOV_CFLAGS="-fprofile-arcs -ftest-coverage"
AC_SUBST(GCOV_CFLAGS)
dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
dnl links in -lgcov, so we do it explicitly here for the same effect
GCOV_LIBS=-lgcov
AC_SUBST(GCOV_LIBS)
fi
AM_CONDITIONAL(ENABLE_GCOV, test x"$enable_gcov" = "xtrue")
AC_ARG_ENABLE(timeout-tests,
AC_HELP_STRING([--enable-timeout-tests],
[turn on timeout tests @<:@default=yes@:>@]),
[case "${enableval}" in
yes) enable_timeout_tests=true ;;
no) enable_timeout_tests=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-timeout-tests) ;;
esac], [enable_timeout_tests=true ])
AC_ARG_ENABLE(build-docs,
AC_HELP_STRING([--enable-build-docs],
[turn on building documentation @<:@default=yes@:>@]),
[case "${enableval}" in
yes) enable_build_docs=true ;;
no) enable_build_docs=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-build-docs) ;;
esac], [enable_build_docs=true ])
AM_CONDITIONAL(NO_TIMEOUT_TESTS, test x"$enable_timeout_tests" = "xfalse")
AC_ARG_ENABLE(subunit,
AC_HELP_STRING([--enable-subunit],
[enable support for the subunit test protocol @<:@default=autodetect@:>@]),
[case "${enableval}" in
yes)
enable_subunit=true
echo "Enabled subunit support"
;;
no)
enable_subunit=false
echo "Disabled subunit support"
;;
autodetect)
echo "Subunit support will enable automatically."
;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-subunit) ;;
esac],
[echo "Subunit support will enable automatically."
enable_subunit=autodetect])
AC_ARG_ENABLE(fork,
AC_HELP_STRING([--enable-fork],
[enable support for fork @<:@default=autodetect@:>@]),
[case "${enableval}" in
yes) enable_fork=true ;;
no) enable_fork=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-fork) ;;
esac], [enable_fork=true ])
AC_ARG_ENABLE(snprintf-replacement,
AC_HELP_STRING([--enable-snprintf-replacement],
[enable check snprintf replacement, (even if the system provides a C99 compliant version) @<:@default=autodetect@:>@]),
[case "${enableval}" in
yes) enable_snprintf_replacement=true ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-snprintf-replacement) ;;
esac], [enable_snprintf_replacement=autodetect ])
AC_ARG_ENABLE(timer-replacement,
AC_HELP_STRING([--enable-timer-replacement],
[enable check timer replacement, (even if the system provides timer_create, timer_settime, and timer_delete) @<:@default=autodetect@:>@]),
[case "${enableval}" in
yes) enable_timer_replacement=true ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-timer-replacement) ;;
esac], [enable_timer_replacement=autodetect ])
# Checks for programs.
AC_PROG_SED
AC_PROG_AWK
AC_PROG_CC
# Automake wants this for per-target CFLAGS
AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_LN_S
# for non-POSIX archivers like the one on OS X
# use m4_ifdef to work on older automake (1.11)
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_LIBTOOL
# initialize libtool to build .la files
LT_INIT
# add these options to CFLAGS if the compiler supports them
AC_DEFUN([AX_CFLAGS_ADD],[AX_C_CHECK_FLAG($1, , , CFLAGS="$CFLAGS $1")])
# Do not use the -ansi flag, currently there is a bug in MinGW/MinGW-w64
# which prevents Check from compiling. Add after this is resolved:
# sourceforge.net/p/mingw/bugs/2024
#AX_CFLAGS_WARN_ALL_ANSI
# Do not use the -pedantic flag, as on solaris it has a different
# meaning than on gcc. Using the flag causes the build to fail.
AX_CFLAGS_ADD([-Wextra])
AX_CFLAGS_ADD([-Wstrict-prototypes])
AX_CFLAGS_ADD([-Wmissing-prototypes])
AX_CFLAGS_ADD([-Wwrite-strings])
AX_CFLAGS_ADD([-Wno-variadic-macros])
AX_CFLAGS_ADD([-Wimport])
AX_CFLAGS_ADD([-Wfatal-errors])
AX_CFLAGS_ADD([-Wformat=2])
AX_CFLAGS_ADD([-Winit-self])
AX_CFLAGS_ADD([-Wmissing-include-dirs])
AX_CFLAGS_ADD([-Wswitch-default])
AX_CFLAGS_ADD([-Wunknown-pragmas])
# The following flag is to enable C99 support on AIX, which is
# necessary for variable macros in check.h
case "${host_os}" in
*aix*)
if ! test "$GCC" = "yes"; then
AX_CFLAGS_ADD([-qlanglvl=stdc99])
fi
;;
*)
;;
esac
AC_CHECK_PROGS(GCOV, gcov, false)
AC_CHECK_PROGS(LCOV, lcov, false)
AC_CHECK_PROGS(GENHTML, genhtml, false)
if test "xtrue" = x"$enable_build_docs"; then
AC_CHECK_PROGS(MAKEINFO, makeinfo, false)
if test "$MAKEINFO" = "false"; then
# Make it [somewhat] clear to maintainers that makeinfo is missing. Not an error
# though because 'make install' (which users need) does not build the docs
# anyway.
AC_MSG_WARN(makeinfo not installed: cannot rebuild HTML documentation.)
fi
AM_CONDITIONAL(MAKE_DOCS, [test x"$MAKEINFO" != "xfalse"])
else
AM_CONDITIONAL(MAKE_DOCS, [false])
fi
AC_CHECK_PROGS(FILTERDIFF, filterdiff, false)
if test "$FILTERDIFF" = "false"; then
# Make it [somewhat] clear to maintainers that filterdiff is missing.
# This is not an error, but will prevent builds from being
# reproducible.
AC_MSG_WARN(filterdiff not installed; build will not be reproducible.)
fi
AM_CONDITIONAL(USE_FILTERDIFF, [test x"$FILTERDIFF" = x"filterdiff"])
AC_CHECK_PROGS(GRAPHVIZ, dot, false)
# If graphviz doesn't exist 'make doc/doxygen-devel' will skip rendering graphs
# and inform the developer about it. This target is optional and it aims
# developers of libcheck, not users.
AM_CONDITIONAL(USE_GRAPHVIZ, [test x"$GRAPHVIZ" = x"dot"])
# Checks for pthread implementation.
ACX_PTHREAD
CC="$PTHREAD_CC"
# Check if floor is in the math library, and if so add -lm to LIBS
AC_CHECK_LIB([m], [floor])
# Check if clock_gettime, timer_create, timer_settime, and timer_delete are available in lib rt, and if so,
# add -lrt to LIBS
AC_CHECK_LIB([rt], [clock_gettime, timer_create, timer_settime, timer_delete])
# check that struct timespec is defined in time.h. If not, we need to
# define it in libcompat.h. Note the optional inclusion of pthread.h.
# On MinGW and MinGW-w64, the pthread.h file contains the timespec
# definition.
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")], [
#include <time.h>
#if defined(HAVE_PTHREAD)
#include <pthread.h>
#endif /* HAVE_PTHREAD */
])
# check that struct itimerspec is defined in time.h. If not, we need to
# define it in libcompat.h. Note the optional inclusion of pthread.h.
# On MinGW and MinGW-w64, the pthread.h file contains the itimerspec
# definition.
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")], [
#include <time.h>
#if defined(HAVE_PTHREAD)
#include <pthread.h>
#endif /* HAVE_PTHREAD */
])
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([fcntl.h stddef.h stdlib.h string.h sys/time.h unistd.h])
AX_CREATE_STDINT_H(check_stdint.h)
AS_IF([test x"$enable_subunit" != "xfalse" && test x"$enable_subunit" != "xtrue"], [
PKG_CHECK_EXISTS([libsubunit], [:], [enable_subunit=false])
])
AS_IF([test x"$enable_subunit" != "xfalse"], [
PKG_CHECK_MODULES([LIBSUBUNIT], [libsubunit])
])
if test "xfalse" = x"$enable_subunit"; then
ENABLE_SUBUNIT="0"
LIBSUBUNIT_PC=""
else
ENABLE_SUBUNIT="1"
LIBSUBUNIT_PC="libsubunit"
fi
AC_SUBST(ENABLE_SUBUNIT)
AC_SUBST([LIBSUBUNIT_PC])
AC_DEFINE_UNQUOTED(ENABLE_SUBUNIT, $ENABLE_SUBUNIT, [Subunit protocol result output])
AM_CONDITIONAL(SUBUNIT, test x"$enable_subunit" != "xfalse")
# Check for POSIX regular expressions support.
AC_CHECK_HEADERS([regex.h], HAVE_REGEX_H=1, HAVE_REGEX_H=0)
# Check if we have the windows headers for Init Once API
AC_CHECK_HEADERS([windows.h], HAVE_WINDOWS_H=1, HAVE_WINDOWS_H=0)
AC_SUBST(HAVE_WINDOWS_H)
# Check if we have the One-Time Initialization API
AC_CHECK_FUNCS([InitOnceBeginInitialize], HAVE_INIT_ONCE_BEGIN_INITIALIZE=1, HAVE_INIT_ONCE_BEGIN_INITIALIZE=0)
AC_CHECK_FUNCS([InitOnceComplete], HAVE_INIT_ONCE_COMPLETE=1, HAVE_INIT_ONCE_COMPLETE=0)
AC_SUBST(HAVE_INIT_ONCE_BEGIN_INITIALIZE)
AC_SUBST(HAVE_INIT_ONCE_COMPLETE)
if test "x$HAVE_REGEX_H" = "x1"; then
AC_CHECK_FUNCS([regcomp regexec], HAVE_REGEX=1, HAVE_REGEX=0)
else
HAVE_REGEX=0
fi
AC_SUBST(HAVE_REGEX)
AC_DEFINE_UNQUOTED(HAVE_REGEX, $HAVE_REGEX, "Regular expressions are supported")
if test "x$HAVE_REGEX" = "x1"; then
ENABLE_REGEX="1"
else
ENABLE_REGEX="0"
fi
AC_SUBST(ENABLE_REGEX)
AC_DEFINE_UNQUOTED(ENABLE_REGEX, $ENABLE_REGEX, "Regular expressions are supported and enabled")
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_INTMAX_T
AC_TYPE_UINTMAX_T
AC_TYPE_UINT32_T
AC_HEADER_TIME
AC_STRUCT_TM
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long, 4)
# The following two checks will attempt to include pthread.h. The
# reason is MinGW and MinGW-w64 have been known to put the time
# related definitions in the pthread headers. Without include
# pthread.h, these checks may mistakenly fail to find the
# definitions.
AC_CHECK_TYPE(clockid_t, [], [AC_DEFINE([clockid_t], [int], [clockid_t])], [
AC_INCLUDES_DEFAULT
#if defined(HAVE_PTHREAD)
#include <pthread.h>
#endif /* HAVE_PTHREAD */
])
AC_CHECK_TYPE(timer_t, [], [AC_DEFINE([timer_t], [int], [timer_t])], [
AC_INCLUDES_DEFAULT
#if defined(HAVE_PTHREAD)
#include <pthread.h>
#endif /* HAVE_PTHREAD */
])
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
# Check if the timer_create(), timer_settime(), and timer_delete()
# functions on the system are available and suitable, or need to be
# replaced with Check's replacement of these functions.
HW_LIBRT_TIMERS
# The following checks will replace missing functions from libcompat
AC_REPLACE_FUNCS([alarm clock_gettime getline gettimeofday localtime_r strdup strsignal])
AC_CHECK_DECLS([alarm, clock_gettime, getline, gettimeofday, localtime_r, strdup, strsignal])
# The following checks are to only detect if the functions exist, but
# not replace them
AC_CHECK_DECLS([setenv])
AC_CHECK_FUNCS([setitimer])
# Checks for functions not available in Windows
if test "xtrue" = x"$enable_fork"; then
AC_CHECK_FUNCS([fork], HAVE_FORK=1, HAVE_FORK=0)
else
HAVE_FORK=0
fi
AC_SUBST(HAVE_FORK)
AC_CHECK_FUNCS([sigaction])
AC_CHECK_FUNCS([mkstemp])
# Check if the system's snprintf (and its variations) are C99 compliant.
# If they are not, use the version in libcompat.
HW_FUNC_VSNPRINTF
HW_FUNC_SNPRINTF
# Check for whether we can install checkmk (we have a usable awk)
AC_ARG_VAR([AWK_PATH],[Awk interpreter command])
AC_PATH_PROG(AWK_PATH, $AWK, [*NO AWK*])
AM_CONDITIONAL([INSTALL_CHECKMK], [test "x$AWK_PATH" != 'x*NO AWK*'])
# Certain awk implementations disagree with each other on how to
# substitute doubled backslashes in gsub()
AC_SUBST(AWK_GSUB_DBL_BSLASH, '\\\\')
AS_IF([test "x$AWK_PATH" = 'x*NO AWK*'],
[AC_MSG_WARN([Couldn't find a usable awk; won't install checkmk.])],
# Determine correct number of backslashes for gsub's replacement
# value.
[AS_IF([echo '\' |
"$AWK_PATH" '{ gsub("\\\\", "\\\\", $0); print }' |
grep '^\\$' >/dev/null 2>&1], AWK_GSUB_DBL_BSLASH='\\\\\\\\')
AC_CONFIG_FILES(checkmk/checkmk)
AC_CONFIG_COMMANDS([checkmk-x], [chmod +x checkmk/checkmk])])
# Output files
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
check.pc
Makefile
checkmk/Makefile
doc/Makefile
doc/man/Makefile
doc/man/man3/Makefile
doc/man/man3/suite_create.3
doc/man/man7/Makefile
doc/man/man7/libcheck.7
lib/Makefile
src/check.h
src/Makefile
tests/Makefile
tests/test_vars
])
AC_OUTPUT
# Finally, print a summary of the Check's compile options
echo
echo "=========================================="
echo "Summary of Check $CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION options:"
echo
if test "x0" = x"$HAVE_FORK"; then
result="no"
else
result="yes"
fi
echo "fork mode ............................ $result"
case "$hw_cv_librt_timers_posix" in
"yes")
result="no"
;;
"no")
result="yes"
;;
*)
# The AC_REPLACE_FUNCS macro was invoked,
# meaning we are cross compiling.
if test "xno" = x"$ac_cv_func_timer_create"; then
result="yes"
else
result="no"
fi
;;
esac
echo "high resolution timer replacement .... $result"
if test "xno" = x"$hw_cv_func_snprintf_c99"; then
result="yes"
else
result="no"
fi
echo "snprintf replacement ................. $result"
if test "xfalse" = x"$enable_subunit"; then
result="no"
else
result="yes"
fi
echo "subunit support....................... $result"
if test "xtrue" = x"$enable_timeout_tests"; then
result="yes"
else
result="no"
fi
echo "timeout unit tests ................... $result"
if test "x0" = x"$ENABLE_REGEX"; then
result="no"
else
result="yes"
fi
echo "POSIX regular expressions ............ $result"
if test "xtrue" = x"$enable_build_docs"; then
result="yes"
else
result="no"
fi
echo "build docs ........................... $result"
echo "=========================================="