>>>>> "Bruno" == Bruno Haible <[EMAIL PROTECTED]> writes:
Bruno> Akim Demaille writes:
>> In addition, the style you used is very much 2.13 like, but it is
>> completely different from the style used for CVS Autoconf. You can
>> delete almost all your `dnl's, use `#' for comments, not `dnl' etc.
>> Finally, you used changequote, which is eradicated from Autoconf,
>> or almost.
Bruno> The style I used is much like anything between 2.0 and 2.13. I
Bruno> didn't know that autoconf 3.0 would be that different.
It is :) Just for the fun, here is AC_CHECK_FUNC 2.13:
| dnl AC_CHECK_SIZEOF(TYPE [, CROSS-SIZE])
| AC_DEFUN(AC_CHECK_SIZEOF,
| [changequote(<<, >>)dnl
| dnl The name to #define.
| define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
| dnl The cache variable name.
| define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
| changequote([, ])dnl
| AC_MSG_CHECKING(size of $1)
| AC_CACHE_VAL(AC_CV_NAME,
| [AC_TRY_RUN([#include <stdio.h>
| main()
| {
| FILE *f=fopen("conftestval", "w");
| if (!f) exit(1);
| fprintf(f, "%d\n", sizeof($1));
| exit(0);
| }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))
| ])dnl
| AC_MSG_RESULT($AC_CV_NAME)
| AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
| undefine([AC_TYPE_NAME])dnl
| undefine([AC_CV_NAME])dnl
| ])
and CVS:
| # AC_CHECK_SIZEOF(TYPE, [CROSS-SIZE], [INCLUDES])
| # -----------------------------------------------
| # This macro will probably be obsoleted by the macros of Kaveh. In
| # addition `CHECK' is not a proper name (is not boolean).
| AC_DEFUN(AC_CHECK_SIZEOF,
| [AC_VAR_PUSHDEF([ac_Sizeof], [ac_cv_sizeof_$1])dnl
| AC_CACHE_CHECK([size of $1], ac_Sizeof,
| [AC_TRY_RUN(AC_INCLUDES_DEFAULT([$3])
| [int
| main ()
| {
| FILE *f = fopen ("conftestval", "w");
| if (!f)
| exit (1);
| fprintf (f, "%d\n", sizeof ($1));
| exit (0);
| }],
| AC_VAR_SET(ac_Sizeof, `cat conftestval`),
| AC_VAR_SET(ac_Sizeof, 0),
| ifval([$2], AC_VAR_SET(ac_Sizeof, $2)))])
| AC_DEFINE_UNQUOTED(AC_TR_CPP(sizeof_$1),
| AC_VAR_GET(ac_Sizeof),
| [The number of bytes in a `]$1['.])
| AC_VAR_POPDEF([ac_Sizeof])dnl
| ])
Also, it has a hidden bell: take a look at this:
| /tmp % cat configure.in
| AC_INIT
| AC_CHECK_SIZEOF(char)
| int=int
| AC_CHECK_SIZEOF($int)
| /tmp % $ace/autoconf -m $ace
| /tmp % ./configure
| checking size of char... 1
| checking size of int... 4
Now let's have a look at the code generated:
| if test "${ac_cv_sizeof_char+set}" = set; then
| echo $ECHO_N "(cached) $ECHO_C" >&6
| ac_cv_sizeof_char=`cat conftestval`
| ac_cv_sizeof_char=0
| echo "${ECHO_T}$ac_cv_sizeof_char" >&6
| #define SIZEOF_CHAR $ac_cv_sizeof_char
As opposed to
| int=int
| ac_ac_Sizeof=`echo "ac_cv_sizeof_$int" | $ac_tr_sh`
| if eval "test \"\${$ac_ac_Sizeof+set}\" = set"; then
| echo $ECHO_N "(cached) $ECHO_C" >&6
| eval "$ac_ac_Sizeof=`cat conftestval`"
| eval "$ac_ac_Sizeof=0"
| echo "${ECHO_T}`eval echo '${'$ac_ac_Sizeof'}'`" >&6
| #define `echo "sizeof_$int" | $ac_tr_cpp` `eval echo '${'$ac_ac_Sizeof'}'`
I removed many lines, it's just to highlight the polymorphic nature of
the macros :)
Akim> There's a lot of hair which is due to the fact that you want to
Akim> cache low level details, such as what you computed. I think
Akim> this is not right, you should cache what you look for
Bruno> What you say here is not always followed in current
Bruno> practice. For example, here is a piece of macro Jim Meyering
Bruno> sent me today.
Well, I confess I can't see much relationship between the two examples
:) But I confess my cry was also due to the incredible patsusbt.
Bruno> The motivation for caching at the level of one compiler
Bruno> invocation is that the test result may be reused by different
Bruno> high-level tests in the same configure script. It would be very
Bruno> annoying if AM_GNU_GETTEXT and other big tests couldn't share
Bruno> their results with other pieces of the same script.
When the same low level test is run, it is probably the sign that the
same high level test was run, so...
Akim