On Fri, 2005-01-28 at 08:21, Robert P. J. Day wrote:
>   ${SUBDIRS}:
>         @echo "My target is [EMAIL PROTECTED]"
>         @echo "My makefile variable contains [EMAIL PROTECTED]"
>   ifneq "[EMAIL PROTECTED]" ""
>         @echo "Yup, that variable is set."
>   endif
> 
> i want to call this with something like:
> 
>   $ make d2_MAKEFILE=d2make d2
> 
> and be able to test whether the corresponding variable is set within
> the rule.

That doesn't work because the ifneq is handled at Makefile parse time
and hence $@ is unset and if ends up doing

    ifneq "${_MAKEFILE}" ""

which assuming you haven't set _MAKEFILE somewhere is going to fail. 
Since $@ is only known at rule run time and preprocessor stuff like
ifneq is done at parse time there's no way to mix the two.

You could use a $(if) instead like this:

  ${SUBDIRS}:
        @echo "My target is [EMAIL PROTECTED]"
        @echo "My makefile variable contains [EMAIL PROTECTED]"
        @$(if [EMAIL PROTECTED],echo "Yup that variable is set.")

Note that I took the comma out of the "Yup..." otherwise the $(if)
interprets that , as a parameter separator.

John.
-- 
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/




_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to