Bug 22000 - Variables for rules are evaluated at different times than prerequisites
Variables for rules are evaluated at different times than prerequisites
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: make (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Petr Machata
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-12-09 01:12 EST by Stephen Rasku
Modified: 2015-05-04 21:32 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-02-03 08:55:33 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Stephen Rasku 2000-12-09 01:12:29 EST
Create a Makefile called Makefile.1 containing:

	FILE=file1
	include Makefile.2

In Makefile.2 put:

	foo: $(FILE)
		@echo $(FILE)
	FILE = file2

Now type "gmake -f Makefile.1".  You get:

	gmake: *** No rule to make target `file1', needed by `foo'.  Stop.

Now remove the dependency on foo.  (i.e. Change "foo: $(FILE)" to just
:"foo:").  You get:

	file2

This shows that FILE evaluates to file1 for the prerequisite and to file2
for the rule.  It should be file2 in both cases.
Comment 1 Petr Machata 2006-02-03 08:55:33 EST
This is documented feature of gnu make. It does variable expansion in two
passes, and expansion of rule contents is deferred until second pass.

Note You need to log in before you can comment on or make changes to this bug.