configure.ac 15 KB

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