* configure.in: Do AM_GNU_GETTEXT_VERSION, so that autoreconf will
[bpt/guile.git] / acinclude.m4
CommitLineData
3a629497
JB
1dnl On the NeXT, #including <utime.h> doesn't give you a definition for
2dnl struct utime, unless you #define _POSIX_SOURCE.
3
d70e0619 4AC_DEFUN([GUILE_STRUCT_UTIMBUF], [
3a629497
JB
5 AC_CACHE_CHECK([whether we need POSIX to get struct utimbuf],
6 guile_cv_struct_utimbuf_needs_posix,
7 [AC_TRY_CPP([
8#ifdef __EMX__
9#include <sys/utime.h>
10#else
11#include <utime.h>
12#endif
13struct utime blah;
14],
15 guile_cv_struct_utimbuf_needs_posix=no,
16 guile_cv_struct_utimbuf_needs_posix=yes)])
17 if test "$guile_cv_struct_utimbuf_needs_posix" = yes; then
e103c6b4
RB
18 AC_DEFINE([UTIMBUF_NEEDS_POSIX], 1,
19 [Define this if <utime.h> doesn't define struct utimbuf unless
20 _POSIX_SOURCE is defined. See GUILE_STRUCT_UTIMBUF in aclocal.m4.])
3a629497
JB
21 fi])
22
23
24
25
26dnl
27dnl Apparently, at CMU they have a weird version of libc.h that is
28dnl installed in /usr/local/include and conflicts with unistd.h.
29dnl In these situations, we should not #include libc.h.
30dnl This test arranges to #define LIBC_H_WITH_UNISTD_H iff libc.h is
31dnl present on the system, and is safe to #include.
32dnl
33AC_DEFUN([GUILE_HEADER_LIBC_WITH_UNISTD],
34 [
35 AC_CHECK_HEADERS(libc.h unistd.h)
36 AC_CACHE_CHECK(
3d77146f 37 [whether libc.h and unistd.h can be included together],
3a629497
JB
38 guile_cv_header_libc_with_unistd,
39 [
40 if test "$ac_cv_header_libc_h" = "no"; then
41 guile_cv_header_libc_with_unistd="no"
42d0ffc9 42 elif test "$ac_cv_header_unistd_h" = "no"; then
3a629497
JB
43 guile_cv_header_libc_with_unistd="yes"
44 else
45 AC_TRY_COMPILE(
46 [
47# include <libc.h>
48# include <unistd.h>
49 ],
50 [],
51 [guile_cv_header_libc_with_unistd=yes],
52 [guile_cv_header_libc_with_unistd=no]
53 )
54 fi
55 ]
56 )
57 if test "$guile_cv_header_libc_with_unistd" = yes; then
e103c6b4
RB
58 AC_DEFINE(LIBC_H_WITH_UNISTD_H, 1,
59 [Define this if we should include <libc.h> when we've already
60 included <unistd.h>. On some systems, they conflict, and libc.h
61 should be omitted. See GUILE_HEADER_LIBC_WITH_UNISTD in
62 aclocal.m4.])
3a629497
JB
63 fi
64 ]
65)
0b89e78e
MD
66
67
68
69dnl This is needed when we want to check for the same function repeatedly
70dnl with other parameters, such as libraries, varying.
71dnl
72dnl GUILE_NAMED_CHECK_FUNC(FUNCTION, TESTNAME,
73dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
d70e0619 74AC_DEFUN([GUILE_NAMED_CHECK_FUNC],
0b89e78e
MD
75[AC_MSG_CHECKING([for $1])
76AC_CACHE_VAL(ac_cv_func_$1_$2,
77[AC_TRY_LINK(
78dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
79dnl which includes <sys/select.h> which contains a prototype for
80dnl select. Similarly for bzero.
81[/* System header to define __stub macros and hopefully few prototypes,
82 which can conflict with char $1(); below. */
83#include <assert.h>
84/* Override any gcc2 internal prototype to avoid an error. */
ee79b9ff 85#ifdef __cplusplus
0b89e78e
MD
86extern "C"
87#endif
ee79b9ff 88/* We use char because int might match the return type of a gcc2
0b89e78e
MD
89 builtin and then its argument prototype would still apply. */
90char $1();
91], [
92/* The GNU C library defines this for functions which it implements
93 to always fail with ENOSYS. Some functions are actually named
94 something starting with __ and the normal name is an alias. */
95#if defined (__stub_$1) || defined (__stub___$1)
96choke me
97#else
98$1();
99#endif
100], eval "ac_cv_func_$1_$2=yes", eval "ac_cv_func_$1_$2=no")])
101if eval "test \"`echo '$ac_cv_func_'$1'_'$2`\" = yes"; then
102 AC_MSG_RESULT(yes)
103 ifelse([$3], , :, [$3])
104else
105 AC_MSG_RESULT(no)
106ifelse([$4], , , [$4
107])dnl
108fi
109])
75bfae86
MV
110
111
112
113
d79a62db
NJ
114dnl Available from the Autoconf Macro Archive at:
115dnl http://autoconf-archive.cryp.to/acx_pthread.html
75bfae86
MV
116dnl
117AC_DEFUN([ACX_PTHREAD], [
118AC_REQUIRE([AC_CANONICAL_HOST])
119AC_LANG_SAVE
120AC_LANG_C
121acx_pthread_ok=no
122
123# We used to check for pthread.h first, but this fails if pthread.h
124# requires special compiler flags (e.g. on True64 or Sequent).
125# It gets checked for in the link test anyway.
126
127# First of all, check if the user has set any of the PTHREAD_LIBS,
128# etcetera environment variables, and if threads linking works using
129# them:
130if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
131 save_CFLAGS="$CFLAGS"
132 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
133 save_LIBS="$LIBS"
134 LIBS="$PTHREAD_LIBS $LIBS"
135 AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
136 AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
137 AC_MSG_RESULT($acx_pthread_ok)
138 if test x"$acx_pthread_ok" = xno; then
139 PTHREAD_LIBS=""
140 PTHREAD_CFLAGS=""
141 fi
142 LIBS="$save_LIBS"
143 CFLAGS="$save_CFLAGS"
144fi
145
146# We must check for the threads library under a number of different
147# names; the ordering is very important because some systems
148# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
149# libraries is broken (non-POSIX).
150
151# Create a list of thread flags to try. Items starting with a "-" are
152# C compiler flags, and other items are library names, except for "none"
153# which indicates that we try without any flags at all, and "pthread-config"
154# which is a program returning the flags for the Pth emulation library.
155
156acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
157
158# The ordering *is* (sometimes) important. Some notes on the
159# individual items follow:
160
161# pthreads: AIX (must check this before -lpthread)
162# none: in case threads are in libc; should be tried before -Kthread and
163# other compiler flags to prevent continual compiler warnings
164# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
165# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
166# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
167# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
168# -pthreads: Solaris/gcc
169# -mthreads: Mingw32/gcc, Lynx/gcc
170# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
171# doesn't hurt to check since this sometimes defines pthreads too;
172# also defines -D_REENTRANT)
d79a62db 173# ... -mt is also the pthreads flag for HP/aCC
75bfae86
MV
174# pthread: Linux, etcetera
175# --thread-safe: KAI C++
176# pthread-config: use pthread-config program (for GNU Pth library)
177
178case "${host_cpu}-${host_os}" in
179 *solaris*)
180
181 # On Solaris (at least, for some versions), libc contains stubbed
182 # (non-functional) versions of the pthreads routines, so link-based
d79a62db 183 # tests will erroneously succeed. (We need to link with -pthreads/-mt/
75bfae86
MV
184 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
185 # a function called by this macro, so we could check for that, but
186 # who knows whether they'll stub that too in a future libc.) So,
187 # we'll just look for -pthreads and -lpthread first:
188
d79a62db 189 acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
75bfae86
MV
190 ;;
191esac
192
193if test x"$acx_pthread_ok" = xno; then
194for flag in $acx_pthread_flags; do
195
196 case $flag in
197 none)
198 AC_MSG_CHECKING([whether pthreads work without any flags])
199 ;;
200
201 -*)
202 AC_MSG_CHECKING([whether pthreads work with $flag])
203 PTHREAD_CFLAGS="$flag"
204 ;;
205
d79a62db
NJ
206 pthread-config)
207 AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
208 if test x"$acx_pthread_config" = xno; then continue; fi
209 PTHREAD_CFLAGS="`pthread-config --cflags`"
210 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
211 ;;
75bfae86
MV
212
213 *)
214 AC_MSG_CHECKING([for the pthreads library -l$flag])
215 PTHREAD_LIBS="-l$flag"
216 ;;
217 esac
218
219 save_LIBS="$LIBS"
220 save_CFLAGS="$CFLAGS"
221 LIBS="$PTHREAD_LIBS $LIBS"
222 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
223
224 # Check for various functions. We must include pthread.h,
225 # since some functions may be macros. (On the Sequent, we
226 # need a special flag -Kthread to make this header compile.)
227 # We check for pthread_join because it is in -lpthread on IRIX
228 # while pthread_create is in libc. We check for pthread_attr_init
229 # due to DEC craziness with -lpthreads. We check for
230 # pthread_cleanup_push because it is one of the few pthread
231 # functions on Solaris that doesn't have a non-functional libc stub.
232 # We try pthread_create on general principles.
233 AC_TRY_LINK([#include <pthread.h>],
234 [pthread_t th; pthread_join(th, 0);
235 pthread_attr_init(0); pthread_cleanup_push(0, 0);
236 pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
237 [acx_pthread_ok=yes])
238
239 LIBS="$save_LIBS"
240 CFLAGS="$save_CFLAGS"
241
242 AC_MSG_RESULT($acx_pthread_ok)
243 if test "x$acx_pthread_ok" = xyes; then
244 break;
245 fi
246
247 PTHREAD_LIBS=""
248 PTHREAD_CFLAGS=""
249done
250fi
251
252# Various other checks:
253if test "x$acx_pthread_ok" = xyes; then
254 save_LIBS="$LIBS"
255 LIBS="$PTHREAD_LIBS $LIBS"
256 save_CFLAGS="$CFLAGS"
257 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
258
d79a62db 259 # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
75bfae86 260 AC_MSG_CHECKING([for joinable pthread attribute])
d79a62db
NJ
261 attr_name=unknown
262 for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
263 AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
264 [attr_name=$attr; break])
265 done
266 AC_MSG_RESULT($attr_name)
267 if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
268 AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
269 [Define to necessary symbol if this constant
270 uses a non-standard name on your system.])
75bfae86
MV
271 fi
272
273 AC_MSG_CHECKING([if more special flags are required for pthreads])
274 flag=no
275 case "${host_cpu}-${host_os}" in
d79a62db
NJ
276 *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
277 *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
75bfae86
MV
278 esac
279 AC_MSG_RESULT(${flag})
280 if test "x$flag" != xno; then
d79a62db 281 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
75bfae86
MV
282 fi
283
284 LIBS="$save_LIBS"
285 CFLAGS="$save_CFLAGS"
286
d79a62db
NJ
287 # More AIX lossage: must compile with xlc_r or cc_r
288 if test x"$GCC" != xyes; then
289 AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
290 else
291 PTHREAD_CC=$CC
292 fi
75bfae86
MV
293else
294 PTHREAD_CC="$CC"
295fi
296
297AC_SUBST(PTHREAD_LIBS)
298AC_SUBST(PTHREAD_CFLAGS)
299AC_SUBST(PTHREAD_CC)
300
301# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
302if test x"$acx_pthread_ok" = xyes; then
303 ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
304 :
305else
306 acx_pthread_ok=no
307 $2
308fi
309AC_LANG_RESTORE
310])dnl ACX_PTHREAD
0bdb025f
NJ
311
312AC_DEFUN([AM_INTL_SUBDIR], [])dnl