nammerkage
nammerkage

Reputation: 304

Makefile - using math in a loop

I'm trying to make a loop. I would like to use the values: 10, 20, 30, 40, 50..

I managed to get the function to print out 1,2,3,4,5:

main:
    for i in `seq 1 5`; do \
        echo $$i; \
    done;

But somehow simple mathmatics doesn't work. This fails:

main:
    for i in `seq 1 5`; do \
        echo $$i*10; \
    done;

I've also tried performing math inside $ symbols and vrackets without any luck. Would love your input on this.

Upvotes: 0

Views: 73

Answers (1)

nammerkage
nammerkage

Reputation: 304

Got it working by using SHELL on first line:

SHELL=/bin/bash
main:
    for i in `seq 1 5`; do \
        echo $$(( $$i*10 )); \
    done;

Upvotes: 1

Related Questions