autoconf-patches
[Top][All Lists]
Advanced

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

Re: Add and document AS_VAR_COPY, speed up configure


From: Ralf Wildenhues
Subject: Re: Add and document AS_VAR_COPY, speed up configure
Date: Fri, 17 Oct 2008 21:05:53 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Eric,

* Eric Blake wrote on Fri, Oct 17, 2008 at 07:43:51PM CEST:
> 
> I'm planning on committing this to savannah later today, unless someone
> reviews it sooner.

Overall very nice, only nits.  Thanks!

> Subject: [PATCH] Add AS_VAR_COPY.
> 
> +# AS_VAR_SET(VARIABLE, VALUE)
> +# ---------------------------
> +# Set the VALUE of the shell VARIABLE.
> +# If the variable contains indirections (e.g. `ac_cv_func_$ac_func')
> +# perform whenever possible at m4 level, otherwise sh level.

This sentence is hard to understand; I'd guess:

+# If VARIABLE contains indirections (e.g. `ac_cv_func_$ac_func'),
+# perform indirection at the m4 level whenever possible, otherwise
+# at the sh level.


> Subject: [PATCH] Test AS_VAR interfaces.

> +AT_SETUP([AS@&address@hidden)
> +AT_KEYWORDS([m4sh AS@&address@hidden AS@&address@hidden AS@&address@hidden
> +AS@&address@hidden AS@&address@hidden AS@&address@hidden AS@&address@hidden
> +AS@&address@hidden)

FWIW, you can use multiple AT_KEYWORDS instead of wrapping, too.

> --- a/NEWS
> +++ b/NEWS
> @@ -18,11 +18,19 @@ GNU Autoconf NEWS - User visible changes.
>  ** The following documented m4sh macros are new:
>     AS_LINENO_PREPARE
>     AS_ME_PREPARE
> +   AS_VAR_COPY
> 
>  ** The following m4sh macros are documented now:
>     AS_ECHO
>     AS_ECHO_N
> +   AS_LITERAL_IF
>     AS_UNSET
> +   AS_VAR_IF
> +   AS_VAR_POPDEF
> +   AS_VAR_PUSHDEF
> +   AS_VAR_SET
> +   AS_VAR_SET_IF
> +   AS_VAR_TEST_SET
>     AS_VERSION_COMPARE

s/\n/  /g | fmt   ?
(but you can do that in an independent patch if you prefer)


> --- a/doc/autoconf.texi
> +++ b/doc/autoconf.texi

> address@hidden Polymorphic Variables
> address@hidden Support for indirect variable names
> address@hidden variable name indirection
> address@hidden polymorphic variable name
> address@hidden indirection, variable name
> +
> +Often times, it is convenient to write a macro that will emit shell code

s/ times//  ?

> +operating on a shell variable.  The simplest case is when the variable
> +name is known.  But a more powerful idiom is writing shell code that can
> +work through an indirection, where another variable or command
> +substitution produces the name of the variable to actually manipulate.
> +M4sh supports the notion of polymorphic shell variables, making it easy
> +to write a macro that can deal with either literal or indirect variable
> +names and output shell code appropriate to both use cases.  Behavior is

appropriate for?

> +undefined if expansion of an indirect variable does not result in a
> +literal variable name.  These macros are often followed with @code{dnl},
> +to avoid excess newlines in the output.
> +
> address@hidden AS_LITERAL_IF (@var{expression}, @ovar{if-literal}, 
> @ovar{if-not})
> address@hidden
> +If the expansion of @var{expression} is definitely a shell literal,
> +expand @var{if-literal}.  If the expansion of @var{expression} looks
> +like it might contain shell indirections (such as @code{$var} or
> address@hidden), then @var{if-not} is expanded.  The implementation is
> +somewhat conservative (for example, @samp{'[$]'} is a single-quoted
> +shell literal, but causes @var{if-not} to be expanded), in order to
> +offer speed to the common case of deciding whether a variable name is

speed for?

> +literal or indirect, but can be used even in contexts unrelated to
> +variable names.
> address@hidden defmac

Should AS_LITERAL_IF have an example?

> address@hidden AS_VAR_IF (@var{var}, @ovar{value}, @ovar{if-match}, 
> @ovar{if-diff})

if-equal and if-not-equal?

> address@hidden
> +Output a shell conditional statement.  If the contents of the
> +polymorphic shell variable @var{var} equal to the string @var{value},

are equal to?

> +execute @var{if-match}; otherwise execute @var{if-diff}.  Avoids shell
> +bugs if an interrupt signal arrives while a command substitution in
> address@hidden is being expanded.
> address@hidden defmac
> +
> address@hidden AS_VAR_PUSHDEF (@var{m4-name}, @var{value})
> address@hidden AS_VAR_POPDEF (@var{m4-name})
> address@hidden
> address@hidden
> address@hidden composing variable names
> address@hidden variable names, composing
> +A common m4sh idiom involves composing shell variable names from an m4
> +argument (for example, writing a macro that uses a cache variable).
> address@hidden can be an arbitrary string, which will be transliterated
> +into a valid shell name by @code{AS_TR_SH}.  In order to access the
> +composed variable name based on @var{value}, it easier to declare a

s/it /&is /

> +temporary m4 macro @var{m4-name} with @code{AS_VAR_PUSHDEF}, then use
> +that macro as the argument to subsequent @code{AS_VAR} macros as a
> +polymorphic variable name, and finally free the temporary macro with
> address@hidden
> +
> +Here is an involved example, that shows the power of writing macros that
> +can handle composed shell variable names:
> +
> address@hidden
> +m4_define([MY_CHECK_HEADER],
> +[AS_VAR_PUSHDEF([my_Header], [ac_cv_header_$1])dnl
> +AS_VAR_IF([my_Header], [yes], [echo "header $1 available"])dnl
> +AS_VAR_POPDEF([my_Header])dnl
> +])
> +MY_CHECK_HEADER([stdint.h])
> +for header in inttypes.h stdlib.h ; do
> +  MY_CHECK_HEADER([$header])
> +done
> address@hidden example
> +

@noindent here.

> +In the above example, @code{MY_CHECK_HEADER} can operate on polymorphic
> +variable names.  In the first invocation, the m4 argument is


Cheers,
Ralf




reply via email to

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