help-make
[Top][All Lists]
Advanced

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

Target-specific variables in implicit rules


From: Dario Teixeira
Subject: Target-specific variables in implicit rules
Date: Thu, 20 Oct 2005 18:06:06 +0200
User-agent: Mozilla Thunderbird 0.9 (X11/20041127)

Hi,

I need to use variables inside an implicit rule.  The idea
is that all files named $(PREFIX)_%_$(SUFFIX) should
be processed by the rule.  The exact values for $(PREFIX)
and $(SUFFIX) are set previously in the Makefile, and the
% character is of course the wildcard for implicit rules.

Anyway, here's an example that works fine:
(It is of course a stripped down version of the full Makefile.
Also, suppose that "generate" is a command which reads from
first argument and writes to the second).

==================================================
all: draft
PREFIX=before
SUFFIX=after
draft: before_foobar_after.out

$(PREFIX)_%_$(SUFFIX).out : $(PREFIX)_%_$(SUFFIX).in
        generate $< $@
==================================================


Now, the problem happens when I use target-specific
variable values.  If I understood the make manual,
all prerequisites should inherit those target-specific
variables, but this does not seem to happen with
the implicit rule.

This example fails:

==================================================
all: draft
draft: PREFIX=before
draft: SUFFIX=after
draft: prefix_foobar_suffix.out

$(PREFIX)_%_$(SUFFIX).out : $(PREFIX)_%_$(SUFFIX).in
        generate $< $@
==================================================


Is this a bug, a feature, or am I missing something?
Also, is there any other way to achieve what I want?

Thanks in advance for your help, guys!
Kind regards,
Dario Teixeira






reply via email to

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