----- "Paul Smith" <[EMAIL PROTECTED]> wrote:

> On Wed, 2008-10-29 at 11:26 -0400, Michael Ploujnikov wrote:
> > define rule-generator
> > $(1):
> >         @echo "$(1) generating $(2)" && \                           
>                           
> >         $(call $(3)) && \                                           
>                           
> >         $(call $(4))
> > endef
> > 
> > $(eval $(call
> rule-generator,my-rule1,package-name,default-start-fun,default-end-fun))
> 
> You really don't want to use ifdef for this.  Ifdef is a preprocessor
> statement and it can't be used inside of backslash-extended lines
> like
> this.  It gets appended to the previous line and bad things happen.
> 
> Why don't you just use $(if ..)... or actually even $(or ...) would
> be
> more efficient (one less variable expansion)?  Something like:
> 
>         define rule-generator
>         $(1):
>                 @echo "$(1) generating $(2)" && \                     
>                                 
>                 $(call $(or $(3),$(default-start-fun))) && \          
>                                                            
>                 $(call $(or $(4),$(default-end-fun)))
>         endef
> 
> (totally untested).

Nice. This works wonderfully if I don't treat default-start-fun as a variable:

define rule-generator
$(1):
        @echo "$(1) generating $(2)" && \                                       
               
        $(call $(or $(3),default-start-fun)) && \                               
               
        $(call $(or $(4),default-end-fun))
endef

$(eval $(call rule-generator,my-rule1,package-name,custom-start-fun))

$ make -f /tmp/simple.mk
my-rule1 generating package-name
uh, oh, we are doing something different!
starting ... started
ending
ended

Thanks a lot. I never noticed the Make "or" function.


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to