Subject: Re: arithmetic in make
To: None <>
From: Alan Barrett <>
List: tech-toolchain
Date: 02/26/2007 00:18:32
On Sun, 25 Feb 2007, Manuel Bouyer wrote:
> The help of shell is probably the easiest for what I want to
> do, but is echo $(($(n)+1)) portable enough ? This is for
> distrib/common/Makefile.bootcd, so it has to be cross-compile friendly
> ...

David Laight already gave you a good solution to the other part of the
problem, but I'll answer the portability questions raised by both you
and Mouse:

It's fine to use modern shell features such as $((...)) in shell
commands that are executed during the build.  On systems with an
unsuitable /bin/sh, you have to have a suitable POSIX-compliant shell
already installed (probably under a name other than /bin/sh), and invoke with HOST_SH pointing to the good shell.  All shell scripts or
shell commands in Makefiles used directly or indirectly by are
run using ${HOST_SH} as the shell.

It's fine to use NetBSD-specific syntax in Makefiles used as part of the
build.  One of the first things that does is to build nbmake
as a host tool, and that copy of nbmake is used to interpret all other
Makefiles used directly or indirectly by

--apb (Alan Barrett)