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: Vincent Torri
Subject: Re: m4 macro whose name depends on a a variable
Date: Tue, 11 Nov 2008 08:56:55 +0100 (CET)



On Mon, 10 Nov 2008, Eric Blake wrote:

For that matter, even

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

would work.

indeed

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])

no, I use AC_SUBST([evas_image_loader_$1_cflags])

I call that macro that way:

m4_default([EVAS_CHECK_LOADER_DEP_]m4_defn([UP]))(DOWN,
   [have_evas_image_loader_[]DOWN="yes"],
   [have_evas_image_loader_[]DOWN="no"])

I have not quoted DOWN (the 1st argument). Otherwise it does not work.

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], [:])

ok, thank you for your help. It's nice to see that we can write some kind of interface in m4 :)

Vincent Torri




reply via email to

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