[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to conditionally pass a function to a function
From: |
Paul Smith |
Subject: |
Re: how to conditionally pass a function to a function |
Date: |
Wed, 29 Oct 2008 11:42:53 -0400 |
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).