This is the mail archive of the autoconf-patches@gnu.org mailing list for the autoconf project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

61-1-style-cpp-directives



Index: 0.85/ChangeLog
--- 0.85/ChangeLog Sat, 27 Nov 1999 21:20:57 +0100 akim (ace/34_ChangeLog 1.80 666)
+++ 0.85(w)/ChangeLog Sat, 27 Nov 1999 22:04:59 +0100 akim (ace/34_ChangeLog 1.80 666)
@@ -1,5 +1,17 @@
 1999-11-27  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.
+
+1999-11-27  Akim Demaille  <akim@epita.fr>
+
 	Quote properly AC_SHELL_IFELSE and callers.

 	* acgeneral.m4 (AC_SHELL_IFELSE): Don't overquote $1.
Index: 0.85/acspecific.m4
--- 0.85/acspecific.m4 Sat, 27 Nov 1999 10:03:45 +0100 akim (ace/25_acspecific 1.38 666)
+++ 0.85(w)/acspecific.m4 Sat, 27 Nov 1999 21:32:47 +0100 akim (ace/25_acspecific 1.38 666)
@@ -1084,7 +1084,7 @@
 [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);],
@@ -1126,12 +1126,12 @@
 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])

@@ -1222,7 +1222,7 @@
 [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);
@@ -1286,7 +1286,7 @@
 #endif

 int
-main()
+main ()
 {
   exit (fnmatch ("a*", "abc", 0) != 0);
 }],
@@ -1305,8 +1305,8 @@
 [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
@@ -1332,20 +1332,20 @@
 #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
@@ -1513,7 +1511,7 @@
 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

@@ -1568,10 +1566,10 @@
 #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
@@ -2223,17 +2221,17 @@
      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)
Index: 0.85/doc/autoconf.texi
--- 0.85/doc/autoconf.texi Sat, 20 Nov 1999 23:30:05 +0100 akim (ace/16_autoconf.t 1.27 666)
+++ 0.85(w)/doc/autoconf.texi Sat, 27 Nov 1999 21:55:47 +0100 akim (ace/16_autoconf.t 1.27 666)
@@ -690,7 +690,7 @@
 @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
@@ -1307,8 +1307,8 @@
 @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
@@ -1317,32 +1317,40 @@
 @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

+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}

@@ -6229,3 +6237,7 @@

 @contents
 @bye
+
+@c Local Variables:
+@c ispell-local-dictionary: "american"
+@c End:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]