[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: arithmetic, e.g. $(word $(num)-1,$(list))
From: |
Markus Mauhart |
Subject: |
Re: arithmetic, e.g. $(word $(num)-1,$(list)) |
Date: |
Thu, 17 Apr 2003 18:32:34 +0200 |
> "Mike Gibson" <address@hidden> wrote ...
>
> > Q1: is there another way for computing an arithmetic expression
> > except $(shell echo $$((expression))) ?
>
> $(shell echo $(expression) | bc)
Thanks Mike, that solved it for me !
Actually it is $(shell echo expression | bc).
So the now working makefile is ...
//-----makefile-----
list := eins zwei drei
num := $(words $(list))
num_minus_1 := $(shell echo $(num) - 1 | bc)
all:
@echo num = $(num)
echo $(num) - 1 | bc
@echo num_minus_1 = $(num_minus_1)
//----inside cygwin's bash----
//1st test the shell's arithmetic directly:
$ echo 3-1 | bc
2
//now run make:
$ make
num = 3
echo 3 - 1 | bc
2
num_minus_1 = 2
$