Install a uniform set of default includes.
* acgeneral.m4 (AC_INCLUDES_DEFAULT): New macro. Expands in its
argument if non empty, otherwise a default list of includes.
(AC_CHECK_DECL, AC_CHECK_TYPE_INTERNAL): Use AC_INCLUDES_DEFAULT.
* autoconf.texi: Adjusted.
+1999-11-01 Akim Demaille <akim@epita.fr>
+
+ Install a uniform set of default includes.
+
+ * acgeneral.m4 (AC_INCLUDES_DEFAULT): New macro. Expands in its
+ argument if non empty, otherwise a default list of includes.
+ (AC_CHECK_DECL, AC_CHECK_TYPE_INTERNAL): Use AC_INCLUDES_DEFAULT.
+ * autoconf.texi: Adjusted.
+
1999-11-01 Akim Demaille <akim@epita.fr>
* autoheader.m4 (AH_FUNC_ALLOCA, AH_C_CHAR_UNSIGNED, AH_AIX):
AC_DIVERT_POP()dnl to NORMAL
])
-dnl AC_INCLUDE
+dnl AC_INCLUDE(FILES...)
+dnl --------------------
+dnl Note that there is shell expansion, hence AC_INCLUDE(m4/*.m4) is
+dnl legal.
AC_DEFUN(AC_INCLUDE,
[ifelse($1, [], [], [dnl
esyscmd([for file in $1; do echo "m4_include($file)dnl"; done])dnl
])])
+
dnl AC_INIT_PREPARE(UNIQUE-FILE-IN-SOURCE-DIR)
dnl ------------------------------------------
dnl Called by AC_INIT to build the preamble of the `configure' scripts.
$1="$ac_cv_c_struct_member_$1"])
+dnl ### Default headers.
+
+dnl Always use the same set of default headers for all the generic macros.
+dnl It is easier to document, to extend, and to understand than having
+dnl specific defaults for each macro.
+
+dnl AC_INCLUDES_DEFAULT([INCLUDES])
+dnl -------------------------------
+dnl If INCLUDES is empty, expand in default includes, otherwise in
+dnl INCLUDES.
+define(AC_INCLUDES_DEFAULT,
+[m4_default([$1],
+[#include <stdio.h>
+#ifdef HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#else
+# ifdef HAVE_STRINGS_H
+# include <strings.h>
+# endif
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+])])
dnl ### Checking for programs
dnl AC_TRY_CPP(INCLUDES, [ACTION-IF-TRUE [, ACTION-IF-FALSE]])
dnl ----------------------------------------------------------
+dnl INCLUDES are not defaulted.
AC_DEFUN(AC_TRY_CPP,
[AC_REQUIRE_CPP()dnl
cat >conftest.$ac_ext <<EOF
dnl AC_TRY_COMPILE(INCLUDES, FUNCTION-BODY,
-dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
-dnl ---------------------------------------------------------
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------
+dnl Should INCLUDES be defaulted here?
AC_DEFUN(AC_TRY_COMPILE,
[cat >conftest.$ac_ext <<EOF
ifelse(AC_LANG, [FORTRAN77],
])
dnl AC_TRY_LINK(INCLUDES, FUNCTION-BODY,
-dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
-dnl ------------------------------------------------------
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -----------------------------------------------------
+dnl Should the INCLUDES be defaulted here?
AC_DEFUN(AC_TRY_LINK,
[cat >conftest.$ac_ext <<EOF
ifelse(AC_LANG, [FORTRAN77],
dnl ### Checking for declared symbols
-dnl AC_CHECK_DECL(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
-dnl [, INCLUDES,]]])
-dnl -------------------------------------------------------------
+dnl AC_CHECK_DECL(SYMBOL,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl [INCLUDES])
+dnl -------------------------------------------------------
dnl Check if SYMBOL (a variable or a function) is declared.
AC_DEFUN([AC_CHECK_DECL],
[AC_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])dnl
AC_CACHE_CHECK([whether $1 is declared], ac_Symbol,
-[AC_TRY_COMPILE(m4_default([$4], [#include <stdio.h>
-#ifdef HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#else
-# ifdef HAVE_STRINGS_H
-# include <strings.h>
-# endif
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-]),
+[AC_TRY_COMPILE(AC_INCLUDES_DEFAULT([$4]),
[#ifndef $1
char *p = (char *) $1;
#endif
AC_VAR_POPDEF([ac_Symbol])dnl
])dnl AC_CHECK_DECL
-dnl AC_CHECK_DECLS(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
-dnl [, INCLUDES]]])
-dnl --------------------------------------------------------------
+
+dnl AC_CHECK_DECLS(SYMBOL,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl [INCLUDES])
+dnl --------------------------------------------------------
AC_DEFUN([AC_CHECK_DECLS],
[AC_FOREACH([AC_Symbol], [$1],
[AC_SPECIALIZE([AC_CHECK_DECL], AC_Symbol,
dnl AC_CHECK_SIZEOF(TYPE [, CROSS-SIZE, [INCLUDES]])
dnl ------------------------------------------------
dnl This macro will probably be obsoleted by the macros of Kaveh. In
-dnl addition `CHECK' is not a proper name (is not boolean).
+dnl addition `CHECK' is not a proper name (is not boolean). And finally:
+dnl shouldn't we use the default INCLUDES?
AC_DEFUN(AC_CHECK_SIZEOF,
[AC_VAR_PUSHDEF([ac_Sizeof], [ac_cv_sizeof_$1])dnl
AC_CACHE_CHECK([size of $1], ac_Sizeof,
dnl ### Checking for typedefs
-dnl AC_CHECK_TYPE_INTERNAL(TYPE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl AC_CHECK_TYPE_INTERNAL(TYPE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
dnl [INCLUDES])
-dnl ----------------------------------------------------------------------
+dnl ----------------------------------------------------------------
dnl Check whether the type TYPE is supported by the system, maybe via the
dnl the provided includes. This macro implements the former task of
dnl AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was
[AC_REQUIRE([AC_HEADER_STDC])dnl
AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
AC_CACHE_CHECK([for $1], ac_Type,
-[AC_TRY_COMPILE(m4_default([$4
-], [#include <stdio.h>
-#include <sys/types.h>
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#endif
-]),
- [$1 foo;],
- AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))])
+[AC_TRY_COMPILE(AC_INCLUDES_DEFAULT([$4]),
+ [$1 foo;],
+ AC_VAR_SET(ac_Type, yes),
+ AC_VAR_SET(ac_Type, no))])
AC_SHELL_IFELSE(test AC_VAR_GET(ac_Type) = yes,
[$2], [$3])dnl
AC_VAR_POPDEF([ac_Type])dnl
])dnl AC_CHECK_TYPE_INTERNAL
-dnl AC_CHECK_TYPES(TYPES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES])
-dnl ---------------------------------------------------------------------------
-dnl TYPES is an m4 list.
+dnl AC_CHECK_TYPES((TYPE, ...),
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl [INCLUDES])
+dnl --------------------------------------------------------
+dnl TYPEs is an m4 list.
AC_DEFUN(AC_CHECK_TYPES,
[m4_foreach([AC_Type], [$1],
[AC_SPECIALIZE([AC_CHECK_TYPE_INTERNAL], AC_Type,
These macros are used to find declarations not covered by the particular
test macros.
-@defmac AC_CHECK_DECL (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@defmac AC_CHECK_DECL (@var{symbol}, @ovar{action-if-found}, @ovar{action-if-not-found}, o@var{includes})
@maindex CHECK_DECL
If the declaration of @var{symbol} (a function or a variable) is needed
because it is not declared in @var{includes}, run the shell commands
@var{action-if-not-found}, otherwise @var{action-if-found}. If no
-@var{includes} are given at all, by default @file{stdio.h},
-@file{stdlib.h}, @file{stddef.h}, @file{memory.h}, @file{string.h},
-@file{strings.h}, and @file{unistd.h} will be included.
+@var{includes} are given at all, FIXME: point to a node defining the
+standard include.
This macro actually tests whether it is valid to use @var{symbol} as an
r-value, not if it is really declared, because it is much safer to avoid
introducing extra declarations when not needed.
@end defmac
-@defmac AC_CHECK_DECLS (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@defmac AC_CHECK_DECLS (@var{symbol}, @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes})
@maindex CHECK_DECLS
@cvindex NEED_@var{symbol}_DECL
For each given @var{symbol} (whitespace-separated), define
@defmac AC_CHECK_TYPES ((@var{type}, @dots{}), @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes})
@maindex CHECK_TYPES
-For each given @var{type} that is defined by the @var{includes} (by
-default, @file{sys/types.h}, @file{stdlib.h}, and @file{stddef.h}),
+For each given @var{type} that is defined by the FIXME: @var{includes},
define @code{HAVE_@var{type}} (in all capitals). If
@var{action-if-found} is given, it is additional shell code to execute
when one of the header files is found. You can give it a value of
@defmac AC_CHECK_TYPE (@var{type}, @var{default}, @ovar{includes})
@maindex CHECK_TYPE
-If the type @var{type} is not defined in @file{sys/types.h}, or
-@file{stdlib.h} or @file{stddef.h} if they exist, define it to be the C
-(or C++) builtin type @var{default}; e.g., @samp{short} or
-@samp{unsigned}. The default header files to search can be replaced by
-supplying the optional argument @var{includes}.
+If the type @var{type} is not defined in FIXME: @ovar{includes}, define
+it to be the C (or C++) builtin type @var{default}; e.g., @samp{short}
+or @samp{unsigned}.
This macro has a broken design. First, although it is a member of the
@code{CHECK} clan, singular subfamily, it does more than just checking.
These macros are used to find declarations not covered by the particular
test macros.
-@defmac AC_CHECK_DECL (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@defmac AC_CHECK_DECL (@var{symbol}, @ovar{action-if-found}, @ovar{action-if-not-found}, o@var{includes})
@maindex CHECK_DECL
If the declaration of @var{symbol} (a function or a variable) is needed
because it is not declared in @var{includes}, run the shell commands
@var{action-if-not-found}, otherwise @var{action-if-found}. If no
-@var{includes} are given at all, by default @file{stdio.h},
-@file{stdlib.h}, @file{stddef.h}, @file{memory.h}, @file{string.h},
-@file{strings.h}, and @file{unistd.h} will be included.
+@var{includes} are given at all, FIXME: point to a node defining the
+standard include.
This macro actually tests whether it is valid to use @var{symbol} as an
r-value, not if it is really declared, because it is much safer to avoid
introducing extra declarations when not needed.
@end defmac
-@defmac AC_CHECK_DECLS (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@defmac AC_CHECK_DECLS (@var{symbol}, @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes})
@maindex CHECK_DECLS
@cvindex NEED_@var{symbol}_DECL
For each given @var{symbol} (whitespace-separated), define
@defmac AC_CHECK_TYPES ((@var{type}, @dots{}), @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes})
@maindex CHECK_TYPES
-For each given @var{type} that is defined by the @var{includes} (by
-default, @file{sys/types.h}, @file{stdlib.h}, and @file{stddef.h}),
+For each given @var{type} that is defined by the FIXME: @var{includes},
define @code{HAVE_@var{type}} (in all capitals). If
@var{action-if-found} is given, it is additional shell code to execute
when one of the header files is found. You can give it a value of
@defmac AC_CHECK_TYPE (@var{type}, @var{default}, @ovar{includes})
@maindex CHECK_TYPE
-If the type @var{type} is not defined in @file{sys/types.h}, or
-@file{stdlib.h} or @file{stddef.h} if they exist, define it to be the C
-(or C++) builtin type @var{default}; e.g., @samp{short} or
-@samp{unsigned}. The default header files to search can be replaced by
-supplying the optional argument @var{includes}.
+If the type @var{type} is not defined in FIXME: @ovar{includes}, define
+it to be the C (or C++) builtin type @var{default}; e.g., @samp{short}
+or @samp{unsigned}.
This macro has a broken design. First, although it is a member of the
@code{CHECK} clan, singular subfamily, it does more than just checking.
AC_DIVERT_POP()dnl to NORMAL
])
-dnl AC_INCLUDE
+dnl AC_INCLUDE(FILES...)
+dnl --------------------
+dnl Note that there is shell expansion, hence AC_INCLUDE(m4/*.m4) is
+dnl legal.
AC_DEFUN(AC_INCLUDE,
[ifelse($1, [], [], [dnl
esyscmd([for file in $1; do echo "m4_include($file)dnl"; done])dnl
])])
+
dnl AC_INIT_PREPARE(UNIQUE-FILE-IN-SOURCE-DIR)
dnl ------------------------------------------
dnl Called by AC_INIT to build the preamble of the `configure' scripts.
$1="$ac_cv_c_struct_member_$1"])
+dnl ### Default headers.
+
+dnl Always use the same set of default headers for all the generic macros.
+dnl It is easier to document, to extend, and to understand than having
+dnl specific defaults for each macro.
+
+dnl AC_INCLUDES_DEFAULT([INCLUDES])
+dnl -------------------------------
+dnl If INCLUDES is empty, expand in default includes, otherwise in
+dnl INCLUDES.
+define(AC_INCLUDES_DEFAULT,
+[m4_default([$1],
+[#include <stdio.h>
+#ifdef HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#else
+# ifdef HAVE_STRINGS_H
+# include <strings.h>
+# endif
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+])])
dnl ### Checking for programs
dnl AC_TRY_CPP(INCLUDES, [ACTION-IF-TRUE [, ACTION-IF-FALSE]])
dnl ----------------------------------------------------------
+dnl INCLUDES are not defaulted.
AC_DEFUN(AC_TRY_CPP,
[AC_REQUIRE_CPP()dnl
cat >conftest.$ac_ext <<EOF
dnl AC_TRY_COMPILE(INCLUDES, FUNCTION-BODY,
-dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
-dnl ---------------------------------------------------------
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------
+dnl Should INCLUDES be defaulted here?
AC_DEFUN(AC_TRY_COMPILE,
[cat >conftest.$ac_ext <<EOF
ifelse(AC_LANG, [FORTRAN77],
])
dnl AC_TRY_LINK(INCLUDES, FUNCTION-BODY,
-dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
-dnl ------------------------------------------------------
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -----------------------------------------------------
+dnl Should the INCLUDES be defaulted here?
AC_DEFUN(AC_TRY_LINK,
[cat >conftest.$ac_ext <<EOF
ifelse(AC_LANG, [FORTRAN77],
dnl ### Checking for declared symbols
-dnl AC_CHECK_DECL(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
-dnl [, INCLUDES,]]])
-dnl -------------------------------------------------------------
+dnl AC_CHECK_DECL(SYMBOL,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl [INCLUDES])
+dnl -------------------------------------------------------
dnl Check if SYMBOL (a variable or a function) is declared.
AC_DEFUN([AC_CHECK_DECL],
[AC_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])dnl
AC_CACHE_CHECK([whether $1 is declared], ac_Symbol,
-[AC_TRY_COMPILE(m4_default([$4], [#include <stdio.h>
-#ifdef HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#else
-# ifdef HAVE_STRINGS_H
-# include <strings.h>
-# endif
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-]),
+[AC_TRY_COMPILE(AC_INCLUDES_DEFAULT([$4]),
[#ifndef $1
char *p = (char *) $1;
#endif
AC_VAR_POPDEF([ac_Symbol])dnl
])dnl AC_CHECK_DECL
-dnl AC_CHECK_DECLS(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
-dnl [, INCLUDES]]])
-dnl --------------------------------------------------------------
+
+dnl AC_CHECK_DECLS(SYMBOL,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl [INCLUDES])
+dnl --------------------------------------------------------
AC_DEFUN([AC_CHECK_DECLS],
[AC_FOREACH([AC_Symbol], [$1],
[AC_SPECIALIZE([AC_CHECK_DECL], AC_Symbol,
dnl AC_CHECK_SIZEOF(TYPE [, CROSS-SIZE, [INCLUDES]])
dnl ------------------------------------------------
dnl This macro will probably be obsoleted by the macros of Kaveh. In
-dnl addition `CHECK' is not a proper name (is not boolean).
+dnl addition `CHECK' is not a proper name (is not boolean). And finally:
+dnl shouldn't we use the default INCLUDES?
AC_DEFUN(AC_CHECK_SIZEOF,
[AC_VAR_PUSHDEF([ac_Sizeof], [ac_cv_sizeof_$1])dnl
AC_CACHE_CHECK([size of $1], ac_Sizeof,
dnl ### Checking for typedefs
-dnl AC_CHECK_TYPE_INTERNAL(TYPE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl AC_CHECK_TYPE_INTERNAL(TYPE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
dnl [INCLUDES])
-dnl ----------------------------------------------------------------------
+dnl ----------------------------------------------------------------
dnl Check whether the type TYPE is supported by the system, maybe via the
dnl the provided includes. This macro implements the former task of
dnl AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was
[AC_REQUIRE([AC_HEADER_STDC])dnl
AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
AC_CACHE_CHECK([for $1], ac_Type,
-[AC_TRY_COMPILE(m4_default([$4
-], [#include <stdio.h>
-#include <sys/types.h>
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#endif
-]),
- [$1 foo;],
- AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))])
+[AC_TRY_COMPILE(AC_INCLUDES_DEFAULT([$4]),
+ [$1 foo;],
+ AC_VAR_SET(ac_Type, yes),
+ AC_VAR_SET(ac_Type, no))])
AC_SHELL_IFELSE(test AC_VAR_GET(ac_Type) = yes,
[$2], [$3])dnl
AC_VAR_POPDEF([ac_Type])dnl
])dnl AC_CHECK_TYPE_INTERNAL
-dnl AC_CHECK_TYPES(TYPES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES])
-dnl ---------------------------------------------------------------------------
-dnl TYPES is an m4 list.
+dnl AC_CHECK_TYPES((TYPE, ...),
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl [INCLUDES])
+dnl --------------------------------------------------------
+dnl TYPEs is an m4 list.
AC_DEFUN(AC_CHECK_TYPES,
[m4_foreach([AC_Type], [$1],
[AC_SPECIALIZE([AC_CHECK_TYPE_INTERNAL], AC_Type,