Make's empty(), defined() and .ifdef don't catch outer .for iterators

Kogule Ryo <[email protected]> Wed, 8 Jul 2026 10:22:05 +0900
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
Hi forks,

Make's empty() does not catch outer .for iterators.

> % uname -a
> NetBSD myhost 10.1 NetBSD 10.1 (GENERIC) #0: Mon Dec 16 13:08:11 UTC =
2024  [email protected]:/usr/src/sys/arch/amd64/compile/GENERIC =
amd64
>=20
> % cat Makefile.empty
> .for i in yes no
> .  if !empty(i:M[Yy][Ee][Ss])
> output+=3D	yes
> .  endif
> .endfor
>=20
> all:
> 	@echo ${output}
>=20
> % make -f Makefile.empty
>=20


Debug output says:

> % make -dA -f Makefile.empty
> :
> :
> CondParser_Eval: !empty(i:M[Yy][Ee][Ss])
> Var_Parse: y(i:M[Yy][Ee][Ss]) (eval)
> Evaluating modifier ${i:M...} on value "" (eval, undefined)
> Pattern for ':M' is "[Yy][Ee][Ss]"
> ModifyWords: split "" into 1 word
> Result of ${i:M[Yy][Ee][Ss]} is "" (eval, undefined)
> :
> :

i is undefined.

defined() and .ifdef do the same.  Is this behavior intentional?


--=20
Kogule, Ryo