* bin/autoupdate.in: Trace AU_DEFINE instead of AU_DEFUN.
[autoconf.git] / lib / autoconf / specific.m4
blob6e9d96470cd65f59dd1cb15f24e62c7ef307a2c0
1 # This file is part of Autoconf.                       -*- Autoconf -*-
2 # Macros that test for specific, unclassified, features.
4 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
5 # 2002, 2003, 2004 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # 02111-1307, USA.
22 # As a special exception, the Free Software Foundation gives unlimited
23 # permission to copy, distribute and modify the configure scripts that
24 # are the output of Autoconf.  You need not follow the terms of the GNU
25 # General Public License when using or distributing such scripts, even
26 # though portions of the text of Autoconf appear in them.  The GNU
27 # General Public License (GPL) does govern all other use of the material
28 # that constitutes the Autoconf program.
30 # Certain portions of the Autoconf source text are designed to be copied
31 # (in certain cases, depending on the input) into the output of
32 # Autoconf.  We call these the "data" portions.  The rest of the Autoconf
33 # source text consists of comments plus executable code that decides which
34 # of the data portions to output in any given case.  We call these
35 # comments and executable code the "non-data" portions.  Autoconf never
36 # copies any of the non-data portions into its output.
38 # This special exception to the GPL applies to versions of Autoconf
39 # released by the Free Software Foundation.  When you make and
40 # distribute a modified version of Autoconf, you may extend this special
41 # exception to the GPL to apply to your modified version as well, *unless*
42 # your modified version has the potential to copy into its output some
43 # of the text that was the non-data portion of the version that you started
44 # with.  (In other words, unless your change moves or copies text from
45 # the non-data portions to the data portions.)  If your modification has
46 # such potential, you must delete any notice of this special exception
47 # to the GPL from your modified version.
49 # Written by David MacKenzie, with help from
50 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
51 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
54 ## ------------------------- ##
55 ## Checks for declarations.  ##
56 ## ------------------------- ##
59 # AC_DECL_SYS_SIGLIST
60 # -------------------
61 AN_IDENTIFIER([sys_siglist],     [AC_CHECK_DECLS([sys_siglist])])
62 AU_DEFUN([AC_DECL_SYS_SIGLIST],
63 [AC_CHECK_DECLS([sys_siglist],,,
64 [#include <signal.h>
65 /* NetBSD declares sys_siglist in unistd.h.  */
66 #if HAVE_UNISTD_H
67 # include <unistd.h>
68 #endif
70 ])# AC_DECL_SYS_SIGLIST
75 ## -------------------------------------- ##
76 ## Checks for operating system services.  ##
77 ## -------------------------------------- ##
80 # AC_SYS_INTERPRETER
81 # ------------------
82 AC_DEFUN([AC_SYS_INTERPRETER],
83 [AC_CACHE_CHECK(whether @%:@! works in shell scripts, ac_cv_sys_interpreter,
84 [echo '#! /bin/cat
85 exit 69
86 ' >conftest
87 chmod u+x conftest
88 (SHELL=/bin/sh; export SHELL; ./conftest >/dev/null)
89 if test $? -ne 69; then
90    ac_cv_sys_interpreter=yes
91 else
92    ac_cv_sys_interpreter=no
94 rm -f conftest])
95 interpval=$ac_cv_sys_interpreter
99 AU_DEFUN([AC_HAVE_POUNDBANG],
100 [AC_SYS_INTERPRETER],
101 [Remove this warning when you adjust your code to use
102 `AC_SYS_INTERPRETER'.])
105 AU_DEFUN([AC_ARG_ARRAY], [],
106 [$0 is no longer implemented: don't do unportable things
107 with arguments. Remove this warning when you adjust your code.])
110 # _AC_SYS_LARGEFILE_TEST_INCLUDES
111 # -------------------------------
112 m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
113 [@%:@include <sys/types.h>
114  /* Check that off_t can represent 2**63 - 1 correctly.
115     We can't simply define LARGE_OFF_T to be 9223372036854775807,
116     since some C++ compilers masquerading as C compilers
117     incorrectly reject 9223372036854775807.  */
118 @%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
119   int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
120                        && LARGE_OFF_T % 2147483647 == 1)
121                       ? 1 : -1]];[]dnl
125 # _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
126 #                               CACHE-VAR,
127 #                               DESCRIPTION,
128 #                               [INCLUDES], [FUNCTION-BODY])
129 # ----------------------------------------------------------
130 m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
131 [AC_CACHE_CHECK([for $1 value needed for large files], [$3],
132 [while :; do
133   $3=no
134   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$5], [$6])],
135                     [break])
136   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@define $1 $2
137 $5], [$6])],
138                     [$3=$2; break])
139   break
140 done])
141 if test "$$3" != no; then
142   AC_DEFINE_UNQUOTED([$1], [$$3], [$4])
144 rm -f conftest*[]dnl
145 ])# _AC_SYS_LARGEFILE_MACRO_VALUE
148 # AC_SYS_LARGEFILE
149 # ----------------
150 # By default, many hosts won't let programs access large files;
151 # one must use special compiler options to get large-file access to work.
152 # For more details about this brain damage please see:
153 # http://www.unix-systems.org/version2/whatsnew/lfs20mar.html
154 AC_DEFUN([AC_SYS_LARGEFILE],
155 [AC_ARG_ENABLE(largefile,
156                [  --disable-largefile     omit support for large files])
157 if test "$enable_largefile" != no; then
159   AC_CACHE_CHECK([for special C compiler options needed for large files],
160     ac_cv_sys_largefile_CC,
161     [ac_cv_sys_largefile_CC=no
162      if test "$GCC" != yes; then
163        ac_save_CC=$CC
164        while :; do
165          # IRIX 6.2 and later do not support large files by default,
166          # so use the C compiler's -n32 option if that helps.
167          AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
168          AC_COMPILE_IFELSE([], [break])
169          CC="$CC -n32"
170          AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
171          break
172        done
173        CC=$ac_save_CC
174        rm -f conftest.$ac_ext
175     fi])
176   if test "$ac_cv_sys_largefile_CC" != no; then
177     CC=$CC$ac_cv_sys_largefile_CC
178   fi
180   _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
181     ac_cv_sys_file_offset_bits,
182     [Number of bits in a file offset, on hosts where this is settable.],
183     [_AC_SYS_LARGEFILE_TEST_INCLUDES])
184   _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
185     ac_cv_sys_large_files,
186     [Define for large files, on AIX-style hosts.],
187     [_AC_SYS_LARGEFILE_TEST_INCLUDES])
189 ])# AC_SYS_LARGEFILE
192 # AC_SYS_LONG_FILE_NAMES
193 # ----------------------
194 # Security: use a temporary directory as the most portable way of
195 # creating files in /tmp securely.  Removing them leaves a race
196 # condition, set -C is not portably guaranteed to use O_EXCL, so still
197 # leaves a race, and not all systems have the `mktemp' utility.  We
198 # still test for existence first in case of broken systems where the
199 # mkdir succeeds even when the directory exists.  Broken systems may
200 # retain a race, but they probably have other security problems
201 # anyway; this should be secure on well-behaved systems.  In any case,
202 # use of `mktemp' is probably inappropriate here since it would fail in
203 # attempting to create different file names differing after the 14th
204 # character on file systems without long file names.
205 AC_DEFUN([AC_SYS_LONG_FILE_NAMES],
206 [AC_CACHE_CHECK(for long file names, ac_cv_sys_long_file_names,
207 [ac_cv_sys_long_file_names=yes
208 # Test for long file names in all the places we know might matter:
209 #      .                the current directory, where building will happen
210 #      $prefix/lib      where we will be installing things
211 #      $exec_prefix/lib likewise
212 # eval it to expand exec_prefix.
213 #      $TMPDIR          if set, where it might want to write temporary files
214 # if $TMPDIR is not set:
215 #      /tmp             where it might want to write temporary files
216 #      /var/tmp         likewise
217 #      /usr/tmp         likewise
218 if test -n "$TMPDIR" && test -d "$TMPDIR" && test -w "$TMPDIR"; then
219   ac_tmpdirs=$TMPDIR
220 else
221   ac_tmpdirs='/tmp /var/tmp /usr/tmp'
223 for ac_dir in  . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do
224   test -d $ac_dir || continue
225   test -w $ac_dir || continue # It is less confusing to not echo anything here.
226   ac_xdir=$ac_dir/cf$$
227   (umask 077 && mkdir $ac_xdir 2>/dev/null) || continue
228   ac_tf1=$ac_xdir/conftest9012345
229   ac_tf2=$ac_xdir/conftest9012346
230   (echo 1 >$ac_tf1) 2>/dev/null
231   (echo 2 >$ac_tf2) 2>/dev/null
232   ac_val=`cat $ac_tf1 2>/dev/null`
233   if test ! -f $ac_tf1 || test "$ac_val" != 1; then
234     ac_cv_sys_long_file_names=no
235     rm -f -r $ac_xdir 2>/dev/null
236     break
237   fi
238   rm -f -r $ac_xdir 2>/dev/null
239 done])
240 if test $ac_cv_sys_long_file_names = yes; then
241   AC_DEFINE(HAVE_LONG_FILE_NAMES, 1,
242             [Define to 1 if you support file names longer than 14 characters.])
247 # AC_SYS_RESTARTABLE_SYSCALLS
248 # ---------------------------
249 # If the system automatically restarts a system call that is
250 # interrupted by a signal, define `HAVE_RESTARTABLE_SYSCALLS'.
251 AC_DEFUN([AC_SYS_RESTARTABLE_SYSCALLS],
252 [AC_DIAGNOSE([obsolete],
253 [$0: AC_SYS_RESTARTABLE_SYSCALLS is useful only when supporting very
254 old systems that lack `sigaction' and `SA_RESTART'.  Don't bother with
255 this macro unless you need to support very old systems like 4.2BSD and
256 SVR3.])dnl
257 AC_REQUIRE([AC_HEADER_SYS_WAIT])dnl
258 AC_CHECK_HEADERS(unistd.h)
259 AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
260 [AC_RUN_IFELSE([AC_LANG_SOURCE(
261 [/* Exit 0 (true) if wait returns something other than -1,
262    i.e. the pid of the child, which means that wait was restarted
263    after getting the signal.  */
265 #include <sys/types.h>
266 #include <signal.h>
267 #if HAVE_UNISTD_H
268 # include <unistd.h>
269 #endif
270 #if HAVE_SYS_WAIT_H
271 # include <sys/wait.h>
272 #endif
274 /* Some platforms explicitly require an extern "C" signal handler
275    when using C++. */
276 #ifdef __cplusplus
277 extern "C" void ucatch (int dummy) { }
278 #else
279 void ucatch (dummy) int dummy; { }
280 #endif
283 main ()
285   int i = fork (), status;
287   if (i == 0)
288     {
289       sleep (3);
290       kill (getppid (), SIGINT);
291       sleep (3);
292       exit (0);
293     }
295   signal (SIGINT, ucatch);
297   status = wait (&i);
298   if (status == -1)
299     wait (&i);
301   exit (status == -1);
302 }])],
303                [ac_cv_sys_restartable_syscalls=yes],
304                [ac_cv_sys_restartable_syscalls=no])])
305 if test $ac_cv_sys_restartable_syscalls = yes; then
306   AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS, 1,
307             [Define to 1 if system calls automatically restart after
308              interruption by a signal.])
310 ])# AC_SYS_RESTARTABLE_SYSCALLS
313 # AC_SYS_POSIX_TERMIOS
314 # --------------------
315 AC_DEFUN([AC_SYS_POSIX_TERMIOS],
316 [AC_CACHE_CHECK([POSIX termios], ac_cv_sys_posix_termios,
317 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
318 #include <unistd.h>
319 #include <termios.h>
321              [/* SunOS 4.0.3 has termios.h but not the library calls.  */
322    tcgetattr(0, 0);])],
323              ac_cv_sys_posix_termios=yes,
324              ac_cv_sys_posix_termios=no)])
325 ])# AC_SYS_POSIX_TERMIOS
330 ## ------------------------------------ ##
331 ## Checks for not-quite-Unix variants.  ##
332 ## ------------------------------------ ##
335 # AC_GNU_SOURCE
336 # --------------
337 AC_DEFUN([AC_GNU_SOURCE],
338 [AH_VERBATIM([_GNU_SOURCE],
339 [/* Enable GNU extensions on systems that have them.  */
340 #ifndef _GNU_SOURCE
341 # undef _GNU_SOURCE
342 #endif])dnl
343 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
344 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
345 AC_DEFINE([_GNU_SOURCE])
349 # AC_CYGWIN
350 # ---------
351 # Check for Cygwin.  This is a way to set the right value for
352 # EXEEXT.
353 AU_DEFUN([AC_CYGWIN],
354 [AC_CANONICAL_HOST
355 case $host_os in
356   *cygwin* ) CYGWIN=yes;;
357          * ) CYGWIN=no;;
358 esac
359 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
360 matches *cygwin*])# AC_CYGWIN
363 # AC_EMXOS2
364 # ---------
365 # Check for EMX on OS/2.  This is another way to set the right value
366 # for EXEEXT.
367 AU_DEFUN([AC_EMXOS2],
368 [AC_CANONICAL_HOST
369 case $host_os in
370   *emx* ) EMXOS2=yes;;
371       * ) EMXOS2=no;;
372 esac
373 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
374 matches *emx*])# AC_EMXOS2
377 # AC_MINGW32
378 # ----------
379 # Check for mingw32.  This is another way to set the right value for
380 # EXEEXT.
381 AU_DEFUN([AC_MINGW32],
382 [AC_CANONICAL_HOST
383 case $host_os in
384   *mingw32* ) MINGW32=yes;;
385           * ) MINGW32=no;;
386 esac
387 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
388 matches *mingw32*])# AC_MINGW32
393 ## -------------------------- ##
394 ## Checks for UNIX variants.  ##
395 ## -------------------------- ##
398 # These are kludges which should be replaced by a single POSIX check.
399 # They aren't cached, to discourage their use.
401 # AC_AIX
402 # ------
403 AC_DEFUN([AC_AIX],
404 [AH_VERBATIM([_ALL_SOURCE],
405 [/* Define to 1 if on AIX 3.
406    System headers sometimes define this.
407    We just want to avoid a redefinition error message.  */
408 @%:@ifndef _ALL_SOURCE
409 @%:@ undef _ALL_SOURCE
410 @%:@endif])dnl
411 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
412 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
413 AC_MSG_CHECKING([for AIX])
414 AC_EGREP_CPP(yes,
415 [#ifdef _AIX
416   yes
417 #endif
419 [AC_MSG_RESULT([yes])
420 AC_DEFINE(_ALL_SOURCE)],
421 [AC_MSG_RESULT([no])])
422 ])# AC_AIX
425 # AC_MINIX
426 # --------
427 AC_DEFUN([AC_MINIX],
428 [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
429 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
430 AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=)
431 if test "$MINIX" = yes; then
432   AC_DEFINE(_POSIX_SOURCE, 1,
433             [Define to 1 if you need to in order for `stat' and other things to
434              work.])
435   AC_DEFINE(_POSIX_1_SOURCE, 2,
436             [Define to 2 if the system does not provide POSIX.1 features except
437              with this defined.])
438   AC_DEFINE(_MINIX, 1,
439             [Define to 1 if on MINIX.])
441 ])# AC_MINIX
444 # AC_ISC_POSIX
445 # ------------
446 AC_DEFUN([AC_ISC_POSIX], [AC_SEARCH_LIBS(strerror, cposix)])
449 # AC_XENIX_DIR
450 # ------------
451 AU_DEFUN([AC_XENIX_DIR],
452 [AC_MSG_CHECKING([for Xenix])
453 AC_EGREP_CPP(yes,
454 [#if defined(M_XENIX) && !defined(M_UNIX)
455   yes
456 @%:@endif],
457              [AC_MSG_RESULT([yes]); XENIX=yes],
458              [AC_MSG_RESULT([no]); XENIX=])
460 AC_HEADER_DIRENT[]dnl
462 [You shouldn't need to depend upon XENIX.  Remove the
463 `AC_MSG_CHECKING', `AC_EGREP_CPP', and this warning if this part
464 of the test is useless.])
467 # AC_DYNIX_SEQ
468 # ------------
469 AU_DEFUN([AC_DYNIX_SEQ], [AC_FUNC_GETMNTENT])
472 # AC_IRIX_SUN
473 # -----------
474 AU_DEFUN([AC_IRIX_SUN],
475 [AC_FUNC_GETMNTENT
476 AC_CHECK_LIB(sun, getpwnam)])
479 # AC_SCO_INTL
480 # -----------
481 AU_DEFUN([AC_SCO_INTL], [AC_FUNC_STRFTIME])