autoconf: Particular Functions

1 
1 5.5.2 Particular Function Checks
1 --------------------------------
1 
1 These macros check for particular C functions--whether they exist, and
1 in some cases how they respond when given certain arguments.
1 
1  -- Macro: AC_FUNC_ALLOCA
1      Check how to get `alloca'.  Tries to get a builtin version by
1      checking for `alloca.h' or the predefined C preprocessor macros
1      `__GNUC__' and `_AIX'.  If this macro finds `alloca.h', it defines
1      `HAVE_ALLOCA_H'.
1 
1      If those attempts fail, it looks for the function in the standard C
1      library.  If any of those methods succeed, it defines
1      `HAVE_ALLOCA'.  Otherwise, it sets the output variable `ALLOCA' to
1      `${LIBOBJDIR}alloca.o' and defines `C_ALLOCA' (so programs can
1      periodically call `alloca (0)' to garbage collect).  This variable
1      is separate from `LIBOBJS' so multiple programs can share the
1      value of `ALLOCA' without needing to create an actual library, in
1      case only some of them use the code in `LIBOBJS'.  The
1      `${LIBOBJDIR}' prefix serves the same purpose as in `LIBOBJS'
1      (⇒AC_LIBOBJ vs LIBOBJS).
1 
1      This macro does not try to get `alloca' from the System V R3
1      `libPW' or the System V R4 `libucb' because those libraries
1      contain some incompatible functions that cause trouble.  Some
1      versions do not even contain `alloca' or contain a buggy version.
1      If you still want to use their `alloca', use `ar' to extract
1      `alloca.o' from them instead of compiling `alloca.c'.
1 
1      Source files that use `alloca' should start with a piece of code
1      like the following, to declare it properly.
1 
1           #ifdef STDC_HEADERS
1           # include <stdlib.h>
1           # include <stddef.h>
1           #else
1           # ifdef HAVE_STDLIB_H
1           #  include <stdlib.h>
1           # endif
1           #endif
1           #ifdef HAVE_ALLOCA_H
1           # include <alloca.h>
1           #elif !defined alloca
1           # ifdef __GNUC__
1           #  define alloca __builtin_alloca
1           # elif defined _AIX
1           #  define alloca __alloca
1           # elif defined _MSC_VER
1           #  include <malloc.h>
1           #  define alloca _alloca
1           # elif !defined HAVE_ALLOCA
1           #  ifdef  __cplusplus
1           extern "C"
1           #  endif
1           void *alloca (size_t);
1           # endif
1           #endif
1 
1  -- Macro: AC_FUNC_CHOWN
1      If the `chown' function is available and works (in particular, it
1      should accept `-1' for `uid' and `gid'), define `HAVE_CHOWN'.  The
1      result of this macro is cached in the `ac_cv_func_chown_works'
1      variable.
1 
1  -- Macro: AC_FUNC_CLOSEDIR_VOID
1      If the `closedir' function does not return a meaningful value,
1      define `CLOSEDIR_VOID'.  Otherwise, callers ought to check its
1      return value for an error indicator.
1 
1      Currently this test is implemented by running a test program.  When
1      cross compiling the pessimistic assumption that `closedir' does not
1      return a meaningful value is made.
1 
1      The result of this macro is cached in the
1      `ac_cv_func_closedir_void' variable.
1 
1      This macro is obsolescent, as `closedir' returns a meaningful value
1      on current systems.  New programs need not use this macro.
1 
1  -- Macro: AC_FUNC_ERROR_AT_LINE
1      If the `error_at_line' function is not found, require an
1      `AC_LIBOBJ' replacement of `error'.
1 
1      The result of this macro is cached in the `ac_cv_lib_error_at_line'
1      variable.
1 
1      The `AC_FUNC_ERROR_AT_LINE' macro is obsolescent.  New programs
1      should use Gnulib's `error' module.  ⇒Gnulib.
1 
1  -- Macro: AC_FUNC_FNMATCH
1      If the `fnmatch' function conforms to Posix, define
1      `HAVE_FNMATCH'.  Detect common implementation bugs, for example,
1      the bugs in Solaris 2.4.
1 
1      Unlike the other specific `AC_FUNC' macros, `AC_FUNC_FNMATCH' does
1      not replace a broken/missing `fnmatch'.  This is for historical
1      reasons.  See `AC_REPLACE_FNMATCH' below.
1 
1      The result of this macro is cached in the
1      `ac_cv_func_fnmatch_works' variable.
1 
1      This macro is obsolescent.  New programs should use Gnulib's
1      `fnmatch-posix' module.  ⇒Gnulib.
1 
1  -- Macro: AC_FUNC_FNMATCH_GNU
1      Behave like `AC_REPLACE_FNMATCH' (_replace_) but also test whether
1      `fnmatch' supports GNU extensions.  Detect common implementation
1      bugs, for example, the bugs in the GNU C Library 2.1.
1 
1      The result of this macro is cached in the `ac_cv_func_fnmatch_gnu'
1      variable.
1 
1      This macro is obsolescent.  New programs should use Gnulib's
1      `fnmatch-gnu' module.  ⇒Gnulib.
1 
1  -- Macro: AC_FUNC_FORK
1      This macro checks for the `fork' and `vfork' functions.  If a
1      working `fork' is found, define `HAVE_WORKING_FORK'.  This macro
1      checks whether `fork' is just a stub by trying to run it.
1 
1      If `vfork.h' is found, define `HAVE_VFORK_H'.  If a working
1      `vfork' is found, define `HAVE_WORKING_VFORK'.  Otherwise, define
1      `vfork' to be `fork' for backward compatibility with previous
1      versions of `autoconf'.  This macro checks for several known
1      errors in implementations of `vfork' and considers the system to
1      not have a working `vfork' if it detects any of them.  It is not
1      considered to be an implementation error if a child's invocation
1      of `signal' modifies the parent's signal handler, since child
1      processes rarely change their signal handlers.
1 
1      Since this macro defines `vfork' only for backward compatibility
1      with previous versions of `autoconf' you're encouraged to define it
1      yourself in new code:
1           #ifndef HAVE_WORKING_VFORK
1           # define vfork fork
1           #endif
1 
1      The results of this macro are cached in the `ac_cv_func_fork_works'
1      and `ac_cv_func_vfork_works' variables.  In order to override the
1      test, you also need to set the `ac_cv_func_fork' and
1      `ac_cv_func_vfork' variables.
1 
1  -- Macro: AC_FUNC_FSEEKO
1      If the `fseeko' function is available, define `HAVE_FSEEKO'.
1      Define `_LARGEFILE_SOURCE' if necessary to make the prototype
1      visible on some systems (e.g., glibc 2.2).  Otherwise linkage
1      problems may occur when compiling with `AC_SYS_LARGEFILE' on
1      largefile-sensitive systems where `off_t' does not default to a
1      64bit entity.  All systems with `fseeko' also supply `ftello'.
1 
1  -- Macro: AC_FUNC_GETGROUPS
1      If the `getgroups' function is available and works (unlike on
1      Ultrix 4.3, where `getgroups (0, 0)' always fails), define
1      `HAVE_GETGROUPS'.  Set `GETGROUPS_LIBS' to any libraries needed to
1      get that function.  This macro runs `AC_TYPE_GETGROUPS'.
1 
1  -- Macro: AC_FUNC_GETLOADAVG
1      Check how to get the system load averages.  To perform its tests
1      properly, this macro needs the file `getloadavg.c'; therefore, be
1      sure to set the `AC_LIBOBJ' replacement directory properly (see
1      ⇒Generic Functions, `AC_CONFIG_LIBOBJ_DIR').
1 
1      If the system has the `getloadavg' function, define
1      `HAVE_GETLOADAVG', and set `GETLOADAVG_LIBS' to any libraries
1      necessary to get that function.  Also add `GETLOADAVG_LIBS' to
1      `LIBS'.  Otherwise, require an `AC_LIBOBJ' replacement for
1      `getloadavg' with source code in `DIR/getloadavg.c', and possibly
1      define several other C preprocessor macros and output variables:
1 
1        1. Define `C_GETLOADAVG'.
1 
1        2. Define `SVR4', `DGUX', `UMAX', or `UMAX4_3' if on those
1           systems.
1 
1        3. If `nlist.h' is found, define `HAVE_NLIST_H'.
1 
1        4. If `struct nlist' has an `n_un.n_name' member, define
1           `HAVE_STRUCT_NLIST_N_UN_N_NAME'.  The obsolete symbol
1           `NLIST_NAME_UNION' is still defined, but do not depend upon
1           it.
1 
1        5. Programs may need to be installed set-group-ID (or
1           set-user-ID) for `getloadavg' to work.  In this case, define
1           `GETLOADAVG_PRIVILEGED', set the output variable `NEED_SETGID'
1           to `true' (and otherwise to `false'), and set `KMEM_GROUP' to
1           the name of the group that should own the installed program.
1 
1      The `AC_FUNC_GETLOADAVG' macro is obsolescent.  New programs should
1      use Gnulib's `getloadavg' module.  ⇒Gnulib.
1 
1  -- Macro: AC_FUNC_GETMNTENT
1      Check for `getmntent' in the standard C library, and then in the
1      `sun', `seq', and `gen' libraries, for UNICOS, IRIX 4, PTX, and
1      UnixWare, respectively.  Then, if `getmntent' is available, define
1      `HAVE_GETMNTENT' and set `ac_cv_func_getmntent' to `yes'.
1      Otherwise set `ac_cv_func_getmntent' to `no'.
1 
1      The result of this macro can be overridden by setting the cache
1      variable `ac_cv_search_getmntent'.
1 
1  -- Macro: AC_FUNC_GETPGRP
1      Define `GETPGRP_VOID' if it is an error to pass 0 to `getpgrp';
1      this is the Posix behavior.  On older BSD systems, you must pass 0
1      to `getpgrp', as it takes an argument and behaves like Posix's
1      `getpgid'.
1 
1           #ifdef GETPGRP_VOID
1             pid = getpgrp ();
1           #else
1             pid = getpgrp (0);
1           #endif
1 
1      This macro does not check whether `getpgrp' exists at all; if you
1      need to work in that situation, first call `AC_CHECK_FUNC' for
1      `getpgrp'.
1 
1      The result of this macro is cached in the `ac_cv_func_getpgrp_void'
1      variable.
1 
1      This macro is obsolescent, as current systems have a `getpgrp'
1      whose signature conforms to Posix.  New programs need not use this
1      macro.
1 
1  -- Macro: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
1      If `link' is a symbolic link, then `lstat' should treat `link/'
1      the same as `link/.'.  However, many older `lstat' implementations
1      incorrectly ignore trailing slashes.
1 
1      It is safe to assume that if `lstat' incorrectly ignores trailing
1      slashes, then other symbolic-link-aware functions like `unlink'
1      also incorrectly ignore trailing slashes.
1 
1      If `lstat' behaves properly, define
1      `LSTAT_FOLLOWS_SLASHED_SYMLINK', otherwise require an `AC_LIBOBJ'
1      replacement of `lstat'.
1 
1      The result of this macro is cached in the
1      `ac_cv_func_lstat_dereferences_slashed_symlink' variable.
1 
1      The `AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' macro is obsolescent.
1      New programs should use Gnulib's `lstat' module.  ⇒Gnulib.
1 
1  -- Macro: AC_FUNC_MALLOC
1      If the `malloc' function is compatible with the GNU C library
1      `malloc' (i.e., `malloc (0)' returns a valid pointer), define
1      `HAVE_MALLOC' to 1.  Otherwise define `HAVE_MALLOC' to 0, ask for
1      an `AC_LIBOBJ' replacement for `malloc', and define `malloc' to
1      `rpl_malloc' so that the native `malloc' is not used in the main
1      project.
1 
1      Typically, the replacement file `malloc.c' should look like (note
1      the `#undef malloc'):
1 
1      #include <config.h>
1      #undef malloc
1 
1      #include <sys/types.h>
1 
1      void *malloc ();
1 
1      /* Allocate an N-byte block of memory from the heap.
1         If N is zero, allocate a 1-byte block.  */
1 
1      void *
1      rpl_malloc (size_t n)
1      {
1        if (n == 0)
1          n = 1;
1        return malloc (n);
1      }
1 
1      The result of this macro is cached in the
1      `ac_cv_func_malloc_0_nonnull' variable.
1 
1  -- Macro: AC_FUNC_MBRTOWC
1      Define `HAVE_MBRTOWC' to 1 if the function `mbrtowc' and the type
1      `mbstate_t' are properly declared.
1 
1      The result of this macro is cached in the `ac_cv_func_mbrtowc'
1      variable.
1 
1  -- Macro: AC_FUNC_MEMCMP
1      If the `memcmp' function is not available, or does not work on
1      8-bit data (like the one on SunOS 4.1.3), or fails when comparing
1      16 bytes or more and with at least one buffer not starting on a
1      4-byte boundary (such as the one on NeXT x86 OpenStep), require an
1      `AC_LIBOBJ' replacement for `memcmp'.
1 
1      The result of this macro is cached in the
1      `ac_cv_func_memcmp_working' variable.
1 
1      This macro is obsolescent, as current systems have a working
1      `memcmp'.  New programs need not use this macro.
1 
1  -- Macro: AC_FUNC_MKTIME
1      If the `mktime' function is not available, or does not work
1      correctly, require an `AC_LIBOBJ' replacement for `mktime'.  For
1      the purposes of this test, `mktime' should conform to the Posix
1      standard and should be the inverse of `localtime'.
1 
1      The result of this macro is cached in the
1      `ac_cv_func_working_mktime' variable.
1 
1      The `AC_FUNC_MKTIME' macro is obsolescent.  New programs should
1      use Gnulib's `mktime' module.  ⇒Gnulib.
1 
1  -- Macro: AC_FUNC_MMAP
1      If the `mmap' function exists and works correctly, define
1      `HAVE_MMAP'.  This checks only private fixed mapping of
1      already-mapped memory.
1 
1      The result of this macro is cached in the
1      `ac_cv_func_mmap_fixed_mapped' variable.
1 
1  -- Macro: AC_FUNC_OBSTACK
1      If the obstacks are found, define `HAVE_OBSTACK', else require an
1      `AC_LIBOBJ' replacement for `obstack'.
1 
1      The result of this macro is cached in the `ac_cv_func_obstack'
1      variable.
1 
1  -- Macro: AC_FUNC_REALLOC
1      If the `realloc' function is compatible with the GNU C library
1      `realloc' (i.e., `realloc (NULL, 0)' returns a valid pointer),
1      define `HAVE_REALLOC' to 1.  Otherwise define `HAVE_REALLOC' to 0,
1      ask for an `AC_LIBOBJ' replacement for `realloc', and define
1      `realloc' to `rpl_realloc' so that the native `realloc' is not
1      used in the main project.  See `AC_FUNC_MALLOC' for details.
1 
1      The result of this macro is cached in the
1      `ac_cv_func_realloc_0_nonnull' variable.
1 
1  -- Macro: AC_FUNC_SELECT_ARGTYPES
1      Determines the correct type to be passed for each of the `select'
1      function's arguments, and defines those types in
1      `SELECT_TYPE_ARG1', `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'
1      respectively.  `SELECT_TYPE_ARG1' defaults to `int',
1      `SELECT_TYPE_ARG234' defaults to `int *', and `SELECT_TYPE_ARG5'
1      defaults to `struct timeval *'.
1 
1      This macro is obsolescent, as current systems have a `select' whose
1      signature conforms to Posix.  New programs need not use this macro.
1 
1  -- Macro: AC_FUNC_SETPGRP
1      If `setpgrp' takes no argument (the Posix version), define
1      `SETPGRP_VOID'.  Otherwise, it is the BSD version, which takes two
1      process IDs as arguments.  This macro does not check whether
1      `setpgrp' exists at all; if you need to work in that situation,
1      first call `AC_CHECK_FUNC' for `setpgrp'.
1 
1      The result of this macro is cached in the `ac_cv_func_setpgrp_void'
1      variable.
1 
1      This macro is obsolescent, as current systems have a `setpgrp'
1      whose signature conforms to Posix.  New programs need not use this
1      macro.
1 
1  -- Macro: AC_FUNC_STAT
1  -- Macro: AC_FUNC_LSTAT
1      Determine whether `stat' or `lstat' have the bug that it succeeds
1      when given the zero-length file name as argument.  The `stat' and
1      `lstat' from SunOS 4.1.4 and the Hurd (as of 1998-11-01) do this.
1 
1      If it does, then define `HAVE_STAT_EMPTY_STRING_BUG' (or
1      `HAVE_LSTAT_EMPTY_STRING_BUG') and ask for an `AC_LIBOBJ'
1      replacement of it.
1 
1      The results of these macros are cached in the
1      `ac_cv_func_stat_empty_string_bug' and the
1      `ac_cv_func_lstat_empty_string_bug' variables, respectively.
1 
1      These macros are obsolescent, as no current systems have the bug.
1      New programs need not use these macros.
1 
1  -- Macro: AC_FUNC_STRCOLL
1      If the `strcoll' function exists and works correctly, define
1      `HAVE_STRCOLL'.  This does a bit more than
1      `AC_CHECK_FUNCS(strcoll)', because some systems have incorrect
1      definitions of `strcoll' that should not be used.
1 
1      The result of this macro is cached in the
1      `ac_cv_func_strcoll_works' variable.
1 
1  -- Macro: AC_FUNC_STRERROR_R
1      If `strerror_r' is available, define `HAVE_STRERROR_R', and if it
1      is declared, define `HAVE_DECL_STRERROR_R'.  If it returns a `char
1      *' message, define `STRERROR_R_CHAR_P'; otherwise it returns an
1      `int' error number.  The Thread-Safe Functions option of Posix
1      requires `strerror_r' to return `int', but many systems
1      (including, for example, version 2.2.4 of the GNU C Library)
1      return a `char *' value that is not necessarily equal to the
1      buffer argument.
1 
1      The result of this macro is cached in the
1      `ac_cv_func_strerror_r_char_p' variable.
1 
1  -- Macro: AC_FUNC_STRFTIME
1      Check for `strftime' in the `intl' library, for SCO Unix.  Then,
1      if `strftime' is available, define `HAVE_STRFTIME'.
1 
1      This macro is obsolescent, as no current systems require the `intl'
1      library for `strftime'.  New programs need not use this macro.
1 
1  -- Macro: AC_FUNC_STRTOD
1      If the `strtod' function does not exist or doesn't work correctly,
1      ask for an `AC_LIBOBJ' replacement of `strtod'.  In this case,
1      because `strtod.c' is likely to need `pow', set the output
1      variable `POW_LIB' to the extra library needed.
1 
1      This macro caches its result in the `ac_cv_func_strtod' variable
1      and depends upon the result in the `ac_cv_func_pow' variable.
1 
1      The `AC_FUNC_STRTOD' macro is obsolescent.  New programs should
1      use Gnulib's `strtod' module.  ⇒Gnulib.
1 
1  -- Macro: AC_FUNC_STRTOLD
1      If the `strtold' function exists and conforms to C99, define
1      `HAVE_STRTOLD'.
1 
1      This macro caches its result in the `ac_cv_func_strtold' variable.
1 
1  -- Macro: AC_FUNC_STRNLEN
1      If the `strnlen' function is not available, or is buggy (like the
1      one from AIX 4.3), require an `AC_LIBOBJ' replacement for it.
1 
1      This macro caches its result in the `ac_cv_func_strnlen_working'
1      variable.
1 
1  -- Macro: AC_FUNC_UTIME_NULL
1      If `utime (FILE, NULL)' sets FILE's timestamp to the present,
1      define `HAVE_UTIME_NULL'.
1 
1      This macro caches its result in the `ac_cv_func_utime_null'
1      variable.
1 
1      This macro is obsolescent, as all current systems have a `utime'
1      that behaves this way.  New programs need not use this macro.
1 
1  -- Macro: AC_FUNC_VPRINTF
1      If `vprintf' is found, define `HAVE_VPRINTF'.  Otherwise, if
1      `_doprnt' is found, define `HAVE_DOPRNT'.  (If `vprintf' is
1      available, you may assume that `vfprintf' and `vsprintf' are also
1      available.)
1 
1      This macro is obsolescent, as all current systems have `vprintf'.
1      New programs need not use this macro.
1 
1  -- Macro: AC_REPLACE_FNMATCH
1      If the `fnmatch' function does not conform to Posix (see
1      `AC_FUNC_FNMATCH'), ask for its `AC_LIBOBJ' replacement.
1 
1      The files `fnmatch.c', `fnmatch_loop.c', and `fnmatch_.h' in the
1      `AC_LIBOBJ' replacement directory are assumed to contain a copy of
1      the source code of GNU `fnmatch'.  If necessary, this source code
1      is compiled as an `AC_LIBOBJ' replacement, and the `fnmatch_.h'
1      file is linked to `fnmatch.h' so that it can be included in place
1      of the system `<fnmatch.h>'.
1 
1      This macro caches its result in the `ac_cv_func_fnmatch_works'
1      variable.
1 
1      This macro is obsolescent, as it assumes the use of particular
1      source files.  New programs should use Gnulib's `fnmatch-posix'
1      module, which provides this macro along with the source files.
1      ⇒Gnulib.
1