maint: update URLs
[autoconf.git] / lib / autoconf / specific.m4
blob99cc6044648651de3d444cfae9c80c5a3f75b2ed
1 # This file is part of Autoconf.                        -*- Autoconf -*-
2 # Macros that test for specific, unclassified, features.
4 # Copyright (C) 1992-1996, 1998-2017 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 <https://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 ## ------------------------- ##
36 # AC_DECL_SYS_SIGLIST
37 # -------------------
38 AN_IDENTIFIER([sys_siglist],     [AC_CHECK_DECLS([sys_siglist])])
39 AU_DEFUN([AC_DECL_SYS_SIGLIST],
40 [AC_CHECK_DECLS([sys_siglist],,,
41 [#include <signal.h>
42 /* NetBSD declares sys_siglist in unistd.h.  */
43 #ifdef HAVE_UNISTD_H
44 # include <unistd.h>
45 #endif
47 ])# AC_DECL_SYS_SIGLIST
52 ## -------------------------------------- ##
53 ## Checks for operating system services.  ##
54 ## -------------------------------------- ##
57 # AC_SYS_INTERPRETER
58 # ------------------
59 AC_DEFUN([AC_SYS_INTERPRETER],
60 [AC_CACHE_CHECK(whether @%:@! works in shell scripts, ac_cv_sys_interpreter,
61 [echo '#! /bin/cat
62 exit 69
63 ' >conftest
64 chmod u+x conftest
65 (SHELL=/bin/sh; export SHELL; ./conftest >/dev/null 2>&1)
66 if test $? -ne 69; then
67    ac_cv_sys_interpreter=yes
68 else
69    ac_cv_sys_interpreter=no
71 rm -f conftest])
72 interpval=$ac_cv_sys_interpreter
76 AU_DEFUN([AC_HAVE_POUNDBANG],
77 [AC_SYS_INTERPRETER],
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)
98                       ? 1 : -1]];[]dnl
102 # _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
103 #                               CACHE-VAR,
104 #                               DESCRIPTION,
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],
109 [while :; do
110   m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
111     [AC_LANG_PROGRAM([$5], [$6])],
112     [$3=no; break])
113   m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
114     [AC_LANG_PROGRAM([@%:@define $1 $2
115 $5], [$6])],
116     [$3=$2; break])
117   $3=unknown
118   break
119 done])
120 case $$3 in #(
121   no | unknown) ;;
122   *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
123 esac
124 rm -rf conftest*[]dnl
125 ])# _AC_SYS_LARGEFILE_MACRO_VALUE
128 # AC_SYS_LARGEFILE
129 # ----------------
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.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
143        ac_save_CC=$CC
144        while :; do
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])
149          CC="$CC -n32"
150          AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
151          break
152        done
153        CC=$ac_save_CC
154        rm -f conftest.$ac_ext
155     fi])
156   if test "$ac_cv_sys_largefile_CC" != no; then
157     CC=$CC$ac_cv_sys_largefile_CC
158   fi
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])
169   fi
171   AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1],
172     [Enable large inode numbers on Mac OS X 10.5.])
174 ])# AC_SYS_LARGEFILE
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
199 #      /var/tmp         likewise
200 #      /usr/tmp         likewise
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}'.
204   case $ac_dir in #(
205     . | /* | ?:[[\\/]]*) ;; #(
206     *) continue;;
207   esac
208   test -w "$ac_dir/." || continue # It is less confusing to not echo anything here.
209   ac_xdir=$ac_dir/cf$$
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
217 done])
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
234 SVR3.])dnl
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.  */
242 AC_INCLUDES_DEFAULT
243 #include <signal.h>
244 #ifdef HAVE_SYS_WAIT_H
245 # include <sys/wait.h>
246 #endif
248 /* Some platforms explicitly require an extern "C" signal handler
249    when using C++. */
250 #ifdef __cplusplus
251 extern "C" void ucatch (int dummy) { }
252 #else
253 void ucatch (dummy) int dummy; { }
254 #endif
257 main (void)
259   int i = fork (), status;
261   if (i == 0)
262     {
263       sleep (3);
264       kill (getppid (), SIGINT);
265       sleep (3);
266       return 0;
267     }
269   signal (SIGINT, ucatch);
271   status = wait (&i);
272   if (status == -1)
273     wait (&i);
275   return status == -1;
276 }])],
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>
292 #include <unistd.h>
293 #include <termios.h>
295              [/* SunOS 4.0.3 has termios.h but not the library calls.  */
296    tcgetattr(0, 0);])],
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 ## ------------------------------------ ##
309 # AC_GNU_SOURCE
310 # -------------
311 AU_DEFUN([AC_GNU_SOURCE], [AC_USE_SYSTEM_EXTENSIONS])
314 # AC_CYGWIN
315 # ---------
316 # Check for Cygwin.  This is a way to set the right value for
317 # EXEEXT.
318 AU_DEFUN([AC_CYGWIN],
319 [AC_CANONICAL_HOST
320 case $host_os in
321   *cygwin* ) CYGWIN=yes;;
322          * ) CYGWIN=no;;
323 esac
324 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
325 matches *cygwin*])# AC_CYGWIN
328 # AC_EMXOS2
329 # ---------
330 # Check for EMX on OS/2.  This is another way to set the right value
331 # for EXEEXT.
332 AU_DEFUN([AC_EMXOS2],
333 [AC_CANONICAL_HOST
334 case $host_os in
335   *emx* ) EMXOS2=yes;;
336       * ) EMXOS2=no;;
337 esac
338 ], [$0 is obsolete: use AC_CANONICAL_HOST and check if $host_os
339 matches *emx*])# AC_EMXOS2
342 # AC_MINGW32
343 # ----------
344 # Check for mingw32.  This is another way to set the right value for
345 # EXEEXT.
346 AU_DEFUN([AC_MINGW32],
347 [AC_CANONICAL_HOST
348 case $host_os in
349   *mingw32* ) MINGW32=yes;;
350           * ) MINGW32=no;;
351 esac
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
373        things to work.])
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.])
381   fi
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.  */
387 #ifndef _ALL_SOURCE
388 # undef _ALL_SOURCE
389 #endif
390 /* Enable general extensions on macOS.  */
391 #ifndef _DARWIN_C_SOURCE
392 # undef _DARWIN_C_SOURCE
393 #endif
394 /* Enable GNU extensions on systems that have them.  */
395 #ifndef _GNU_SOURCE
396 # undef _GNU_SOURCE
397 #endif
398 /* Enable threading extensions on Solaris.  */
399 #ifndef _POSIX_PTHREAD_SEMANTICS
400 # undef _POSIX_PTHREAD_SEMANTICS
401 #endif
402 /* Enable extensions specified by ISO/IEC TS 18661-5:2014.  */
403 #ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
404 # undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
405 #endif
406 /* Enable extensions specified by ISO/IEC TS 18661-1:2014.  */
407 #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
408 # undef __STDC_WANT_IEC_60559_BFP_EXT__
409 #endif
410 /* Enable extensions specified by ISO/IEC TS 18661-2:2015.  */
411 #ifndef __STDC_WANT_IEC_60559_DFP_EXT__
412 # undef __STDC_WANT_IEC_60559_DFP_EXT__
413 #endif
414 /* Enable extensions specified by ISO/IEC TS 18661-4:2015.  */
415 #ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
416 # undef __STDC_WANT_IEC_60559_FUNCS_EXT__
417 #endif
418 /* Enable extensions specified by ISO/IEC TS 18661-3:2015.  */
419 #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
420 # undef __STDC_WANT_IEC_60559_TYPES_EXT__
421 #endif
422 /* Enable extensions specified by ISO/IEC TR 24731-2:2010.  */
423 #ifndef __STDC_WANT_LIB_EXT2__
424 # undef __STDC_WANT_LIB_EXT2__
425 #endif
426 /* Enable extensions specified by ISO/IEC 24747:2009.  */
427 #ifndef __STDC_WANT_MATH_SPEC_FUNCS__
428 # undef __STDC_WANT_MATH_SPEC_FUNCS__
429 #endif
430 /* Enable extensions on HP NonStop.  */
431 #ifndef _TANDEM_SOURCE
432 # undef _TANDEM_SOURCE
433 #endif
434 /* Enable X/Open extensions if necessary.  HP-UX 11.11 defines
435    mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of
436    whether compiling with -Ae or -D_HPUX_SOURCE=1.  */
437 #ifndef _XOPEN_SOURCE
438 # undef _XOPEN_SOURCE
439 #endif
440 /* Enable general extensions on Solaris.  */
441 #ifndef __EXTENSIONS__
442 # undef __EXTENSIONS__
443 #endif
445   AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
446     [ac_cv_safe_to_define___extensions__],
447     [AC_COMPILE_IFELSE(
448        [AC_LANG_PROGRAM([[
449 #         define __EXTENSIONS__ 1
450           ]AC_INCLUDES_DEFAULT])],
451        [ac_cv_safe_to_define___extensions__=yes],
452        [ac_cv_safe_to_define___extensions__=no])])
453   test $ac_cv_safe_to_define___extensions__ = yes &&
454     AC_DEFINE([__EXTENSIONS__])
455   AC_DEFINE([_ALL_SOURCE])
456   AC_DEFINE([_DARWIN_C_SOURCE])
457   AC_DEFINE([_GNU_SOURCE])
458   AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
459   AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])
460   AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__])
461   AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__])
462   AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__])
463   AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__])
464   AC_DEFINE([__STDC_WANT_LIB_EXT2__])
465   AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__])
466   AC_DEFINE([_TANDEM_SOURCE])
467   AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
468     [ac_cv_should_define__xopen_source],
469     [ac_cv_should_define__xopen_source=no
470      AC_COMPILE_IFELSE(
471        [AC_LANG_PROGRAM([[
472           #include <wchar.h>
473           mbstate_t x;]])],
474        [],
475        [AC_COMPILE_IFELSE(
476           [AC_LANG_PROGRAM([[
477              #define _XOPEN_SOURCE 500
478              #include <wchar.h>
479              mbstate_t x;]])],
480           [ac_cv_should_define__xopen_source=yes])])])
481   test $ac_cv_should_define__xopen_source = yes &&
482     AC_DEFINE([_XOPEN_SOURCE], [500])
483 ])# AC_USE_SYSTEM_EXTENSIONS
487 ## -------------------------- ##
488 ## Checks for UNIX variants.  ##
489 ## -------------------------- ##
492 # These are kludges which should be replaced by a single POSIX check.
493 # They aren't cached, to discourage their use.
495 # AC_AIX
496 # ------
497 AU_DEFUN([AC_AIX], [AC_USE_SYSTEM_EXTENSIONS])
500 # AC_MINIX
501 # --------
502 AU_DEFUN([AC_MINIX], [AC_USE_SYSTEM_EXTENSIONS])
505 # AC_ISC_POSIX
506 # ------------
507 AU_DEFUN([AC_ISC_POSIX], [AC_SEARCH_LIBS([strerror], [cposix])])
510 # AC_XENIX_DIR
511 # ------------
512 AU_DEFUN([AC_XENIX_DIR],
513 [AC_MSG_CHECKING([for Xenix])
514 AC_EGREP_CPP([yes],
515 [#if defined M_XENIX && ! defined M_UNIX
516   yes
517 @%:@endif],
518              [AC_MSG_RESULT([yes]); XENIX=yes],
519              [AC_MSG_RESULT([no]); XENIX=])
521 AC_HEADER_DIRENT[]dnl
523 [You shouldn't need to depend upon XENIX.  Remove the
524 `AC_MSG_CHECKING', `AC_EGREP_CPP', and this warning if this part
525 of the test is useless.])
528 # AC_DYNIX_SEQ
529 # ------------
530 AU_DEFUN([AC_DYNIX_SEQ], [AC_FUNC_GETMNTENT])
533 # AC_IRIX_SUN
534 # -----------
535 AU_DEFUN([AC_IRIX_SUN],
536 [AC_FUNC_GETMNTENT
537 AC_CHECK_LIB([sun], [getpwnam])])
540 # AC_SCO_INTL
541 # -----------
542 AU_DEFUN([AC_SCO_INTL], [AC_FUNC_STRFTIME])