Re: Iterating over variable using AC_DEFINE to get HAVE_FOO_varitem (similar to AC_CHECK_HEADERS)

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

 



On 05/17/2010 01:44 PM, Daniel Leidert wrote:
>> AS_FOR is not (yet) documented;
> 
> I tried m4_foreach_w too. But this fails too:
> 
>> ALL_LINGUAS="de fr nl"
>> m4_foreach_w(

m4_foreach_w does iteration of a list known at m4 time...

>>         [AC_lingua],
>>         [$ALL_LINGUAS],

but $ALL_LINGUAS is a list not known until shell time.  Therefore,
m4_foreach_w sees a single-element list - the string "$ALL_LINGUAS".

I meant that it would be worth writing an open-coded shell for loop:

for lingua in $ALL_LINGUAS; do
  AC_MSG_NOTICE([...])
  ...
end

> Even if I use m4_unquote, m4_split, ... I can't get this to work. My
> working solution now is this one:
> 
>> m4_define([_MY_LINGUAS], [de fr nl])

With this approach, you've moved the whitespace list of linguas out of
shell and into m4...

>> AC_SUBST([ALL_LINGUAS], "_MY_LINGUAS")
>> m4_foreach_w(
>>         [AC_lingua],
>>         _MY_LINGUAS,

which explains why this is working better for you.

> Unfortunately the shell loop didn't work for me. I tried this:
> 
>> ALL_LINGUAS="de fr nl"
>> for lang in $ALL_LINGUAS
>> do
>> 	AC_MSG_NOTICE([Having lingua $lang])dnl debugging
>> 	AH_TEMPLATE(AS_TR_CPP([HAVE_LINGUA_$lang]), [Define to 1 for $lang lingua support.])
>> 	AC_DEFINE(AS_TR_CPP([HAVE_LINGUA_$lang]))
>> done
> 
> It did split the variable correctly, but AH_TEMPLATES didn't seem to
> work. Maybe I did something wrong (quotation maybe?)?

Ah - to use an indirect variable (as in the value of HAVE_LINGUA_$lang),
you have to us AS_VAR_PUSHDEF and AS_VAR_POPDEF.  AH_TEMPLATE is a no-op
unless it has a literal argument, but you gave it an indirect argument.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux