+2000-02-08 Akim Demaille <akim@epita.fr>
+
+ Use the style we promote.
+
+ * doc/autoconf.texi (Header Templates): Promote #if over #ifdef;
+ and #undef over #define in templates.
+ * acspecific.m4 (AC_DECL_SYS_SIGLIST, AC_FUNC_MMAP,
+ AC_FUNC_SETPGRP, AC_FUNC_VFORK, AC_FUNC_SELECT_ARGTYPES): Use #if,
+ not #ifdef and #ifndef, indent CPP directives.
+
2000-02-08 Akim Demaille <akim@epita.fr>
Quote properly AC_SHELL_IFELSE and callers.
[AC_TRY_COMPILE([#include <sys/types.h>
#include <signal.h>
/* NetBSD declares sys_siglist in unistd.h. */
-#ifdef HAVE_UNISTD_H
+#if HAVE_UNISTD_H
# include <unistd.h>
#endif
], [char *msg = *(sys_siglist + 1);],
AC_DEFUNCT(AC_UNISTD_H, [; instead use AC_CHECK_HEADERS(unistd.h)])
AC_DEFUNCT(AC_USG,
- [; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])
+ [; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])
# If memchr and the like aren't declared in <string.h>, include <memory.h>.
# To avoid problems, don't check for gcc2 built-ins.
AC_DEFUNCT(AC_MEMORY_H,
- [; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])
+ [; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])
AC_DEFUNCT(AC_DIR_HEADER, [; instead use AC_HEADER_DIRENT])
[AC_TRY_COMPILE([#include <sys/types.h>
#include <signal.h>
#ifdef signal
-#undef signal
+# undef signal
#endif
#ifdef __cplusplus
extern "C" void (*signal (int, void (*)(int)))(int);
#endif
int
-main()
+main ()
{
exit (fnmatch ("a*", "abc", 0) != 0);
}],
[AC_CHECK_HEADERS(unistd.h)
AC_CHECK_FUNCS(getpagesize)
AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
-[AC_TRY_RUN([
-/* Thanks to Mike Haertel and Jim Avera for this test.
+[AC_TRY_RUN(
+[/* Thanks to Mike Haertel and Jim Avera for this test.
Here is a matrix of mmap possibilities:
mmap private not fixed
mmap private fixed at somewhere currently unmapped
#include <sys/mman.h>
/* This mess was copied from the GNU getpagesize.h. */
-#ifndef HAVE_GETPAGESIZE
-# ifdef HAVE_UNISTD_H
+#if !HAVE_GETPAGESIZE
+# if HAVE_UNISTD_H
# include <unistd.h>
# endif
/* Assume that all systems that can run configure have sys/param.h. */
-# ifndef HAVE_SYS_PARAM_H
+# if !HAVE_SYS_PARAM_H
# define HAVE_SYS_PARAM_H 1
# endif
# ifdef _SC_PAGESIZE
# define getpagesize() sysconf(_SC_PAGESIZE)
# else /* no _SC_PAGESIZE */
-# ifdef HAVE_SYS_PARAM_H
+# if HAVE_SYS_PARAM_H
# include <sys/param.h>
# ifdef EXEC_PAGESIZE
# define getpagesize() EXEC_PAGESIZE
AC_DEFUN(AC_FUNC_SETPGRP,
[AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
AC_TRY_RUN(
-[#ifdef HAVE_UNISTD_H
+[#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
+#if HAVE_UNISTD_H
# include <unistd.h>
#endif
-#ifdef HAVE_VFORK_H
+#if HAVE_VFORK_H
# include <vfork.h>
#endif
/* On some sparc systems, changes by the child to local and incoming
for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
AC_TRY_COMPILE(dnl
-[#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
+[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
#endif
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
+#if HAVE_SYS_SELECT_H
+# include <sys/select.h>
#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
#endif
extern select ($ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5);],,dnl
[ac_not_found=no ; break 3],ac_not_found=yes)
@item --trace=@var{macro}
@itemx -t @var{macro}
List the calls to @var{macro}. Multiple calls to @samp{--trace} list
-several macros. It is adviced to use this feature instead of parsing
+several macros. It is advised to use this feature instead of parsing
@file{configure.in}.
The output is composed of separated lines for each macro call. Each
@subsection Configuration Header Templates
Your distribution should contain a template file that looks as you want
-the final header file to look, including comments, with default values
-in the @code{#define} statements. For example, suppose your
+the final header file to look, including comments, with @code{#undef}
+statements which are used as hooks. For example, suppose your
@file{configure.in} makes these calls:
@example
@end example
@noindent
-Then you could have code like the following in @file{conf.h.in}.
-On systems that have @file{unistd.h}, @code{configure} will change the 0
-to a 1. On other systems, it will leave the line unchanged.
+Then you could have code like the following in @file{conf.h.in}. On
+systems that have @file{unistd.h}, @code{configure} will @samp{#define}
+@samp{HAVE_UNISTD_H} to 1. On other systems, the whole line will be
+commented out (in case the system predefines that symbol).
@example
@group
/* Define as 1 if you have unistd.h. */
-#define HAVE_UNISTD_H 0
+#undef HAVE_UNISTD_H
@end group
@end example
-Alternately, if your code tests for configuration options using
-@code{#ifdef} instead of @code{#if}, a default value can be to
-@code{#undef} the variable instead of to define it to a value. On
-systems that have @file{unistd.h}, @code{configure} will change the
-second line to read @samp{#define HAVE_UNISTD_H 1}. On other systems,
-it will comment that line out (in case the system predefines that
-symbol).
+You can then decode the configuration header using the preprocessor
+directives:
@example
@group
-/* Define if you have unistd.h. */
-#undef HAVE_UNISTD_H
+#include "conf.h"
+
+#if HAVE_UNISTD_D
+# include <unistd.h>
+#else
+/* We are in trouble. */
+#endif
@end group
@end example
-@node Invoking autoheader, , Header Templates, Configuration Headers
+The use of old form templates, with @samp{#define} instead of
+@samp{#undef} is strongly discouraged.
+
+Since it is a tedious task to keep a template header up to date, you may
+use @code{autoheader} to generate it, see @ref{Invoking autoheader}.
+
+
+@node Invoking autoheader,, Header Templates, Configuration Headers
@subsection Using @code{autoheader} to Create @file{config.h.in}
+
The @code{autoheader} program can create a template file of C
@samp{#define} statements for @code{configure} to use. If
@file{configure.in} invokes @code{AC_CONFIG_HEADER(@var{file})},
@contents
@bye
+
+@c Local Variables:
+@c ispell-local-dictionary: "american"
+@c End:
@item --trace=@var{macro}
@itemx -t @var{macro}
List the calls to @var{macro}. Multiple calls to @samp{--trace} list
-several macros. It is adviced to use this feature instead of parsing
+several macros. It is advised to use this feature instead of parsing
@file{configure.in}.
The output is composed of separated lines for each macro call. Each
@subsection Configuration Header Templates
Your distribution should contain a template file that looks as you want
-the final header file to look, including comments, with default values
-in the @code{#define} statements. For example, suppose your
+the final header file to look, including comments, with @code{#undef}
+statements which are used as hooks. For example, suppose your
@file{configure.in} makes these calls:
@example
@end example
@noindent
-Then you could have code like the following in @file{conf.h.in}.
-On systems that have @file{unistd.h}, @code{configure} will change the 0
-to a 1. On other systems, it will leave the line unchanged.
+Then you could have code like the following in @file{conf.h.in}. On
+systems that have @file{unistd.h}, @code{configure} will @samp{#define}
+@samp{HAVE_UNISTD_H} to 1. On other systems, the whole line will be
+commented out (in case the system predefines that symbol).
@example
@group
/* Define as 1 if you have unistd.h. */
-#define HAVE_UNISTD_H 0
+#undef HAVE_UNISTD_H
@end group
@end example
-Alternately, if your code tests for configuration options using
-@code{#ifdef} instead of @code{#if}, a default value can be to
-@code{#undef} the variable instead of to define it to a value. On
-systems that have @file{unistd.h}, @code{configure} will change the
-second line to read @samp{#define HAVE_UNISTD_H 1}. On other systems,
-it will comment that line out (in case the system predefines that
-symbol).
+You can then decode the configuration header using the preprocessor
+directives:
@example
@group
-/* Define if you have unistd.h. */
-#undef HAVE_UNISTD_H
+#include "conf.h"
+
+#if HAVE_UNISTD_D
+# include <unistd.h>
+#else
+/* We are in trouble. */
+#endif
@end group
@end example
-@node Invoking autoheader, , Header Templates, Configuration Headers
+The use of old form templates, with @samp{#define} instead of
+@samp{#undef} is strongly discouraged.
+
+Since it is a tedious task to keep a template header up to date, you may
+use @code{autoheader} to generate it, see @ref{Invoking autoheader}.
+
+
+@node Invoking autoheader,, Header Templates, Configuration Headers
@subsection Using @code{autoheader} to Create @file{config.h.in}
+
The @code{autoheader} program can create a template file of C
@samp{#define} statements for @code{configure} to use. If
@file{configure.in} invokes @code{AC_CONFIG_HEADER(@var{file})},
@contents
@bye
+
+@c Local Variables:
+@c ispell-local-dictionary: "american"
+@c End:
[AC_TRY_COMPILE([#include <sys/types.h>
#include <signal.h>
/* NetBSD declares sys_siglist in unistd.h. */
-#ifdef HAVE_UNISTD_H
+#if HAVE_UNISTD_H
# include <unistd.h>
#endif
], [char *msg = *(sys_siglist + 1);],
AC_DEFUNCT(AC_UNISTD_H, [; instead use AC_CHECK_HEADERS(unistd.h)])
AC_DEFUNCT(AC_USG,
- [; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])
+ [; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])
# If memchr and the like aren't declared in <string.h>, include <memory.h>.
# To avoid problems, don't check for gcc2 built-ins.
AC_DEFUNCT(AC_MEMORY_H,
- [; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])
+ [; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])
AC_DEFUNCT(AC_DIR_HEADER, [; instead use AC_HEADER_DIRENT])
[AC_TRY_COMPILE([#include <sys/types.h>
#include <signal.h>
#ifdef signal
-#undef signal
+# undef signal
#endif
#ifdef __cplusplus
extern "C" void (*signal (int, void (*)(int)))(int);
#endif
int
-main()
+main ()
{
exit (fnmatch ("a*", "abc", 0) != 0);
}],
[AC_CHECK_HEADERS(unistd.h)
AC_CHECK_FUNCS(getpagesize)
AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
-[AC_TRY_RUN([
-/* Thanks to Mike Haertel and Jim Avera for this test.
+[AC_TRY_RUN(
+[/* Thanks to Mike Haertel and Jim Avera for this test.
Here is a matrix of mmap possibilities:
mmap private not fixed
mmap private fixed at somewhere currently unmapped
#include <sys/mman.h>
/* This mess was copied from the GNU getpagesize.h. */
-#ifndef HAVE_GETPAGESIZE
-# ifdef HAVE_UNISTD_H
+#if !HAVE_GETPAGESIZE
+# if HAVE_UNISTD_H
# include <unistd.h>
# endif
/* Assume that all systems that can run configure have sys/param.h. */
-# ifndef HAVE_SYS_PARAM_H
+# if !HAVE_SYS_PARAM_H
# define HAVE_SYS_PARAM_H 1
# endif
# ifdef _SC_PAGESIZE
# define getpagesize() sysconf(_SC_PAGESIZE)
# else /* no _SC_PAGESIZE */
-# ifdef HAVE_SYS_PARAM_H
+# if HAVE_SYS_PARAM_H
# include <sys/param.h>
# ifdef EXEC_PAGESIZE
# define getpagesize() EXEC_PAGESIZE
AC_DEFUN(AC_FUNC_SETPGRP,
[AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
AC_TRY_RUN(
-[#ifdef HAVE_UNISTD_H
+[#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
+#if HAVE_UNISTD_H
# include <unistd.h>
#endif
-#ifdef HAVE_VFORK_H
+#if HAVE_VFORK_H
# include <vfork.h>
#endif
/* On some sparc systems, changes by the child to local and incoming
for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do
for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do
AC_TRY_COMPILE(dnl
-[#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
+[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
#endif
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
#endif
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
+#if HAVE_SYS_SELECT_H
+# include <sys/select.h>
#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
#endif
extern select ($ac_cv_func_select_arg1,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg234,$ac_cv_func_select_arg5);],,dnl
[ac_not_found=no ; break 3],ac_not_found=yes)