1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Macros that test for specific, unclassified, features.
4 # Copyright (C) 1992-1996, 1998-2013 Free Software Foundation, Inc.
6 # This file is part of Autoconf. This program is free
7 # software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the
9 # Free Software Foundation, either version 3 of the License, or
10 # (at your option) 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 # Under Section 7 of GPL version 3, you are granted additional
18 # permissions described in the Autoconf Configure Script Exception,
19 # version 3.0, as published by the Free Software Foundation.
21 # You should have received a copy of the GNU General Public License
22 # and a copy of the Autoconf Configure Script Exception along with
23 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
24 # respectively. If not, see <http://www.gnu.org/licenses/>.
26 # Written by David MacKenzie, with help from
27 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
28 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
31 ## ------------------------- ##
32 ## Checks for declarations. ##
33 ## ------------------------- ##
38 AN_IDENTIFIER([sys_siglist], [AC_CHECK_DECLS([sys_siglist])])
39 AU_DEFUN([AC_DECL_SYS_SIGLIST],
40 [AC_CHECK_DECLS([sys_siglist],,,
42 /* NetBSD declares sys_siglist in unistd.h. */
47 ])# AC_DECL_SYS_SIGLIST
52 ## -------------------------------------- ##
53 ## Checks for operating system services. ##
54 ## -------------------------------------- ##
59 AC_DEFUN([AC_SYS_INTERPRETER],
60 [AC_CACHE_CHECK(whether @%:@! works in shell scripts, ac_cv_sys_interpreter,
65 (SHELL=/bin/sh; export SHELL; ./conftest >/dev/null 2>&1)
66 if test $? -ne 69; then
67 ac_cv_sys_interpreter=yes
69 ac_cv_sys_interpreter=no
72 interpval=$ac_cv_sys_interpreter
76 AU_DEFUN([AC_HAVE_POUNDBANG],
78 [Remove this warning when you adjust your code to use
79 `AC_SYS_INTERPRETER'.])
82 AU_DEFUN([AC_ARG_ARRAY], [],
83 [$0 is no longer implemented: don't do unportable things
84 with arguments. Remove this warning when you adjust your code.])
87 # _AC_SYS_LARGEFILE_TEST_INCLUDES
88 # -------------------------------
89 m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
90 [@%:@include <sys/types.h>
91 /* Check that off_t can represent 2**63 - 1 correctly.
92 We can't simply define LARGE_OFF_T to be 9223372036854775807,
93 since some C++ compilers masquerading as C compilers
94 incorrectly reject 9223372036854775807. */
95 @%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
96 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
97 && LARGE_OFF_T % 2147483647 == 1)
102 # _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
105 # PROLOGUE, [FUNCTION-BODY])
106 # --------------------------------------------------------
107 m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
108 [AC_CACHE_CHECK([for $1 value needed for large files], [$3],
110 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
111 [AC_LANG_PROGRAM([$5], [$6])],
113 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
114 [AC_LANG_PROGRAM([@%:@define $1 $2
122 *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
124 rm -rf conftest*[]dnl
125 ])# _AC_SYS_LARGEFILE_MACRO_VALUE
130 # By default, many hosts won't let programs access large files;
131 # one must use special compiler options to get large-file access to work.
132 # For more details about this brain damage please see:
133 # http://www.unix-systems.org/version2/whatsnew/lfs20mar.html
134 AC_DEFUN([AC_SYS_LARGEFILE],
135 [AC_ARG_ENABLE(largefile,
136 [ --disable-largefile omit support for large files])
137 if test "$enable_largefile" != no; then
139 AC_CACHE_CHECK([for special C compiler options needed for large files],
140 ac_cv_sys_largefile_CC,
141 [ac_cv_sys_largefile_CC=no
142 if test "$GCC" != yes; then
145 # IRIX 6.2 and later do not support large files by default,
146 # so use the C compiler's -n32 option if that helps.
147 AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
148 AC_COMPILE_IFELSE([], [break])
150 AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
154 rm -f conftest.$ac_ext
156 if test "$ac_cv_sys_largefile_CC" != no; then
157 CC=$CC$ac_cv_sys_largefile_CC
160 _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
161 ac_cv_sys_file_offset_bits,
162 [Number of bits in a file offset, on hosts where this is settable.],
163 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
164 if test $ac_cv_sys_file_offset_bits = unknown; then
165 _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
166 ac_cv_sys_large_files,
167 [Define for large files, on AIX-style hosts.],
168 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
171 AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1],
172 [Enable large inode numbers on Mac OS X 10.5.])
177 # AC_SYS_LONG_FILE_NAMES
178 # ----------------------
179 # Security: use a temporary directory as the most portable way of
180 # creating files in /tmp securely. Removing them leaves a race
181 # condition, set -C is not portably guaranteed to use O_EXCL, so still
182 # leaves a race, and not all systems have the `mktemp' utility. We
183 # still test for existence first in case of broken systems where the
184 # mkdir succeeds even when the directory exists. Broken systems may
185 # retain a race, but they probably have other security problems
186 # anyway; this should be secure on well-behaved systems. In any case,
187 # use of `mktemp' is probably inappropriate here since it would fail in
188 # attempting to create different file names differing after the 14th
189 # character on file systems without long file names.
190 AC_DEFUN([AC_SYS_LONG_FILE_NAMES],
191 [AC_CACHE_CHECK(for long file names, ac_cv_sys_long_file_names,
192 [ac_cv_sys_long_file_names=yes
193 # Test for long file names in all the places we know might matter:
194 # . the current directory, where building will happen
195 # $prefix/lib where we will be installing things
196 # $exec_prefix/lib likewise
197 # $TMPDIR if set, where it might want to write temporary files
198 # /tmp where it might want to write temporary files
201 for ac_dir in . "$TMPDIR" /tmp /var/tmp /usr/tmp "$prefix/lib" "$exec_prefix/lib"; do
202 # Skip $TMPDIR if it is empty or bogus, and skip $exec_prefix/lib
203 # in the usual case where exec_prefix is '${prefix}'.
205 . | /* | ?:[[\\/]]*) ;; #(
208 test -w "$ac_dir/." || continue # It is less confusing to not echo anything here.
210 (umask 077 && mkdir "$ac_xdir" 2>/dev/null) || continue
211 ac_tf1=$ac_xdir/conftest9012345
212 ac_tf2=$ac_xdir/conftest9012346
213 touch "$ac_tf1" 2>/dev/null && test -f "$ac_tf1" && test ! -f "$ac_tf2" ||
214 ac_cv_sys_long_file_names=no
215 rm -f -r "$ac_xdir" 2>/dev/null
216 test $ac_cv_sys_long_file_names = no && break
218 if test $ac_cv_sys_long_file_names = yes; then
219 AC_DEFINE(HAVE_LONG_FILE_NAMES, 1,
220 [Define to 1 if you support file names longer than 14 characters.])
225 # AC_SYS_RESTARTABLE_SYSCALLS
226 # ---------------------------
227 # If the system automatically restarts a system call that is
228 # interrupted by a signal, define `HAVE_RESTARTABLE_SYSCALLS'.
229 AC_DEFUN([AC_SYS_RESTARTABLE_SYSCALLS],
230 [AC_DIAGNOSE([obsolete],
231 [$0: AC_SYS_RESTARTABLE_SYSCALLS is useful only when supporting very
232 old systems that lack `sigaction' and `SA_RESTART'. Don't bother with
233 this macro unless you need to support very old systems like 4.2BSD and
235 AC_REQUIRE([AC_HEADER_SYS_WAIT])dnl
236 AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
237 [AC_RUN_IFELSE([AC_LANG_SOURCE(
238 [/* Exit 0 (true) if wait returns something other than -1,
239 i.e. the pid of the child, which means that wait was restarted
240 after getting the signal. */
244 #ifdef HAVE_SYS_WAIT_H
245 # include <sys/wait.h>
248 /* Some platforms explicitly require an extern "C" signal handler
251 extern "C" void ucatch (int dummy) { }
253 void ucatch (dummy) int dummy; { }
259 int i = fork (), status;
264 kill (getppid (), SIGINT);
269 signal (SIGINT, ucatch);
277 [ac_cv_sys_restartable_syscalls=yes],
278 [ac_cv_sys_restartable_syscalls=no])])
279 if test $ac_cv_sys_restartable_syscalls = yes; then
280 AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS, 1,
281 [Define to 1 if system calls automatically restart after
282 interruption by a signal.])
284 ])# AC_SYS_RESTARTABLE_SYSCALLS
287 # AC_SYS_POSIX_TERMIOS
288 # --------------------
289 AC_DEFUN([AC_SYS_POSIX_TERMIOS],
290 [AC_CACHE_CHECK([POSIX termios], ac_cv_sys_posix_termios,
291 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
295 [/* SunOS 4.0.3 has termios.h but not the library calls. */
297 ac_cv_sys_posix_termios=yes,
298 ac_cv_sys_posix_termios=no)])
299 ])# AC_SYS_POSIX_TERMIOS
304 ## ------------------------------------ ##
305 ## Checks for not-quite-Unix variants. ##
306 ## ------------------------------------ ##
311 AU_DEFUN([AC_GNU_SOURCE], [AC_USE_SYSTEM_EXTENSIONS])
316 # Check for Cygwin. This is a way to set the right value for
318 AU_DEFUN([AC_CYGWIN],
321 *cygwin* ) CYGWIN=yes;;
324 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
325 matches *cygwin*])# AC_CYGWIN
330 # Check for EMX on OS/2. This is another way to set the right value
332 AU_DEFUN([AC_EMXOS2],
338 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
339 matches *emx*])# AC_EMXOS2
344 # Check for mingw32. This is another way to set the right value for
346 AU_DEFUN([AC_MINGW32],
349 *mingw32* ) MINGW32=yes;;
352 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
353 matches *mingw32*])# AC_MINGW32
356 # AC_USE_SYSTEM_EXTENSIONS
357 # ------------------------
358 # Enable extensions on systems that normally disable them,
359 # typically due to standards-conformance issues.
361 # Remember that #undef in AH_VERBATIM gets replaced with #define by
362 # AC_DEFINE. The goal here is to define all known feature-enabling
363 # macros, then, if reports of conflicts are made, disable macros that
364 # cause problems on some platforms (such as __EXTENSIONS__).
365 AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
366 [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
367 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
369 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
370 if test "$MINIX" = yes; then
371 AC_DEFINE([_POSIX_SOURCE], [1],
372 [Define to 1 if you need to in order for 'stat' and other
374 AC_DEFINE([_POSIX_1_SOURCE], [2],
375 [Define to 2 if the system does not provide POSIX.1 features
376 except with this defined.])
377 AC_DEFINE([_MINIX], [1],
378 [Define to 1 if on MINIX.])
379 AC_DEFINE([_NETBSD_SOURCE], [1],
380 [Define to 1 to make NetBSD features available. MINIX 3 needs this.])
383 dnl Use a different key than __EXTENSIONS__, as that name broke existing
384 dnl configure.ac when using autoheader 2.62.
385 AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
386 [/* Enable extensions on AIX 3, Interix. */
390 /* Enable general extensions on OS X. */
391 #ifndef _DARWIN_C_SOURCE
392 # undef _DARWIN_C_SOURCE
394 /* Enable GNU extensions on systems that have them. */
398 /* HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
399 regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1. */
401 # define _XOPEN_SOURCE 500
403 /* Enable threading extensions on Solaris. */
404 #ifndef _POSIX_PTHREAD_SEMANTICS
405 # undef _POSIX_PTHREAD_SEMANTICS
407 /* Enable extensions on HP NonStop. */
408 #ifndef _TANDEM_SOURCE
409 # undef _TANDEM_SOURCE
411 /* Enable general extensions on Solaris. */
412 #ifndef __EXTENSIONS__
413 # undef __EXTENSIONS__
416 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
417 [ac_cv_safe_to_define___extensions__],
420 # define __EXTENSIONS__ 1
421 ]AC_INCLUDES_DEFAULT])],
422 [ac_cv_safe_to_define___extensions__=yes],
423 [ac_cv_safe_to_define___extensions__=no])])
424 test $ac_cv_safe_to_define___extensions__ = yes &&
425 AC_DEFINE([__EXTENSIONS__])
426 AC_DEFINE([_ALL_SOURCE])
427 AC_DEFINE([_DARWIN_C_SOURCE])
428 AC_DEFINE([_GNU_SOURCE])
429 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
430 AC_DEFINE([_TANDEM_SOURCE])
431 ])# AC_USE_SYSTEM_EXTENSIONS
435 ## -------------------------- ##
436 ## Checks for UNIX variants. ##
437 ## -------------------------- ##
440 # These are kludges which should be replaced by a single POSIX check.
441 # They aren't cached, to discourage their use.
445 AU_DEFUN([AC_AIX], [AC_USE_SYSTEM_EXTENSIONS])
450 AU_DEFUN([AC_MINIX], [AC_USE_SYSTEM_EXTENSIONS])
455 AU_DEFUN([AC_ISC_POSIX], [AC_SEARCH_LIBS([strerror], [cposix])])
460 AU_DEFUN([AC_XENIX_DIR],
461 [AC_MSG_CHECKING([for Xenix])
463 [#if defined M_XENIX && ! defined M_UNIX
466 [AC_MSG_RESULT([yes]); XENIX=yes],
467 [AC_MSG_RESULT([no]); XENIX=])
469 AC_HEADER_DIRENT[]dnl
471 [You shouldn't need to depend upon XENIX. Remove the
472 `AC_MSG_CHECKING', `AC_EGREP_CPP', and this warning if this part
473 of the test is useless.])
478 AU_DEFUN([AC_DYNIX_SEQ], [AC_FUNC_GETMNTENT])
483 AU_DEFUN([AC_IRIX_SUN],
485 AC_CHECK_LIB([sun], [getpwnam])])
490 AU_DEFUN([AC_SCO_INTL], [AC_FUNC_STRFTIME])