bump version to 0.82 and prepare for release
[catagits/fcgi2.git] / acinclude.m4
CommitLineData
d300bc46 1dnl $Id: acinclude.m4,v 1.2 2001/12/21 03:12:50 robs Exp $
7ef79c64 2
14e49837 3AC_DEFUN([FCGI_COMMON_CHECKS], [
7ef79c64 4 AC_CHECK_TYPE([ssize_t], [int])
5
6 AC_MSG_CHECKING([for sun_len in sys/un.h])
7 AC_EGREP_HEADER([sun_len], [sys/un.h],
8 [AC_MSG_RESULT([yes])
9 AC_DEFINE([HAVE_SOCKADDR_UN_SUN_LEN], [1],
10 [Define if sockaddr_un in sys/un.h contains a sun_len component])],
11 AC_MSG_RESULT([no]))
12
13 AC_MSG_CHECKING([for fpos_t in stdio.h])
14 AC_EGREP_HEADER([fpos_t], [stdio.h],
15 [AC_MSG_RESULT([yes])
16 AC_DEFINE([HAVE_FPOS], [1],
17 [Define if the fpos_t typedef is in stdio.h])],
18 AC_MSG_RESULT([no]))
19
20 AC_CHECK_HEADERS([sys/socket.h netdb.h netinet/in.h arpa/inet.h])
21 AC_CHECK_HEADERS([sys/time.h limits.h sys/param.h unistd.h])
22
23 AC_MSG_CHECKING([for a fileno() prototype in stdio.h])
24 AC_EGREP_HEADER([fileno], [stdio.h],
25 [AC_MSG_RESULT([yes])
26 AC_DEFINE([HAVE_FILENO_PROTO], [1],
27 [Define if there's a fileno() prototype in stdio.h])],
28 AC_MSG_RESULT([no]))
29
30 if test "$HAVE_SYS_SOCKET_H"; then
31 AC_MSG_CHECKING([for socklen_t in sys/socket.h])
32 AC_EGREP_HEADER([socklen_t], [sys/socket.h],
33 [AC_MSG_RESULT([yes])
34 AC_DEFINE([HAVE_SOCKLEN], [1],
35 [Define if the socklen_t typedef is in sys/socket.h])],
36 AC_MSG_RESULT([no]))
37 fi
38
39 #--------------------------------------------------------------------
40 # Do we need cross-process locking on this platform?
41 #--------------------------------------------------------------------
42 AC_MSG_CHECKING([whether cross-process locking is required by accept()])
43 case "`uname -sr`" in
44 IRIX\ 5.* | SunOS\ 5.* | UNIX_System_V\ 4.0)
45 AC_MSG_RESULT([yes])
46 AC_DEFINE([USE_LOCKING], [1],
47 [Define if cross-process locking is required by accept()])
48 ;;
49 *)
50 AC_MSG_RESULT([no])
51 ;;
52 esac
53
54 #--------------------------------------------------------------------
55 # Does va_arg(arg, long double) crash the compiler?
56 # hpux 9.04 compiler does and so does Stratus FTX (uses HP's compiler)
57 #--------------------------------------------------------------------
58 AC_MSG_CHECKING([whether va_arg(arg, long double) crashes the compiler])
59 AC_TRY_COMPILE([#include <stdarg.h>],
60 [long double lDblArg; va_list arg; lDblArg = va_arg(arg, long double);],
61 AC_MSG_RESULT([no]),
62 [AC_MSG_RESULT([yes])
63 AC_DEFINE([HAVE_VA_ARG_LONG_DOUBLE_BUG], [1],
64 [Define if va_arg(arg, long double) crashes the compiler])])
65
66 AC_C_CONST
67])
d300bc46 68
69
70dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
71dnl
72dnl This macro figures out how to build C programs using POSIX
73dnl threads. It sets the PTHREAD_LIBS output variable to the threads
74dnl library and linker flags, and the PTHREAD_CFLAGS output variable
75dnl to any special C compiler flags that are needed. (The user can also
76dnl force certain compiler flags/libs to be tested by setting these
77dnl environment variables.)
78dnl
79dnl Also sets PTHREAD_CC to any special C compiler that is needed for
80dnl multi-threaded programs (defaults to the value of CC otherwise).
81dnl (This is necessary on AIX to use the special cc_r compiler alias.)
82dnl
83dnl If you are only building threads programs, you may wish to
84dnl use these variables in your default LIBS, CFLAGS, and CC:
85dnl
86dnl LIBS="$PTHREAD_LIBS $LIBS"
87dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
88dnl CC="$PTHREAD_CC"
89dnl
90dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
91dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE
92dnl to that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
93dnl
94dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
95dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands
96dnl to run it if it is not found. If ACTION-IF-FOUND is not specified,
97dnl the default action will define HAVE_PTHREAD.
98dnl
99dnl Please let the authors know if this macro fails on any platform,
100dnl or if you have any other suggestions or comments. This macro was
101dnl based on work by SGJ on autoconf scripts for FFTW (www.fftw.org)
102dnl (with help from M. Frigo), as well as ac_pthread and hb_pthread
103dnl macros posted by AFC to the autoconf macro repository. We are also
104dnl grateful for the helpful feedback of numerous users.
105dnl
106dnl @version $Id: acinclude.m4,v 1.2 2001/12/21 03:12:50 robs Exp $
107dnl @author Steven G. Johnson <stevenj@alum.mit.edu> and Alejandro Forero Cuervo <bachue@bachue.com>
108
109AC_DEFUN([ACX_PTHREAD], [
110AC_REQUIRE([AC_CANONICAL_HOST])
111acx_pthread_ok=no
112
113# First, check if the POSIX threads header, pthread.h, is available.
114# If it isn't, don't bother looking for the threads libraries.
115AC_CHECK_HEADER(pthread.h, , acx_pthread_ok=noheader)
116
117# We must check for the threads library under a number of different
118# names; the ordering is very important because some systems
119# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
120# libraries is broken (non-POSIX).
121
122# First of all, check if the user has set any of the PTHREAD_LIBS,
123# etcetera environment variables, and if threads linking works using
124# them:
125if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
126 save_CFLAGS="$CFLAGS"
127 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
128 save_LIBS="$LIBS"
129 LIBS="$PTHREAD_LIBS $LIBS"
130 AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
131 AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
132 AC_MSG_RESULT($acx_pthread_ok)
133 if test x"$acx_pthread_ok" = xno; then
134 PTHREAD_LIBS=""
135 PTHREAD_CFLAGS=""
136 fi
137 LIBS="$save_LIBS"
138 CFLAGS="$save_CFLAGS"
139fi
140
141# Create a list of thread flags to try. Items starting with a "-" are
142# C compiler flags, and other items are library names, except for "none"
143# which indicates that we try without any flags at all.
144
145acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt"
146
147# The ordering *is* (sometimes) important. Some notes on the
148# individual items follow:
149
150# pthreads: AIX (must check this before -lpthread)
151# none: in case threads are in libc; should be tried before -Kthread and
152# other compiler flags to prevent continual compiler warnings
153# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
154# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
155# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
156# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
157# -pthreads: Solaris/gcc
158# -mthreads: Mingw32/gcc, Lynx/gcc
159# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
160# doesn't hurt to check since this sometimes defines pthreads too;
161# also defines -D_REENTRANT)
162# pthread: Linux, etcetera
163# --thread-safe: KAI C++
164
165case "${host_cpu}-${host_os}" in
166 *solaris*)
167
168 # On Solaris (at least, for some versions), libc contains stubbed
169 # (non-functional) versions of the pthreads routines, so link-based
170 # tests will erroneously succeed. (We need to link with -pthread or
171 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
172 # a function called by this macro, so we could check for that, but
173 # who knows whether they'll stub that too in a future libc.) So,
174 # we'll just look for -pthreads and -lpthread first:
175
176 acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
177 ;;
178esac
179
180if test x"$acx_pthread_ok" = xno; then
181for flag in $acx_pthread_flags; do
182
183 case $flag in
184 none)
185 AC_MSG_CHECKING([whether pthreads work without any flags])
186 ;;
187
188 -*)
189 AC_MSG_CHECKING([whether pthreads work with $flag])
190 PTHREAD_CFLAGS="$flag"
191 ;;
192
193 *)
194 AC_MSG_CHECKING([for the pthreads library -l$flag])
195 PTHREAD_LIBS="-l$flag"
196 ;;
197 esac
198
199 save_LIBS="$LIBS"
200 save_CFLAGS="$CFLAGS"
201 LIBS="$PTHREAD_LIBS $LIBS"
202 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
203
204 # Check for various functions. We must include pthread.h,
205 # since some functions may be macros. (On the Sequent, we
206 # need a special flag -Kthread to make this header compile.)
207 # We check for pthread_join because it is in -lpthread on IRIX
208 # while pthread_create is in libc. We check for pthread_attr_init
209 # due to DEC craziness with -lpthreads. We check for
210 # pthread_cleanup_push because it is one of the few pthread
211 # functions on Solaris that doesn't have a non-functional libc stub.
212 # We try pthread_create on general principles.
213 AC_TRY_LINK([#include <pthread.h>],
214 [pthread_t th; pthread_join(th, 0);
215 pthread_attr_init(0); pthread_cleanup_push(0, 0);
216 pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
217 [acx_pthread_ok=yes])
218
219 LIBS="$save_LIBS"
220 CFLAGS="$save_CFLAGS"
221
222 AC_MSG_RESULT($acx_pthread_ok)
223 if test "x$acx_pthread_ok" = xyes; then
224 break;
225 fi
226
227 PTHREAD_LIBS=""
228 PTHREAD_CFLAGS=""
229done
230fi
231
232# Various other checks:
233if test "x$acx_pthread_ok" = xyes; then
234 save_LIBS="$LIBS"
235 LIBS="$PTHREAD_LIBS $LIBS"
236 save_CFLAGS="$CFLAGS"
237 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
238
239 # Detect AIX lossage: threads are created detached by default
240 # and the JOINABLE attribute has a nonstandard name (UNDETACHED).
241 AC_MSG_CHECKING([for joinable pthread attribute])
242 AC_TRY_LINK([#include <pthread.h>],
243 [int attr=PTHREAD_CREATE_JOINABLE;],
244 ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
245 if test x"$ok" = xunknown; then
246 AC_TRY_LINK([#include <pthread.h>],
247 [int attr=PTHREAD_CREATE_UNDETACHED;],
248 ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
249 fi
250 if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
251 AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
252 [Define to the necessary symbol if this constant
253 uses a non-standard name on your system.])
254 fi
255 AC_MSG_RESULT(${ok})
256 if test x"$ok" = xunknown; then
257 AC_MSG_WARN([we do not know how to create joinable pthreads])
258 fi
259
260 AC_MSG_CHECKING([if more special flags are required for pthreads])
261 flag=no
262 case "${host_cpu}-${host_os}" in
263 *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";;
264 *solaris* | alpha*-osf*) flag="-D_REENTRANT";;
265 esac
266 AC_MSG_RESULT(${flag})
267 if test "x$flag" != xno; then
268 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
269 fi
270
271 LIBS="$save_LIBS"
272 CFLAGS="$save_CFLAGS"
273
274 # More AIX lossage: must compile with cc_r
275 AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
276else
277 PTHREAD_CC="$CC"
278fi
279
280AC_SUBST(PTHREAD_LIBS)
281AC_SUBST(PTHREAD_CFLAGS)
282AC_SUBST(PTHREAD_CC)
283
284# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
285if test x"$acx_pthread_ok" = xyes; then
286 ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
287 :
288else
289 acx_pthread_ok=no
290 $2
291fi
292
293])dnl ACX_PTHREAD
294
295
296
297dnl @synopsis AC_PROG_CC_WARNINGS([ANSI])
298dnl
299dnl Enables a reasonable set of warnings for the C compiler. Optionally,
300dnl if the first argument is nonempty, turns on flags which enforce and/or
301dnl enable proper ANSI C if such flags are known to the compiler used.
302dnl
303dnl Currently this macro knows about GCC, Solaris C compiler,
304dnl Digital Unix C compiler, C for AIX Compiler, HP-UX C compiler,
305dnl and IRIX C compiler.
306dnl
307dnl @version $Id: acinclude.m4,v 1.2 2001/12/21 03:12:50 robs Exp $
308dnl @author Ville Laurikari <vl@iki.fi>
309dnl
310AC_DEFUN([AC_PROG_CC_WARNINGS], [
311 ansi=$1
312 if test -z "$ansi"; then
313 msg="for C compiler warning flags"
314 else
315 msg="for C compiler warning and ANSI conformance flags"
316 fi
317 AC_CACHE_CHECK($msg, ac_cv_prog_cc_warnings, [
318 if test -n "$CC"; then
319 cat > conftest.c <<EOF
320int main(int argc, char **argv) { return 0; }
321EOF
322
323 dnl GCC
324 if test "$GCC" = "yes"; then
325 if test -z "$ansi"; then
326 ac_cv_prog_cc_warnings="-Wall"
327 else
328 ac_cv_prog_cc_warnings="-Wall -ansi -pedantic"
329 fi
330
331 dnl Solaris C compiler
332 elif $CC -flags 2>&1 | grep "Xc.*strict ANSI C" > /dev/null 2>&1 &&
333 $CC -c -v -Xc conftest.c > /dev/null 2>&1 &&
334 test -f conftest.o; then
335 if test -z "$ansi"; then
336 ac_cv_prog_cc_warnings="-v"
337 else
338 ac_cv_prog_cc_warnings="-v -Xc"
339 fi
340
341 dnl HP-UX C compiler
342 elif $CC > /dev/null 2>&1 &&
343 $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 &&
344 test -f conftest.o; then
345 if test -z "$ansi"; then
346 ac_cv_prog_cc_warnings="+w1"
347 else
348 ac_cv_prog_cc_warnings="+w1 -Aa"
349 fi
350
351 dnl Digital Unix C compiler
352 elif ! $CC > /dev/null 2>&1 &&
353 $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 &&
354 test -f conftest.o; then
355 if test -z "$ansi"; then
356 ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos"
357 else
358 ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1"
359 fi
360
361 dnl C for AIX Compiler
362 elif $CC > /dev/null 2>&1 | grep AIX > /dev/null 2>&1 &&
363 $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 &&
364 test -f conftest.o; then
365 if test -z "$ansi"; then
366 ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd"
367 else
368 ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi"
369 fi
370
371 dnl IRIX C compiler
372 elif $CC -fullwarn -ansi -ansiE > /dev/null 2>&1 &&
373 test -f conftest.o; then
374 if test -z "$ansi"; then
375 ac_cv_prog_cc_warnings="-fullwarn"
376 else
377 ac_cv_prog_cc_warnings="-fullwarn -ansi -ansiE"
378 fi
379
380 fi
381 rm -f conftest.*
382 fi
383 if test -n "$ac_cv_prog_cc_warnings"; then
384 CFLAGS="$CFLAGS $ac_cv_prog_cc_warnings"
385 else
386 ac_cv_prog_cc_warnings="unknown"
387 fi
388 ])
389])
390
391