bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] Re: Docs for gnulib-tool --import


From: Gary V. Vaughan
Subject: Re: [Bug-gnulib] Re: Docs for gnulib-tool --import
Date: Tue, 12 Oct 2004 12:31:02 +0100
User-agent: Mozilla Thunderbird 0.8 (X11/20040913)

Hi Simon,

Simon Josefsson wrote:
> "Gary V. Vaughan" <address@hidden> writes:
> 
> 
>>>gl_INIT([getopt progname strdup dummy ...], [gl], [gl/m4], [libgl], [LGPL])
>>>
>>>Or possibly something like:
>>>
>>>gl_INIT([[strdup dummy ...], [lgl], [lgl/m4], [liblgl], [LGPL]],
>>>        [[error getopt progname ...], [gl], [gl/m4], [libgl]])
>>
>>Yes please!  That would be cool :-)
> 
> 
> Before implementing this, could someone more familiar with M4 say if
> the latter is a good idea or not? [[snip]]

I didn't notice the nested quoting when I first looked at it.  Nesting M4
quotes this way is unidiomatic, and it makes it difficult to write macros that
unwrap the quote layers at the right point.

The style used by M4's own macros, and m4sugar.m4 in Autoconf is to shift()
away the first batch of arguments and call ourselves again recursively.  The
invocation would then be (swapping arg order for readability, and using []
to accept the defaults):

  gl_INIT([lgl], [lgl/m4], [liblgl], [LGPL],
               [strdup dummy ...],
          [gl],  [gl/m4],  [libgl],  [],
               [error getopt progname ...])

The implementation would then be:

  AC_DEFUN([gl_INIT],
  [for module in $5 do;
      blah $1 $2 $4 blah $3
  done
  $0(m4_shiftn(5, $@)])

> Perhaps the first version is simpler to parse in gnulib-tool though,
> which is an advantage.

Not necessarily:  gnulib-tool can always call M4 outside of autoconf with
gl_INIT defined to rewrite its arguments in an easy to parse way using m4sh.m4
(i.e autom4te -l m4sh gnulib-rewrite.m4 configure.ac):

# gnulib-rewrite.m4
m4_define([gl_INIT],
[#gnulib-tool start here
source_base=$1
m4_base=$2
lib=$3
license=$4
modules="$4"
#gnulib-tool end here
$0(m4_shiftn(5, $@)])

Then you could either extract the commented blocks from the output using sed,
and source them with the shell to get the values, or you could set an m4
diversion in gnulib-rewrite.m4 that swallows the rest of the output except for
the gl_INIT generated chunks... either way, parsing becomes a whole lot
easier.  Libtool successfully uses this technique to read .la file values at
runtime.

> On the other hand, there is an advantage of having only one entry
> point, otherwise gnulib-tool have to remember state between each call
> to gl_INIT.  This is probably needed to, for example, generate
> gl_EARLY properly, as a superset of all gl_EARLY contents generated by
> each gl_INIT.

Agreed.

HTH,
        Gary.
-- 
Gary V. Vaughan      ())_.  address@hidden,gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker           / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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