help-make
[Top][All Lists]
Advanced

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

Re: Some more patter rules help


From: Paul D. Smith
Subject: Re: Some more patter rules help
Date: Tue, 2 May 2006 11:23:13 -0400

%% "PATTON, BILLY \(SBCSI\)" <address@hidden> writes:

  pb> I have :
  pb> define do_sh
  pb> $(1)/% : $(2)/%.sh
  pb>         @echo "copy $$$$< tp $$$$@"
  pb> endef
  pb> $(foreach proj,$(PROJECTS),\
  pb>   $(foreach bb,$(bb+$(proj)),\
  pb>     $(foreach topic,$(topic+$(proj)+$(bb)),\
  pb>       $(eval $(call 
do_sh,$(PRD_TREE)/$(proj)/$(bb)/bin,$(SRC_TREE)/$(proj)/$(bb)/$(topic)/src)))))

You really need to simplify your examples.  The foreach loops here are
unimportant, because they don't impact the expansion of the loop "body"
at all.

You can just write:

  define do_sh
  $(1)/% : $(2)/%.sh
          @echo "copy $$< tp $$@"
  endef

  $(eval $(call do_sh,/foo_path/bin,/foo_path/src))

  pb> and I get from the echo :
  pb> copy $< tp

  pb> How do I get the $? and $@ ?  How many times do I need to
  pb> refreence/derefence

As always with eval, to debug it replace it with "warning" (or in GNU
make 3.81, you can use "info"):

  define do_sh
  $(1)/% : $(2)/%.sh
          @echo "copy $$$$< tp $$$$@"
  endef

  $(info $(call do_sh,/foo_path/bin,/foo_path/src))

And you'll see that you get:

  /foo_path/bin/% : /foo_path/src/%.sh
          @echo "copy $$< tp $$@"

which is obviously one too many "$".  So, remove one set of "$$" from
"$$$$<" and "$$$$@" in your do_sh macro.

-- 
-------------------------------------------------------------------------------
 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]