(autoconf.info)Particular Headers
4.4.1 Particular Header Checks
------------------------------
These macros check for particular system header files--whether they
exist, and in some cases whether they declare certain symbols.
-- Macro: AC_DECL_SYS_SIGLIST
Define 'SYS_SIGLIST_DECLARED' if the variable 'sys_siglist' is
declared in a system header file, either 'signal.h' or 'unistd.h'.
-- Macro: AC_DIR_HEADER
Like calling 'AC_HEADER_DIRENT' and 'AC_FUNC_CLOSEDIR_VOID', but
defines a different set of C preprocessor macros to indicate which
header file is found. This macro and the names it defines are
considered obsolete. The names it defines are:
'dirent.h'
'DIRENT'
'sys/ndir.h'
'SYSNDIR'
'sys/dir.h'
'SYSDIR'
'ndir.h'
'NDIR'
In addition, if the 'closedir' function does not return a
meaningful value, define 'VOID_CLOSEDIR'.
-- Macro: AC_HEADER_DIRENT
Check for the following header files, and for the first one that is
found and defines 'DIR', define the listed C preprocessor macro:
'dirent.h'
'HAVE_DIRENT_H'
'sys/ndir.h'
'HAVE_SYS_NDIR_H'
'sys/dir.h'
'HAVE_SYS_DIR_H'
'ndir.h'
'HAVE_NDIR_H'
The directory library declarations in the source code should look
something like the following:
#if HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
# define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen
# if HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif
# if HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif
# if HAVE_NDIR_H
# include <ndir.h>
# endif
#endif
Using the above declarations, the program would declare variables
to be type 'struct dirent', not 'struct direct', and would access
the length of a directory entry name by passing a pointer to a
'struct dirent' to the 'NAMLEN' macro.
This macro also checks for the SCO Xenix 'dir' and 'x' libraries.
-- Macro: AC_HEADER_MAJOR
If 'sys/types.h' does not define 'major', 'minor', and 'makedev',
but 'sys/mkdev.h' does, define 'MAJOR_IN_MKDEV'; otherwise, if
'sys/sysmacros.h' does, define 'MAJOR_IN_SYSMACROS'.
-- Macro: AC_HEADER_STDC
Define 'STDC_HEADERS' if the system has ANSI C header files.
Specifically, this macro checks for 'stdlib.h', 'stdarg.h',
'string.h', and 'float.h'; if the system has those, it probably has
the rest of the ANSI C header files. This macro also checks
whether 'string.h' declares 'memchr' (and thus presumably the other
'mem' functions), whether 'stdlib.h' declare 'free' (and thus
presumably 'malloc' and other related functions), and whether the
'ctype.h' macros work on characters with the high bit set, as ANSI
C requires.
Use 'STDC_HEADERS' instead of '__STDC__' to determine whether the
system has ANSI-compliant header files (and probably C library
functions) because many systems that have GCC do not have ANSI C
header files.
On systems without ANSI C headers, there is so much variation that
it is probably easier to declare the functions you use than to
figure out exactly what the system header files declare. Some
systems contain a mix of functions ANSI and BSD; some are mostly
ANSI but lack 'memmove'; some define the BSD functions as macros in
'string.h' or 'strings.h'; some have only the BSD functions but
'string.h'; some declare the memory functions in 'memory.h', some
in 'string.h'; etc. It is probably sufficient to check for one
string function and one memory function; if the library has the
ANSI versions of those then it probably has most of the others. If
you put the following in 'configure.in':
AC_HEADER_STDC
AC_CHECK_FUNCS(strchr memcpy)
then, in your code, you can put declarations like this:
#if STDC_HEADERS
# include <string.h>
#else
# ifndef HAVE_STRCHR
# define strchr index
# define strrchr rindex
# endif
char *strchr (), *strrchr ();
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
If you use a function like 'memchr', 'memset', 'strtok', or
'strspn', which have no BSD equivalent, then macros won't suffice;
you must provide an implementation of each function. An easy way
to incorporate your implementations only when needed (since the
ones in system C libraries may be hand optimized) is to, taking
'memchr' for example, put it in 'memchr.c' and use
'AC_REPLACE_FUNCS(memchr)'.
-- Macro: AC_HEADER_SYS_WAIT
If 'sys/wait.h' exists and is compatible with POSIX.1, define
'HAVE_SYS_WAIT_H'. Incompatibility can occur if 'sys/wait.h' does
not exist, or if it uses the old BSD 'union wait' instead of 'int'
to store a status value. If 'sys/wait.h' is not POSIX.1
compatible, then instead of including it, define the POSIX.1 macros
with their usual interpretations. Here is an example:
#include <sys/types.h>
#if HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif
-- Macro: AC_MEMORY_H
Define 'NEED_MEMORY_H' if 'memcpy', 'memcmp', etc. are not
declared in 'string.h' and 'memory.h' exists. This macro is
obsolete; instead, use 'AC_CHECK_HEADERS(memory.h)'. See the
example for 'AC_HEADER_STDC'.
-- Macro: AC_UNISTD_H
Define 'HAVE_UNISTD_H' if the system has 'unistd.h'. This macro is
obsolete; instead, use 'AC_CHECK_HEADERS(unistd.h)'.
The way to check if the system supports POSIX.1 is:
#if HAVE_UNISTD_H
# include <sys/types.h>
# include <unistd.h>
#endif
#ifdef _POSIX_VERSION
/* Code for POSIX.1 systems. */
#endif
'_POSIX_VERSION' is defined when 'unistd.h' is included on POSIX.1
systems. If there is no 'unistd.h', it is definitely not a POSIX.1
system. However, some non-POSIX.1 systems do have 'unistd.h'.
-- Macro: AC_USG
Define 'USG' if the system does not have 'strings.h', 'rindex',
'bzero', etc. This implies that it has 'string.h', 'strrchr',
'memset', etc.
The symbol 'USG' is obsolete. Instead of this macro, see the
example for 'AC_HEADER_STDC'.
automatically generated by info2www version 1.2.2.9