[Top][All Lists]

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

How to create "re-entrant" makefiles?

From: David Wuertele
Subject: How to create "re-entrant" makefiles?
Date: Wed, 3 Jan 2007 01:48:48 +0000 (UTC)
User-agent: Loom/3.14 (

I want to include a makefile multiple times, and I each time I want it to define
rules based on the current value of some variables.  But I'm stymied by the fact
that Make only interpolates variable values for command scripts when they are
executed, not when they are defined.

For example:


MY_VAR := one

MY_VAR := two

        echo $(MY_VAR) > $(MY_VAR)

all: $(MY_VAR)

When I type "make", I expect it to do this:

  echo one > one
  echo two > two

But the rules for "one" and "two" both contain $(MY_VAR), which isn't evaluated
until execution time, and at that point MY_VAR contains "two".  So all I see is

  echo two > two

How can I make make do what I want?

reply via email to

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