autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stdbool macro, take 2


From: Paolo Bonzini
Subject: stdbool macro, take 2
Date: Thu, 8 Nov 2001 12:01:07 +0100 (CET)

Replying to Bruce:

> I very much like the idea of having all kinds of magic around
> to paper over the gaps (chasms?) some systems have with respect
> to POSIX interfaces. I think this is a start down a libiberty
> type road.

Actually I don't like what libiberty has become.  Why should I distribute
a C++ demangler (weighing around 3000 lines) with GNU Smalltalk?!? (well,
maybe some day I'll need the demangler...) My ideal would be a library
from which I can simply get boilerplate files such as config.guess,
config.sub and .c files for AC_REPLACE_FUNCS; Automake could add them to
the project directory like it does for the first two.

> Adding endless amounts of stuff to the autoconf/automake/libtool trio
> is yielding immense distributions, all of which contain duplicate copies
> of these tools. We do need to find a stopping point.

You're right, it's difficult to have a libtoolized tarball below 300k,
even for a 1000-lines project (consider that the 100k libtool.m4 is
duplicated into aclocal.m4 AND configure, plus we have libtool.sh and
maybe libltdl with a separate configure script...)  Ok, recent configure
scripts often go well over 200k and 7k lines, but the big problems are
libtool and gettext, IMO, as autoconf and automake include (almost) only
what you need.  The right point to stop for autoconf is "only standard
stuff", either POSIX or ISO -- nothing specific to libraries such as
gettext or similar.

Now, back to the code and to Paul's email.

> Surely the output file should be removed before the test is run; it
> should also be removed if config.status is run.

I think it would suffice to remove it in config.status and in make
distclean.

Actually I was not happy to introduce yet another kind of macro (one that
creates a file) but could not think of a better solution.  GNU gettext
0.11 will include a stdbool.h.in file and will copy it if it is needed,
by doing

   noinst_HEADERS = ... @STDBOOL_H@
   stdbool.h: stdbool.h.in
     cp stdbool.h.in stdbool.h

Though I could not find a way to relieve the developer from having to
remember the stdbool.h.in file, apart from patching Automake as well.
Since it is boilerplate, it is nice to create it in config.status.

> Also, the shell var STDBOOL_H doesn't seem right: shouldn't it have a
> reserved prefix? And I don't see how it's propagated from configure
> to config.status.

STDBOOL_H was intended to be used in the makefiles (for example for
address@hidden@).  This time I just put stdbool.h in STDBOOL_H
(without any path) and config.status will contain the path and file
name (computed in ac_stdbool_h).  STDBOOL_H is substituted and passed
through the INIT-CMDS, and also used by config.status to decide whether
to create stdbool.h.

Here is the patch from 2.52f (no MIME this time :-) and a ChangeLog entry

2001-11-08  Paolo Bonzini  <address@hidden)

        * doc/autoconf.texi: document AC_HEADER_STDBOOL
        * lib/autoconf/headers.m4 (AC_HEADER_STDBOOL): new macro

Paolo


diff -U3 -r old/doc/autoconf.texi new/doc/autoconf.texi
--- old/doc/autoconf.texi       Fri Nov  2 17:10:56 2001
+++ new/doc/autoconf.texi       Thu Nov  8 11:05:06 2001
@@ -3996,6 +3996,16 @@
 @end defmac
 
 
address@hidden AC_HEADER_STDBOOL (@var{path})
address@hidden HEADER_STDBOOL
address@hidden STAT_MACROS_BROKEN
+If @file{stdbool.h} is absent or does not work correctly, create a
+file @address@hidden/stdbool.h} (default @file{./stdbool.h})
+that does work. This macro invokes @code{AC_CONFIG_COMMANDS} so it
+is an instantiating macro; see @ref{Configuration Actions}.
address@hidden defmac
+
+
 @defmac AC_HEADER_STDC
 @acindex HEADER_STDC
 @cvindex STDC_HEADERS
diff -U3 -r old/lib/autoconf/headers.m4 new/lib/autoconf/headers.m4
--- old/lib/autoconf/headers.m4 Wed Oct 10 15:08:59 2001
+++ new/lib/autoconf/headers.m4 Thu Nov  8 11:40:35 2001
@@ -395,6 +395,68 @@
 ])# AC_HEADER_STAT
 
 
+# AC_HEADER_STDBOOL
+# -----------------
+AC_DEFUN([AC_HEADER_STDBOOL], [
+AC_CACHE_CHECK(for stdbool.h, ac_cv_header_stdbool_h, [
+  AC_TRY_COMPILE([#include <stdbool.h>
+#if !defined false || !true || !defined bool
+int a2[-1];
+#else
+bool a1[false || !true ? -1 : 1];
+#endif
+], [], ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
+
+if test $ac_cv_header_stdbool_h = no; then
+  STDBOOL_H=stdbool.h
+else
+  STDBOOL_H=''
+fi
+AC_SUBST(STDBOOL_H)
+
+AC_CONFIG_COMMANDS(stdbool.h, [
+  m4_if([$2], , ac_stdbool_h=stdbool.h, ac_stdbool_h=[$2]/stdbool.h)
+  rm -f $ac_stdbool_h
+  if test "x$STDBOOL_H" != x; then
+    echo config.status: creating $ac_stdbool_h
+    cat > $ac_stdbool_h << \EOF_STDBOOL_H
+/* ISO C 99 <stdbool.h> for platforms that lack it.  */
+/* 7.16. Boolean type and values */
+/* Written by Bruno Haible <address@hidden>, 2001. */
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+/* Everybody seems to #define false 0, true 1.  We use the same
+   definitions below, but temporarily we have to #undef them.  */
+#ifdef false
+# undef false
+#endif
+#ifdef true
+# undef true
+#endif
+
+/* For the sake of symbolic names in gdb, define _Bool as an enum type.  */
+#ifndef __cplusplus
+typedef enum { false = 0, true = 1 } _Bool;
+#else
+typedef bool _Bool;
+#endif
+#define bool _Bool
+
+/* The other macros must be usable in preprocessor directives.  */
+#define false 0
+#define true 1
+#define __bool_true_false_are_defined 1
+
+#endif /* _STDBOOL_H */
+EOF_STDBOOL_H
+fi
+  ],
+  [STDBOOL_H="$STDBOOL_H"])
+
+])# AC_HEADER_STDBOOL 
+
+
 # AC_HEADER_STDC
 # --------------
 AC_DEFUN([AC_HEADER_STDC],




reply via email to

[Prev in Thread] Current Thread [Next in Thread]