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: Paul D. Smith
Subject: Re: doing a string comparison with an extra level of variable reference?
Date: Fri, 28 Jan 2005 08:51:48 -0500

%% "Robert P. J. Day" <address@hidden> writes:

  rpjd>   ${SUBDIRS}:
  rpjd>         @echo "My target is address@hidden"
  rpjd>         @echo "My makefile variable contains address@hidden"
  rpjd>   ifneq "address@hidden" ""
  rpjd>         @echo "Yup, that variable is set."
  rpjd>   endif

This cannot work.

Make preprocessor statements are evaluated when the makefile is read in,
just like the C/C++ preprocessor.

The contents of rules, and in particular automatic variables like $@,
are only set when the rule is invoked.


You have to use SHELL syntax to test whether something is set in the
shell, not make syntax.

  rpjd> i want to call this with something like:

  rpjd>   $ make d2_MAKEFILE=d2make d2

  rpjd> and be able to test whether the corresponding variable is set within
  rpjd> the rule.

Try something like:

   ${SUBDIRS}:
         @echo "My target is address@hidden"
         @echo "My makefile variable contains address@hidden"
         @[ -n "address@hidden" ] && echo "Yup, that variable is set."

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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