| >>>>> "AD" == Akim Demaille <[EMAIL PROTECTED]> writes:
| AD> So I pulled out the definition of the macro out of AC_OUTPUT, removed
| AD> the useless (or have I missed something) changequote (changequote is
| AD> *hell*), and it works.
|
| AD> dnl CPP_MAKEFILE(CPPFLAGS,filename)
| AD> define([CPP_MAKEFILE],
| AD> [echo creating $dir/[$2]
| AD> $CPP -I. -I${top_srcdir}/src [$1] junk.c \
| AD> dnl Delete line directives inserted by $CPP
| AD> | sed -e 's/^\#.*//' \
| AD> dnl Delete spurious blanks inserted by $CPP
| AD> -e 's/^[[ TAB][ TAB]]*$//'\
| AD> -e 's/^ /TAB/' \
| AD> dnl Delete blank lines
| AD> | sed -n -e '/^..*$/p' \
| AD> dnl Restore lines quoted above to original contents.
| AD> | sed '/^\"/ {
| AD> s/\\\([\"]\)/\1/g
| AD> s/^[[ TAB]]*\"//
| AD> s/\"[[ TAB]]*$//
| AD> }' > Makefile.new
| AD> chmod 444 Makefile.new
| AD> mv -f Makefile.new [$2]
| AD> ])dnl CPP_MAKEFILE
|
| Well, TAB is a macro defined to you-know-what, and I know of no way to
| quote a non-paired quote character, so [ TAB] cannot be properly
| expanded without changequote. Of course, we could use a real tab
| character in the source instead of TAB, but that would be less
| readable.
OK, I thought TAB was handle by sed somewhere, as @BKL@ mentioned by
Paul.
So indeed you need a changequote because you want both 1. literal [],
2. macro expansion.
But then, what is the point of 2.? Why don't you just use a literal
tab? Then, what i wrote is fine.
dnl CPP_MAKEFILE(CPPFLAGS,filename)
define([CPP_MAKEFILE],
[echo creating $dir/[$2]
$CPP -I. -I${top_srcdir}/src [$1] junk.c \
dnl Delete line directives inserted by $CPP
| sed -e 's/^\#.*//' \
dnl Delete spurious blanks inserted by $CPP
-e 's/^[[ ][ ]]*$//'\
-e 's/^ / /' \
dnl Delete blank lines
| sed -n -e '/^..*$/p' \
dnl Restore lines quoted above to original contents.
| sed '/^\"/ {
s/\\\([\"]\)/\1/g
s/^[[ ]]*\"//
s/\"[[ ]]*$//
}' > Makefile.new
chmod 444 Makefile.new
mv -f Makefile.new [$2]
])dnl CPP_MAKEFILE
BTW, your quoting is not homogeneous with that used in Autoconf. The
rule is now one level of [] for each evaluation, ie. each pair of ().
In particular in the macro above, no single occurrence of $1/$2 should
be quoted.
*Yes* it means that that if you want to use a macro name as $1 it must
be quoted twice at the top level. But that's the price the pay for
uniformity. Double-quoting macros are a pain.
| Regarding your comment about defining a macro inside AC_OUTPUT: it's a
| general principle of good software engineering to define everything as
| close to its use and in as small a scope as possible. So logically,
| if it's only used in AC_OUTPUT, what better place to define it?
In m4/cpp-makefile.m4. Defining macros in configure.in is not a good
idea IMHO. Yet as an argument of another macro, this is sadism :)
Akim