Hi nihkil,

Try using a "macro":

# $(1) is retry count: integer constant in shell test syntax
# $(2) is command
#
define retry-times
i=0; while [ $$i -lt $(1) ]; do ($(2)) && exit 0; i=$$(( i + 1 )); done ; exit 1
endef

target: prerequisite
  $(call retry-times,5,your command here)


Fixed retries version:

# $(1) is command
#
define retry-3-times
  ($(1)) && exit 0 || ($(1)) && exit 0 || ($(1)) && exit 0 || exit 1
endef

target: prerequisite
  $(call retry-3-times,your command here)

We insert the command in parentheses not just for syntactic hygiene but to get it to run in a subshell. This way our command can contain subcommands like "exit 1" without terminating the retry logic.

Cheers ...

On 2019-09-01 12:48, nikhil jain wrote:
Ok, thanks.

On Sat, 31 Aug 2019, 19:44 Paul Smith, <psm...@gnu.org> wrote:

On Fri, 2019-08-30 at 16:37 +0530, nikhil jain wrote:
> Does GMAKE has a retry option. If a command in a rule is failed, is
> there an option to retry it or I have to implement it ?

GNU make has no built-in facility to retry failed commands.


_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to