lua-users home
lua-l archive

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


On Wed, Nov 23, 2016 at 05:29:05PM +0100, mathieu stumpf guntz wrote:
> Ok, maybe this attached file is a somewhat portable solution, providing the
> environemnt have a shell with the test command and that the $(shell […])
> syntax is portable. I don't know how yet if this conditions holds in most
> places where you have a make implementation installable. Feedback is
> welcome.

$(shell) is not portable. In fact, I think only GNU Make supports it. The
following are some of the ways you can accomplish command substitution in
various implementations.

Code:
   OUTPUT = $(shell command)
Supported by:
   GNU Make

Code:
   OUTPUT != command
Supported by:
   GNU Make 4.0+, NetBSD Make, OpenBSD Make

Code:
   OUTPUT:sh = command
Supported by:
   Solaris Make

Code:
   COMMAND = command
   OUTPUT = $(COMMAND:sh)
Supported by:
   NetBSD Make, Solaris Make

Code:
   OUTPUT = $(:!command!)
Supported by:
   NetBSD Make

Code:
   $(OUTPUT::!=command)
Supported By:
   NetBSD Make

OUTPUT != command is the most portable, and it's also approved for the next
POSIX specification. The big headache is that macOS only ships GNU Make
3.81.

A portable version of NetBSD Make is maintained as bmake, and this is what's
commonly known as BSD Make. FreeBSD uses this port for it's native make, and
Linux distributions package it as bmake. OpenBSD's native make is homegrown
and unrelated to NetBSD Make.