On Monday 30 July 2007 01:00, David A. Greene wrote:
> Say I have a rule with an ignored-error action:
>
> some_file:
>       -$(DO_SOMETHING) > $@
>
> Is there a way to test for existence of some_file from another rule?
>
> For example:
>
> some_rule : some_file
>       $(if $(DO_EXISTENCE_TEST_HERE),$(DO_GOODSTUFF),$(DO_BADSTUFF))
>
> $(wildcard some_file) doesn't always seem to be reliable.
>
> Ideas?

All right, I believe I'm completely on the wrong path here because $(if) and 
$(wildcard) aren't useful in rule actions since they get expanded when
the Makefile is parsed, not when the rule is invoked.

However, that doesn't explain behavior that I've seen where
$(if $(wildcard)) _does_ actually work in rule actions.  Sometimes.

The case I'm looking at is something like this (much simplified):

define generate_rules

file1_dep:
   Do something to create some_file_created_by_file1_dep
   Some stuff to create file1_dep

file1: file1_dep
   $$(if $$(wildcard some_file_created_by_file1_dep),$$(eval VAR := true), \
       $$(eval VAR=false)

endef

This does actually seem to work.  Sometimes.  i.e. in some cases VAR is set
to "true."  Other times VAR is set to "false."  I don't know why sometimes and 
not never.  It seems to depend somewhat on where/when generate_rules is
invoked.  Is there some odd interaction between macro expansion and variable 
evaluation possible?

                                                     -Dave


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

Reply via email to