help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: doing a string comparison with an extra level of variable reference?


From: John Graham-Cumming
Subject: Re: doing a string comparison with an extra level of variable reference?
Date: Fri, 28 Jan 2005 08:52:08 -0500

On Fri, 2005-01-28 at 08:21, Robert P. J. Day wrote:
>   ${SUBDIRS}:
>         @echo "My target is address@hidden"
>         @echo "My makefile variable contains address@hidden"
>   ifneq "address@hidden" ""
>         @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 address@hidden"
        @echo "My makefile variable contains address@hidden"
        @$(if address@hidden,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/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]