autoconf
[Top][All Lists]
Advanced

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

Re: split the result of AC_ARG_WITH with a given token


From: Eric Blake
Subject: Re: split the result of AC_ARG_WITH with a given token
Date: Fri, 09 Nov 2012 06:39:47 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1

On 11/09/2012 12:24 AM, Vincent Torri wrote:
> Hey
> 
> AC_ARG_WITH sets a variable named loaders and set to (for example)
> gif,tiff (actually, it's a comma separated list, there can be more
> than 2 'elements')
> 
> What I want to do is plitting it into gif and tiff and manipulate those.
> 
> I know how to do that with m4_foreach ith an m4 list. But i don't know
> what to do with just a variable.
> 
> what should i do ?

That doesn't give me much to go on.  Show me some actual configure.ac
code you have tried to write to demonstrate what you are really trying
to do.  It sounds like you have:

AC_ARG_WITH([loaders], [help string]...)

where the user is calling:

./configure --with-loaders=gif,tiff

and you are now trying to write shell code that iterates over the
contents of $with_loaders?  If so, look at
coreutils.git:m4/include-exclude-prog.m4 - there, you have the example
of using AC_ARG_ENABLE (not AC_ARG_WITH) to set up
$enable_install_program to a comma separated list, followed by
manipulations in shell to operate individually on each member of the list.

But there's no real way to do m4-time looping of the list, since the
contents of the list won't be known until the user supplies the
configure argument - you'll have to do all your list manipulation at
shell time.  Note, however, that it is possible to write shell loops
around m4 macros, so that you call an m4 macro to operate on a shell
variable's contents rather than a literal string (again, in the
coreutils example, you'll notice how at the end of the file there is a
for loop using $gl_i to iterate over the list, but within the for loop
is a call to AC_MSG_WARN if something went wrong).

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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