%% [EMAIL PROTECTED] (Mark Paulus) writes:
mp> The area I am concerned about is in the middle of the
mp> output where it says:
mp> findicf = ""
mp> making with icf file ""
mp> making with icf file ""
mp> Both of these lines should say:
mp> making WITHOUT icf file ""
mp> making WITHOUT icf file""
mp> If anyone has any clues, or insights, I would appreciate them
To understand this you have to keep firmly in mind the distinction in
make between the two phases: the read-in phase where make reads the
makefile, and the run phase where make invokes the rules.
If you look in the GNU make manual for one of the newer versions of GNU
make (I don't think it's in 3.77's manual) there's a section there
describing how and when variables are expanded.
The problem is that make's preprocessor statements, like ifeq, etc., are
expanded in the first phase (they have to be, since they're like
preprocessor statements in that they hide certain parts of the makefile
from being examined at all). Just putting the preprocessor statement
into the command script section doesn't magically make it expand later;
it's still expanded when the makefile is parsed.
However, automatic variables like $< have no value until a particular
rule is actually being run, in the second phase.
So, you set the value of findicf here:
mp> findicf=$(strip $(findstring $(basename $<).icf,$(ICFS)))
And use it here:
mp> %_c.cpp %_c.h %_s.cpp %_s.h : %.idl
mp> @echo findicf = \"$(findicf)\"
mp> ifeq ("",$(findicf)) # check if icf file exists
When make reads the makefile it sees the ifeq with a reference to
$(findicf), so it expands that reference right then. At this point,
though, you're not actually running any rules so the variable $< has no
value. Thus, you get the empty string for $< and thus the results you
see.
You'll have to change this to test using a shell construct, which is
evaluated by the shell during the second phase when the script is
running. Something like this:
%_c.cpp %_c.h %_s.cpp %_s.h : %.idl
@echo findicf = \"$(findicf)\"
@case "$(findicf)" in \
"") echo making without icf file \"$(findstring $(basename
$<).icf,$(ICFS))\" \
echo making without icf file \"$(findicf)\" \
*) echo making with icf file \"$(findstring $(basename $<).icf,$(ICFS))\" \
echo making with icf file \"$(findicf)\" \
esac
touch $(basename $<)_c.cpp
touch $(basename $<)_c.h
touch $(basename $<)_s.cpp
touch $(basename $<)_s.h
touch $(basename $<)_c.o
touch $(basename $<)_s.o
--
-------------------------------------------------------------------------------
Paul D. Smith <[EMAIL PROTECTED]> Find some GNU make tips at:
http://www.gnu.org http://www.ultranet.com/~pauld/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist