help-make
[Top][All Lists]
Advanced

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

Re: Testing rule success


From: Brian Dessent
Subject: Re: Testing rule success
Date: Mon, 30 Jul 2007 08:11:43 -0700

"David A. Greene" wrote:

> 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

Is setting VAR={true,false} the actual thing you want to accomplish or
is that just for illustrative purposes?  Because if you just want to
perform conditional actions it seems to me that using the shell is the
easiest way:

some_rule: some_file
        if [ -f some_file ]; then \
          ... \
        else \
          ... \
        fi

(I suppose if some_file is in $srcdir and you're doing a VPATH build
you'd need to qualify its name in the shell fragment.  But maybe not, I
don't know.)

However with this you can't pass variable assignments up to make, since
changes in a child's environment have no effect in the parent.

If the problem you're trying to solve is a tool that produces several
output files from one invocation then the automake manual has an idiom
that will handle it in a portable and parallel-make safe way:
<http://sources.redhat.com/automake/automake.html#Multiple-Outputs>.

Brian




reply via email to

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