Discussion:
split the result of AC_ARG_WITH with a given token
Vincent Torri
2012-11-09 07:24:51 UTC
Permalink
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 ?

thank you

Vincent Torri
Eric Blake
2012-11-09 13:39:47 UTC
Permalink
Post by Vincent Torri
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 ***@redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Loading...