help-make
[Top][All Lists]
Advanced

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

Re: debugging eval,call,foreach....


From: Toomas Rosin
Subject: Re: debugging eval,call,foreach....
Date: Mon, 21 Oct 2002 15:58:59 +0300 (EEST)

Hello!

I wrote:

   Use `warning'.

Better yet, use a function that both displays the expression to be
evalled and really does the evaluation.  Using this method, I finally
got the damn thing working.

So, I would say that eval is quite debuggable.

Example (note the "verbose-eval" function):

   subjects                   = dog hen man
   
   dog-legs                   = 4
   dog-wears                  = hair
   
   hen-legs                   = 2
   
   man-legs                   = 2
   man-wears                  = clothes
   
   verbose-eval               = $(warning $1) $(eval $1)
   
   define defaults
   
   $(if $$(filter 2,$($1-legs)),$1-wears ?= feathers)
   
   endef
   
   $(foreach s,$(subjects),$(call verbose-eval,$(call defaults,$s)))
   
   all:
           @($(foreach s,$(subjects),echo $s: $($s-wears);))

Transcript:

   address@hidden:~ $ make
   Makefile:18:
   dog-wears ?= feathers
   
   Makefile:18:
   hen-wears ?= feathers
   
   Makefile:18:
   man-wears ?= feathers
   
   dog: hair
   hen: feathers
   man: clothes
   address@hidden:~ $

Of course, the output is not very interesting any more now that all is
working well, but it was helpful for finding mistakes.

Toomas.





reply via email to

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