How to write loop in a Makefile?

后端 未结 12 2245
天命终不由人
天命终不由人 2020-11-27 09:38

I want to execute the following commands:

./a.out 1
./a.out 2
./a.out 3
./a.out 4
.
.
. and so on

How to write this thing as a loop in a

12条回答
  •  失恋的感觉
    2020-11-27 10:14

    A simple, shell/platform-independent, pure macro solution is ...

    # GNU make (`gmake`) compatible; ref: 
    define EOL
    
    $()
    endef
    %sequence = $(if $(word ${1},${2}),$(wordlist 1,${1},${2}),$(call %sequence,${1},${2} $(words _ ${2})))
    
    .PHONY: target
    target:
        $(foreach i,$(call %sequence,10),./a.out ${i}${EOL})
    

提交回复
热议问题