autoconf
[Top][All Lists]
Advanced

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

Re: m4 macro whose name depends on a a variable


From: Eric Blake
Subject: Re: m4 macro whose name depends on a a variable
Date: Mon, 10 Nov 2008 19:09:34 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Vincent Torri on 11/10/2008 11:22 AM:
>>
>> m4_default([], [EVAS_CHECK_LOADER_DEP_]m4_defn([UP]))(args)
> 
> I decided to use the second one as I need to suppot old autoconf macros.

For that matter, even

m4_default([EVAS_CHECK_LOADER_DEP_]m4_defn([UP]))(args)

would work.

> 
> have_dep="no"
> evas_image_loader_[]$1[]_cflags=""
> evas_image_loader_[]$1[]_libs=""
> 
> AC_CHECK_HEADER([jpeglib.h],
>    [
>     have_dep="yes"
>     evas_image_loader_[]$1[]_cflags=""
>     evas_image_loader_[]$1[]_libs="-ljpeg"
>    ]
> )
> 
> AC_SUBST([evas_image_loader_$1_cflags])
> AC_SUBST([evas_image_loader_$1_libs])

This last usage is different than the first two (in the first two, you
separate $1 from its neighbors, so that a $1 of either "LOWER" or "jpeg"
would work.  But since you didn't separate it in the last case, you are
stuck with:

evas_image_loader_LOWER_cflags

which is not a macro name, and you've lost jpeg.  You probably meant:

AC_SUBST([evas_image_loader_[]$1[]_cflags])

in which case you can safely pass [LOWER] rather than expanding in
advance, in order to look more consistent.

> if test "x${have_dep}" = "xyes" ; then
>   ifelse([$2], , :, [$2])

Yes, ifelse is another raw m4 macro you should avoid.  In general, this
can be replaced with m4_if, but in this particular use case, you can write
the abbreviated:

m4_default([$2], [:])

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkY6V4ACgkQ84KuGfSFAYCylACgza6Gx4fZS2ToPF7ViZHIU9XJ
AdEAn3ifAaKYjyXT32HP5zK43BMVFPe7
=kUBl
-----END PGP SIGNATURE-----




reply via email to

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