tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: make .if short-circuit evaluation



Am 06.09.2021 um 20:00 schrieb Edgar Fuß:
> I'm probably doing something stupidly wrong, but man make says:
> 	As in C, make will only evaluate a conditional as far as is necessary to
> 	determine its value.
> however,
> 	x= /nonexistent
> 	.if exists(${x}) && ${x:sh} != 0
> 	.endif
> complains
> 	sh: /nonexistent: not found
>
> what am I missing?
You are missing a current version of make.


~/proj/make-archive $ cat test.mk
x= /nonexistent
.if exists(${x}) && ${x:sh} != 0
.endif

~/proj/make-archive $ ./check -f test.mk
bin/make-2021.07.31.00.17.04-debug
| make: no target to make.
|
| make: stopped in /home/rillig/proj/make-archive
| exit status 2
bin/make-2020.06.28.11.06.26-debug

bin/make-2020.05.17.12.36.26-debug
| sh: /nonexistent: not found
| make: "/nonexistent" returned non-zero status
| make: no target to make.
|
| make: stopped in /home/rillig/proj/make-archive
| exit status 2
bin/make-2001.06.12.23.36.18-debug

bin/make-2001.05.29.17.37.52-debug
| sh: /nonexistent: not found
| make: "/nonexistent" returned non-zero status
| make: no target to make.
| exit status 2


The above output means, when read from bottom to top: until
2001.05.29.17.37.52 UTC, make didn't output the additional "stopped in".

Between 2001.06.12.23.36.18 and 2020.05.17.12.36.26, make wrongly
evaluated the expression to the right of the '&&'.

Since 2020.06.28.11.06.26, this particular case has been fixed:
https://github.com/NetBSD/src/commit/c97dd76ee7ddd6e2f271e1a98306c8d905f4441d
-- there are lots of other similar cases that have been fixed somewhere
near that commit.  If you are interested in more details, have a look at
the history of usr.bin/make/cond.c and
usr.bin/make/unit-tests/cond-short.mk.


Home | Main Index | Thread Index | Old Index