lua-users home
lua-l archive

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


On Wed, Nov 23, 2016 at 11:59:46PM +0100, mathieu stumpf guntz wrote:
> Ok, thank you William, I'll go with `!=` for now and possibly investigate in
> way to make it even more portable later.

FWIW, this construct,

  DATE = date
  V = $(shell $(DATE))$(DATE:sh)
  
  test:
  	@printf "%s\n" "$(V)"

worked on all the systems I tried, including

 - Solaris Make (Solaris 11.3)
 - bmake (FreeBSD 10.2)
 - OpenBSD Make (OpenBSD 6.0)
 - NetBSD Make (NetBSD 7.0)
 - GNU Make 4.1 (Ubuntu Xenial)
 - GNU Make 3.81 (OS X 10.10)

Note that in Solaris Make ":=" is a conditional assignment operator, not the
immediate (non-lazy) assignment operator of the other common make
implementations. That's why POSIX is adding "::=". Point is, one oftens
wants immediate evaluation of macros with shell substitution, and that's not
really possible with the above hack.

However, I'm pretty sure the above hack can be used to dynamically generate
a pathname for an include line, and lazy evaluation is less problematic in
that case.