1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Macros that test for specific, unclassified, features.
4 # Copyright (C) 1992-1996, 1998-2017, 2020-2022 Free Software
7 # This file is part of Autoconf. This program is free
8 # software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the
10 # Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # Under Section 7 of GPL version 3, you are granted additional
19 # permissions described in the Autoconf Configure Script Exception,
20 # version 3.0, as published by the Free Software Foundation.
22 # You should have received a copy of the GNU General Public License
23 # and a copy of the Autoconf Configure Script Exception along with
24 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
25 # respectively. If not, see <https://www.gnu.org/licenses/>.
27 # Written by David MacKenzie, with help from
28 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
29 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
32 ## ------------------------- ##
33 ## Checks for declarations. ##
34 ## ------------------------- ##
39 AN_IDENTIFIER([sys_siglist], [AC_CHECK_DECLS([sys_siglist])])
40 AU_DEFUN([AC_DECL_SYS_SIGLIST],
41 [AC_CHECK_DECLS([sys_siglist],,,
43 /* NetBSD declares sys_siglist in unistd.h. */
48 ])# AC_DECL_SYS_SIGLIST
53 ## -------------------------------------- ##
54 ## Checks for operating system services. ##
55 ## -------------------------------------- ##
60 AC_DEFUN([AC_SYS_INTERPRETER],
61 [AC_CACHE_CHECK(whether @%:@! works in shell scripts, ac_cv_sys_interpreter,
66 (SHELL=/bin/sh; export SHELL; ./conftest >/dev/null 2>&1)
67 if test $? -ne 69; then
68 ac_cv_sys_interpreter=yes
70 ac_cv_sys_interpreter=no
73 interpval=$ac_cv_sys_interpreter
77 AU_DEFUN([AC_HAVE_POUNDBANG],
79 [Remove this warning when you adjust your code to use
80 `AC_SYS_INTERPRETER'.])
83 AU_DEFUN([AC_ARG_ARRAY], [],
84 [$0 is no longer implemented: don't do unportable things
85 with arguments. Remove this warning when you adjust your code.])
88 # _AC_SYS_LARGEFILE_TEST_INCLUDES
89 # -------------------------------
90 m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
91 [@%:@include <sys/types.h>
92 /* Check that off_t can represent 2**63 - 1 correctly.
93 We can't simply define LARGE_OFF_T to be 9223372036854775807,
94 since some C++ compilers masquerading as C compilers
95 incorrectly reject 9223372036854775807. */
96 @%:@define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
97 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
98 && LARGE_OFF_T % 2147483647 == 1)
103 # _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
106 # PROLOGUE, [FUNCTION-BODY])
107 # --------------------------------------------------------
108 m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
109 [AC_CACHE_CHECK([for $1 value needed for large files], [$3],
111 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
112 [AC_LANG_PROGRAM([$5], [$6])],
114 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
115 [AC_LANG_PROGRAM([@%:@define $1 $2
123 *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
125 rm -rf conftest*[]dnl
126 ])# _AC_SYS_LARGEFILE_MACRO_VALUE
131 # By default, many hosts won't let programs access large files;
132 # one must use special compiler options to get large-file access to work.
133 # For more details about this brain damage please see:
134 # http://www.unix.org/version2/whatsnew/lfs20mar.html
135 # Additionally, on Linux file systems with 64-bit inodes a file that happens
136 # to have a 64-bit inode number cannot be accessed by 32-bit applications on
137 # Linux x86/x86_64. This can occur with file systems such as XFS and NFS.
138 AC_DEFUN([AC_SYS_LARGEFILE],
139 [AC_ARG_ENABLE(largefile,
140 [ --disable-largefile omit support for large files])
141 if test "$enable_largefile" != no; then
143 AC_CACHE_CHECK([for special C compiler options needed for large files],
144 ac_cv_sys_largefile_CC,
145 [ac_cv_sys_largefile_CC=no
146 if test "$GCC" != yes; then
149 # IRIX 6.2 and later do not support large files by default,
150 # so use the C compiler's -n32 option if that helps.
151 AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
152 AC_COMPILE_IFELSE([], [break])
154 AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
158 rm -f conftest.$ac_ext
160 if test "$ac_cv_sys_largefile_CC" != no; then
161 CC=$CC$ac_cv_sys_largefile_CC
164 _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
165 ac_cv_sys_file_offset_bits,
166 [Number of bits in a file offset, on hosts where this is settable.],
167 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
168 if test $ac_cv_sys_file_offset_bits = unknown; then
169 _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
170 ac_cv_sys_large_files,
171 [Define for large files, on AIX-style hosts.],
172 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
178 # AC_SYS_LONG_FILE_NAMES
179 # ----------------------
180 # Security: use a temporary directory as the most portable way of
181 # creating files in /tmp securely. Removing them leaves a race
182 # condition, set -C is not portably guaranteed to use O_EXCL, so still
183 # leaves a race, and not all systems have the 'mktemp' utility. We
184 # still test for existence first in case of broken systems where the
185 # mkdir succeeds even when the directory exists. Broken systems may
186 # retain a race, but they probably have other security problems
187 # anyway; this should be secure on well-behaved systems. In any case,
188 # use of 'mktemp' is probably inappropriate here since it would fail in
189 # attempting to create different file names differing after the 14th
190 # character on file systems without long file names.
191 AC_DEFUN([AC_SYS_LONG_FILE_NAMES],
192 [AC_CACHE_CHECK(for long file names, ac_cv_sys_long_file_names,
193 [ac_cv_sys_long_file_names=yes
194 # Test for long file names in all the places we know might matter:
195 # . the current directory, where building will happen
196 # $prefix/lib where we will be installing things
197 # $exec_prefix/lib likewise
198 # $TMPDIR if set, where it might want to write temporary files
199 # /tmp where it might want to write temporary files
202 for ac_dir in . "$TMPDIR" /tmp /var/tmp /usr/tmp "$prefix/lib" "$exec_prefix/lib"; do
203 # Skip $TMPDIR if it is empty or bogus, and skip $exec_prefix/lib
204 # in the usual case where exec_prefix is '${prefix}'.
206 . | /* | ?:[[\\/]]*) ;; #(
209 test -w "$ac_dir/." || continue # It is less confusing to not echo anything here.
211 (umask 077 && mkdir "$ac_xdir" 2>/dev/null) || continue
212 ac_tf1=$ac_xdir/conftest9012345
213 ac_tf2=$ac_xdir/conftest9012346
214 touch "$ac_tf1" 2>/dev/null && test -f "$ac_tf1" && test ! -f "$ac_tf2" ||
215 ac_cv_sys_long_file_names=no
216 rm -f -r "$ac_xdir" 2>/dev/null
217 test $ac_cv_sys_long_file_names = no && break
219 if test $ac_cv_sys_long_file_names = yes; then
220 AC_DEFINE(HAVE_LONG_FILE_NAMES, 1,
221 [Define to 1 if you support file names longer than 14 characters.])
226 # AC_SYS_RESTARTABLE_SYSCALLS
227 # ---------------------------
228 # If the system automatically restarts a system call that is
229 # interrupted by a signal, define 'HAVE_RESTARTABLE_SYSCALLS'.
230 AC_DEFUN([AC_SYS_RESTARTABLE_SYSCALLS],
232 [$0: AC_SYS_RESTARTABLE_SYSCALLS is useful only when supporting very
233 old systems that lack 'sigaction' and 'SA_RESTART'. Don't bother with
234 this macro unless you need to support very old systems like 4.2BSD and
236 AC_REQUIRE([AC_HEADER_SYS_WAIT])dnl
237 AC_CACHE_CHECK(for restartable system calls, ac_cv_sys_restartable_syscalls,
238 [AC_RUN_IFELSE([AC_LANG_SOURCE(
239 [/* Exit 0 (true) if wait returns something other than -1,
240 i.e. the pid of the child, which means that wait was restarted
241 after getting the signal. */
245 #ifdef HAVE_SYS_WAIT_H
246 # include <sys/wait.h>
249 /* Some platforms explicitly require an extern "C" signal handler
252 extern "C" void ucatch (int dummy) { }
254 void ucatch (dummy) int dummy; { }
260 int i = fork (), status;
265 kill (getppid (), SIGINT);
270 signal (SIGINT, ucatch);
278 [ac_cv_sys_restartable_syscalls=yes],
279 [ac_cv_sys_restartable_syscalls=no])])
280 if test $ac_cv_sys_restartable_syscalls = yes; then
281 AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS, 1,
282 [Define to 1 if system calls automatically restart after
283 interruption by a signal.])
285 ])# AC_SYS_RESTARTABLE_SYSCALLS
288 # AC_SYS_POSIX_TERMIOS
289 # --------------------
290 AC_DEFUN([AC_SYS_POSIX_TERMIOS],
291 [AC_CACHE_CHECK([POSIX termios], ac_cv_sys_posix_termios,
292 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
296 [/* SunOS 4.0.3 has termios.h but not the library calls. */
298 ac_cv_sys_posix_termios=yes,
299 ac_cv_sys_posix_termios=no)])
300 ])# AC_SYS_POSIX_TERMIOS
305 ## ------------------------------------ ##
306 ## Checks for not-quite-Unix variants. ##
307 ## ------------------------------------ ##
312 AU_DEFUN([AC_GNU_SOURCE], [AC_USE_SYSTEM_EXTENSIONS])
317 # Check for Cygwin. This is a way to set the right value for
319 AU_DEFUN([AC_CYGWIN],
322 *cygwin* ) CYGWIN=yes;;
325 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
326 matches *cygwin*])# AC_CYGWIN
331 # Check for EMX on OS/2. This is another way to set the right value
333 AU_DEFUN([AC_EMXOS2],
339 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
340 matches *emx*])# AC_EMXOS2
345 # Check for mingw32. This is another way to set the right value for
347 AU_DEFUN([AC_MINGW32],
350 *mingw32* ) MINGW32=yes;;
353 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
354 matches *mingw32*])# AC_MINGW32
357 # AC_USE_SYSTEM_EXTENSIONS
358 # ------------------------
359 # Enable extensions on systems that normally disable them,
360 # typically due to standards-conformance issues.
361 # We unconditionally define as many of the known feature-enabling
362 # as possible, reserving conditional behavior for macros that are
363 # known to cause problems on some platforms (such as __EXTENSIONS__).
364 AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
365 [AC_BEFORE([$0], [AC_PREPROC_IFELSE])dnl
366 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
367 AC_BEFORE([$0], [AC_LINK_IFELSE])dnl
368 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
369 AC_BEFORE([$0], [AC_CHECK_INCLUDES_DEFAULT])dnl
370 dnl #undef in AH_VERBATIM gets replaced with #define by AC_DEFINE.
371 dnl Use a different key than __EXTENSIONS__, as that name broke existing
372 dnl configure.ac when using autoheader 2.62.
373 dnl The macros below are in alphabetical order ignoring leading _ or __
375 AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
376 [/* Enable extensions on AIX 3, Interix. */
380 /* Enable general extensions on macOS. */
381 #ifndef _DARWIN_C_SOURCE
382 # undef _DARWIN_C_SOURCE
384 /* Enable general extensions on Solaris. */
385 #ifndef __EXTENSIONS__
386 # undef __EXTENSIONS__
388 /* Enable GNU extensions on systems that have them. */
392 /* Enable X/Open compliant socket functions that do not require linking
393 with -lxnet on HP-UX 11.11. */
394 #ifndef _HPUX_ALT_XOPEN_SOCKET_API
395 # undef _HPUX_ALT_XOPEN_SOCKET_API
397 /* Identify the host operating system as Minix.
398 This macro does not affect the system headers' behavior.
399 A future release of Autoconf may stop defining this macro. */
403 /* Enable general extensions on NetBSD.
404 Enable NetBSD compatibility extensions on Minix. */
405 #ifndef _NETBSD_SOURCE
406 # undef _NETBSD_SOURCE
408 /* Enable OpenBSD compatibility extensions on NetBSD.
409 Oddly enough, this does nothing on OpenBSD. */
410 #ifndef _OPENBSD_SOURCE
411 # undef _OPENBSD_SOURCE
413 /* Define to 1 if needed for POSIX-compatible behavior. */
414 #ifndef _POSIX_SOURCE
415 # undef _POSIX_SOURCE
417 /* Define to 2 if needed for POSIX-compatible behavior. */
418 #ifndef _POSIX_1_SOURCE
419 # undef _POSIX_1_SOURCE
421 /* Enable POSIX-compatible threading on Solaris. */
422 #ifndef _POSIX_PTHREAD_SEMANTICS
423 # undef _POSIX_PTHREAD_SEMANTICS
425 /* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
426 #ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
427 # undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
429 /* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
430 #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
431 # undef __STDC_WANT_IEC_60559_BFP_EXT__
433 /* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
434 #ifndef __STDC_WANT_IEC_60559_DFP_EXT__
435 # undef __STDC_WANT_IEC_60559_DFP_EXT__
437 /* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
438 #ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
439 # undef __STDC_WANT_IEC_60559_FUNCS_EXT__
441 /* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
442 #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
443 # undef __STDC_WANT_IEC_60559_TYPES_EXT__
445 /* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
446 #ifndef __STDC_WANT_LIB_EXT2__
447 # undef __STDC_WANT_LIB_EXT2__
449 /* Enable extensions specified by ISO/IEC 24747:2009. */
450 #ifndef __STDC_WANT_MATH_SPEC_FUNCS__
451 # undef __STDC_WANT_MATH_SPEC_FUNCS__
453 /* Enable extensions on HP NonStop. */
454 #ifndef _TANDEM_SOURCE
455 # undef _TANDEM_SOURCE
457 /* Enable X/Open extensions. Define to 500 only if necessary
458 to make mbstate_t available. */
459 #ifndef _XOPEN_SOURCE
460 # undef _XOPEN_SOURCE
464 AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])dnl
465 _AC_CHECK_HEADER_ONCE([wchar.h])
466 _AC_CHECK_HEADER_ONCE([minix/config.h])
468 dnl Defining __EXTENSIONS__ may break the system headers on some systems.
469 dnl (FIXME: Which ones?)
470 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
471 [ac_cv_safe_to_define___extensions__],
474 # define __EXTENSIONS__ 1
475 ]AC_INCLUDES_DEFAULT])],
476 [ac_cv_safe_to_define___extensions__=yes],
477 [ac_cv_safe_to_define___extensions__=no])])
479 dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to
480 dnl 500, regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1.
481 dnl But defining _XOPEN_SOURCE may turn *off* extensions on platforms
482 dnl not covered by turn-on-extensions macros (notably Dragonfly, Free,
483 dnl and OpenBSD, which don't have any equivalent of _NETBSD_SOURCE) so
484 dnl it should only be defined when necessary.
485 AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
486 [ac_cv_should_define__xopen_source],
487 [ac_cv_should_define__xopen_source=no
488 AS_IF([test $ac_cv_header_wchar_h = yes],
496 #define _XOPEN_SOURCE 500
499 [ac_cv_should_define__xopen_source=yes])])])])
501 AC_DEFINE([_ALL_SOURCE])
502 AC_DEFINE([_DARWIN_C_SOURCE])
503 AC_DEFINE([_GNU_SOURCE])
504 AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API])
505 AC_DEFINE([_NETBSD_SOURCE])
506 AC_DEFINE([_OPENBSD_SOURCE])
507 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
508 AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])
509 AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__])
510 AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__])
511 AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__])
512 AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__])
513 AC_DEFINE([__STDC_WANT_LIB_EXT2__])
514 AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__])
515 AC_DEFINE([_TANDEM_SOURCE])
516 AS_IF([test $ac_cv_header_minix_config_h = yes],
519 AC_DEFINE([_POSIX_SOURCE])
520 AC_DEFINE([_POSIX_1_SOURCE], [2])],
522 AS_IF([test $ac_cv_safe_to_define___extensions__ = yes],
523 [AC_DEFINE([__EXTENSIONS__])])
524 AS_IF([test $ac_cv_should_define__xopen_source = yes],
525 [AC_DEFINE([_XOPEN_SOURCE], [500])])
526 ])# AC_USE_SYSTEM_EXTENSIONS
530 ## -------------------------- ##
531 ## Checks for UNIX variants. ##
532 ## -------------------------- ##
535 # These are kludges which should be replaced by a single POSIX check.
536 # They aren't cached, to discourage their use.
540 AU_DEFUN([AC_AIX], [AC_USE_SYSTEM_EXTENSIONS])
545 AU_DEFUN([AC_MINIX], [AC_USE_SYSTEM_EXTENSIONS])
550 AU_DEFUN([AC_ISC_POSIX], [AC_SEARCH_LIBS([strerror], [cposix])])
555 AU_DEFUN([AC_XENIX_DIR],
556 [AC_MSG_CHECKING([for Xenix])
558 [#if defined M_XENIX && ! defined M_UNIX
561 [AC_MSG_RESULT([yes]); XENIX=yes],
562 [AC_MSG_RESULT([no]); XENIX=])
564 AC_HEADER_DIRENT[]dnl
566 [You shouldn't need to depend upon XENIX. Remove the
567 'AC_MSG_CHECKING', 'AC_EGREP_CPP', and this warning if this part
568 of the test is useless.])
573 AU_DEFUN([AC_DYNIX_SEQ], [AC_FUNC_GETMNTENT])
578 AU_DEFUN([AC_IRIX_SUN],
580 AC_CHECK_LIB([sun], [getpwnam])])
585 AU_DEFUN([AC_SCO_INTL], [AC_FUNC_STRFTIME])