[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: conditional parts
From: |
Paul D. Smith |
Subject: |
Re: conditional parts |
Date: |
Mon, 11 Mar 2002 12:51:03 -0500 |
%% Massimiliano Cialdi <address@hidden> writes:
mc> %m: %n
mc> @echo "*$<* ... *$(FILES)* ... *$(findstring $<,$(F))*"
mc> ifeq ($<,$(findstring $<,$(F)))
mc> @echo "++$<==$(findstring $<,$(F))++"
mc> else
mc> @echo "++$<!=$(findstring $<,$(F))++"
mc> endif
You can't do this.
Make parses makefiles in two steps: first it reads the entire makefile
and constructs an internal graph.
Second it walks that graph and invokes the rules needed to build the
out-of-date targets it finds during that walk.
The make preprocessor commands like ifeq, etc. are all parsed during the
first step.
The contents of the automatic variables like $<, etc. are only valid
during the second step, when the rule is being invoked.
So, your ifeq statement is the same as this (since $< is always empty
during the first step):
ifeq (,$(findstring ,$(F)))
If you want to write conditions that execute inside a rule based on the
target/prerequisite values of that rule, you _MUST_ use shell
conditionals, not make conditionals:
%m: %n
@echo "*$<* ... *$(FILES)* ... *$(findstring $<,$(F))*"
@case "$<" in $(findstring $<,$(F))) echo found; *) echo not found; esac
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://www.paulandlesley.org/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
- conditional parts, Massimiliano Cialdi, 2002/03/11
- Re: conditional parts,
Paul D. Smith <=