help-gnu-utils
[Top][All Lists]
Advanced

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

Repeat a target on failure


From: Markus Dehmann
Subject: Repeat a target on failure
Date: Wed, 14 Dec 2005 12:15:48 -0500
User-agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317)

I wrote an interesting test Makefile that repeats a target if it fails (see target 2 below).

There are just 2 problems:

1) *** Aborting one target and continuing with next one ***
   After the retry of target 2 fails I still want to run target 3.
   I currently reach that by returning true on a failed retry.
   (well, echo returns true anyway)
   But that also means that it prints "TARGET 2 successful"
   which I don't want. I kind of want to abort target 2 and continue
   with target 3.

2) *** Nested parallel runs ***
   If I run them in parallel (which is kind of the reason why I
   use make in my case...) with make -j3
   then I get the following warning message:

--> RETRYING target 2
make[1]: Entering directory `/home/markus/tmp'
make[1]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

    I don't understand why. I use $(MAKE) as I should.
    I think I could just do a .EXPORT_ALL_VARIABLES: and then
    just say make instead of $(MAKE).  But usually $(MAKE) is
    considered better...?

Here is the Makefile:

<snip>

ifdef RETRY
 RETRY_ONCE = false
else
 RETRY_ONCE = echo && echo "--> RETRYING target $@"; \
               $(MAKE) $(MFLAGS) RETRY=1 $@ || \
               (echo "--> RETRY target $@ FAILED. Continuing..."; true)
endif

all: 1 2 3

1:
        @echo && echo "Starting target $@"
        date; sleep 1;
        @echo "--> TARGET $@ successful"

2:
        @echo && echo "Starting target $@"
        date; sleep 1; ls sdfsdfszxcz || $(RETRY_ONCE)
        @echo "--> TARGET $@ successful"

3:
        @echo && echo "Starting target $@"
        date; sleep 1
        @echo "--> TARGET $@ successful"

</snip>


reply via email to

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