You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

389 lines
14 KiB

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