On Thu, 2007-03-15 at 17:40 -0700, Frazer Worley wrote: 

> I got a solution working with eval ... altough it appears to be overly
> complex:


Please be sure to CC the mailing list on discussions.  Thanks!  Also,
please try to find a way to keep your mail client from reformatting code
samples, otuput, etc. as it's very difficult to evaluate after it's been
"helpfully" munged up like that.


> define spyglass_rule
>   $(eval export DISCIPLINE  = $1)
>   $(eval export GOALS       = $1-$2)
>   $(eval export MILESTONE   = $3)
>   $(eval        OUTPUT      = 
> (SG_RUN_DIR)/SPYGLASS_RUN/$(MILESTONE)/$(BLOCK)/$(GOALS)/$4.vdb)
>   $(OUTPUT): \
>     $(HDL_COMPILE_DIR)/$(ANALYZE_MAKEFILE) \
>     $(SG_GLOBAL_DIR)/$(DISCIPLINE).f
>           @echo "Make: $(GOALS) ..."
>           $(RM) ./.spyglass.setup
>           $(SG_RUN_CMD)
>   $(GOALS): $(OUTPUT)
>   PHONY_TARGETS += $(GOALS)
>   SPYGLASS_RULES += $(GOALS)
> 
>     # the correspondig all target eg. Lint-all
>   $(DISCIPLINE)-all: $(GOALS)
> endef
> 
> $(eval $(call spyglass_rule,Lint,Reuse,3_Analysis,spyglass))
> $(eval $(call spyglass_rule,Lint,Structure,5_Analysis,spyglass))



> Which works correctly and the variable definitions DISCIPLINE,
> MILESTONE, GOALS are available the prerequisite lists for the target.


Hm... this is pretty confusing, to be honest.  The "export
DISCIPLINE ..." etc. will not do what you apparently think they will
do... but without seeing the definition of $(SG_RUN_CMD) I can't tell
for sure.  It's possible that this will work "by accident" because of
the extra evals inside the spyglass_rule (although I can't see any
possible advantage in exporting them with "export").

It's unquestionably much more complex than necessary, though.

I would write it something like this (again, without being able to see
the values for the other variables like SG_RUN_CMD, HDL_COMPILE_DIR,
ANALYZE_MAKEFILE, SG_GLOBAL_DIR we can't say anything for sure):


define spyglass_rule
  DISCIPLINE := $1
  GOALS      := $1-$2
  MILESTONE  := $3
  OUTPUT     := (SG_RUN_DIR)/SPYGLASS_RUN/$(MILESTONE)/$(BLOCK)/$(GOALS)/$4.vdb)
  $(OUTPUT): DISCIPLINE := $(DISCIPLINE)
  $(OUTPUT): GOALS      := $(GOALS)
  $(OUTPUT): MILESTONE  := $(MILESTONE)
  $(OUTPUT): OUTPUT     := $(OUTPUT)
  $(OUTPUT): \
    $(HDL_COMPILE_DIR)/$(ANALYZE_MAKEFILE) \
    $(SG_GLOBAL_DIR)/$(DISCIPLINE).f
          @echo "Make: $$(GOALS) ..."
          $$(RM) ./.spyglass.setup
          $$(SG_RUN_CMD)
  $(GOALS): $(OUTPUT)
  PHONY_TARGETS += $(GOALS)
  SPYGLASS_RULES += $(GOALS)
  # the correspondig all target eg. Lint-all
  $(DISCIPLINE)-all: $(GOALS)
endef

$(eval $(call spyglass_rule,Lint,Reuse,3_Analysis,spyglass))
$(eval $(call spyglass_rule,Lint,Structure,5_Analysis,spyglass))


Of course this is untested but I think it will work.

-- 
-------------------------------------------------------------------------------
 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-make mailing list
Help-make@gnu.org
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to