help-make
[Top][All Lists]
Advanced

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

Re: Variable assignation in a target


From: Philip Guenther
Subject: Re: Variable assignation in a target
Date: Sat, 16 Dec 2006 07:02:38 -0700

On 12/16/06, Gauvain Pocentek <address@hidden> wrote:
I try to define a variable this way:

-----
config.status-%:
    DEB_BUILDDIR_$* ?= build-$*
----

But it doesn't work, DEB_BUILDDIR_$* is understood as a command by make.
How could I define this variable?

That depends on what you're trying to achieve.  If the DEB_BUILDDIR_*
variables are only going to be used in commands for target (and not in
prerequisite lists, target names, or global variable assignments) then
you _may_ be able to use target-specific assignments.  However, I
doubt that'll work for you.

Instead, I think you need to take a step back and look at what you're
trying to do.  You want to define a default value for an entire set of
variables and had tried to do that by using a pattern rule to select
the values for which that was true.  That won't work.  Instead, why
not define it as a function?

DEB_BUILDDIR = $(if $(findstring undefined,$(origin \
       DEB_BUILDDIR_${1})),build-${1},${DEB_BUILDDIR_${1}})

With that, instead of referencing ${DEB_BUILDDIR_${whatever}}, you could use
$(call DEB_BUILDDIR,${whatever}).  You would still override the
default value for a given input by assigning to
DEB_BUILDDIR_${whatever}.


Philip Guenther




reply via email to

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