%% "James" <[EMAIL PROTECTED]> writes:

  j> I have a situation where tens of target dependent variables need to be
  j> set.

  j> T: AA=aa
  j> T: BB=bb
  j> T: CC=cc
  j> etc.

  j> Is there a compact way of writing these instead of writing
  j> line-by-line?

No.  But you can use eval to do it in a loop:

  $(foreach V,AA=aa BB=bb CC=cc,$(eval T: $(V)))

Note this will ONLY work with simple variable values (ones that contain
no whitespace).  Trying to allow values with whitespace using this
method would be more work than just writing them all out.


Alternatively, if your problem is not really so much that you have lots
of target-dependent variable values you need to set, but rather that you
have lots of targets that need these variables set, you can loop on the
target, something like this:

  define SET-VARS
    $(1): AA=aa
    $(1): BB=bb
    $(1): CC=cc
  endef

  $(foreach T,$(TARGETS),$(eval $(call SET-VARS,$(T))))

You have to write out all the variable settings, yes, but only once
rather than once per target.

(note this requires at least GNU make 3.80)

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          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
_______________________________________________
help-gnu-utils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gnu-utils

Reply via email to