Hello,

I'm using make version 3.79.1 on a Solaris 7 machine and have run across
a peculiar feature when using target-specific variables.  Basically,
global variables are being used in the prerequisite section while
target-specific variables are used in the command lines.  An example
Makefile and run session follow: 

Makefile
------------------
file=global_junk

my_target: file = junk

my_target: $(file)
        echo $(file)
------------------


>gmake my_target
gmake: *** No rule to make target `global_junk', needed by `my_target'. 
Stop.
>touch global_junk
>gmake my_target
echo junk
junk

-------------------

The documentation confirms this behavior.

"As with automatic variables, these values are only available within the
context of a target's command script (and in other target-specific
assignments)."

To me, it seems odd that in the Makefile above the $(file) variable has
different values in the prereq. and command section.  Why are
target-specific variables handled in this way?  My desired result is
that the target-specific variable be used for _both_ the prereq. section
and the commands.  Would it make sense to provide some mechanism to
accomplish this?  


Regards,


-- Tom Drabenstott

Reply via email to