summaryrefslogtreecommitdiff
path: root/configure.ac
blob: a649881d520ba2555077e2b0affe1e08a4f70def (plain)
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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

# Prelude.
AC_PREREQ([2.59])

AC_INIT([Check], [0.9.8], [check-devel at lists dot sourceforge dot net])
CHECK_MAJOR_VERSION=0
CHECK_MINOR_VERSION=9
CHECK_MICRO_VERSION=8
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])

# place to put some extra build scripts installed
AC_CONFIG_AUX_DIR([build-aux])

# define things like _GNU_SOURCE appropriately
AC_USE_SYSTEM_EXTENSIONS

# really severe build strictness
AM_INIT_AUTOMAKE([-Wall -Werror gnits 1.9.6])

# FIXME: find the other places this stuff is used

AC_SUBST(CHECK_MAJOR_VERSION)
AC_SUBST(CHECK_MINOR_VERSION)
AC_SUBST(CHECK_MICRO_VERSION)
AC_SUBST(CHECK_VERSION)

# Configure options.

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 -n "$GCC"; 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 ])

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
    echoo "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])

# Checks for programs.
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
AC_PROG_LIBTOOL

# add these options to CFLAGS if the compiler supports them
AC_DEFUN([AX_CFLAGS_ADD],[AX_C_CHECK_FLAG($1, , , CFLAGS="$CFLAGS $1")])
AX_CFLAGS_WARN_ALL_ANSI
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])

AC_CHECK_PROGS(GCOV, gcov, false)
AC_CHECK_PROGS(LCOV, lcov, false)
AC_CHECK_PROGS(GENHTML, genhtml, false)
AC_CHECK_PROGS(TEX, tex, false)
if test -n "$TEX"; then
    # Make it [somewhat] clear to maintainers that tex is missing. Not an error
    # though because 'make install' (which users need) does not build the docs
    # anyway.
    AC_MSG_WARN(tex not installed: cannot rebuild HTML documentation.)
fi

# Checks for libraries.

# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([fcntl.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h])

if test xfalse != x"$enable_subunit"; then
AC_CHECK_LIB(subunit, subunit_test_start, ,
[case "$enable_subunit" in
 autodetect)
   enable_subunit=false
   ;;
 true)
   AC_MSG_ERROR([libsubunit is required for subunit protocol support. The homepage for subunit is https://launchpad.net/subunit/])
   ;;
 esac
])
fi
if test xfalse != x"$enable_subunit"; then
AC_CHECK_HEADER([subunit/child.h], ,
[case "$enable_subunit" in
 autodetect)
   enable_subunit=false
   ;;
 true)
   AC_MSG_ERROR([The header subunit/child.h could not be succesfully included and is required for subunit protocol support. The homepage for subunit is https://launchpad.net/subunit/])
   ;;
 esac
])
fi
if test xfalse = x"$enable_subunit"; then
ENABLE_SUBUNIT="0"
else
ENABLE_SUBUNIT="1"
fi
AC_SUBST(ENABLE_SUBUNIT)
AC_DEFINE_UNQUOTED(ENABLE_SUBUNIT, $ENABLE_SUBUNIT, [Subunit protocol result output])

AM_CONDITIONAL(SUBUNIT, test x"$enable_subunit" != "xfalse")



# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM

AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long, 4)

# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_REPLACE_FUNCS([fileno localtime_r pipe putenv setenv sleep strdup strsignal unsetenv])
AC_CHECK_DECLS([fileno, localtime_r, pipe, putenv, setenv, sleep, strdup, strsignal, unsetenv])

# Checks for pthread implementation.
ACX_PTHREAD
CC="$PTHREAD_CC"

# Output files
AC_CONFIG_HEADERS([config.h])

AC_CONFIG_FILES([check.pc
                 Makefile
		 doc/Makefile
		 lib/Makefile
                 src/check.h
                 src/Makefile
                 tests/Makefile
		 tests/test_vars])

AC_OUTPUT