How do I use a shell assignment in a makefile so that it works with both FreeBSD make (bmake) and macOS make (GNU Make 3.81)?
1
vote
1
answer
431
views
I'd like to use the shell assignment operator (i.e.,
!=
) in a makefile that is going to be executed on FreeBSD, macOS, and Linux. Here's an example:
a!= seq 3
.PHONY: all
all: $a
.PHONY: $a
$a:
@echo $@
Here's the expected output:
$ touch 1 2 3
$ make all
1
2
3
Unfortunately, the shell assignment operator is not supported by the GNU Make shipped with macOS Monterey 12.6.1 and the output of the example is empty. It works in more recent versions of GNU Make though (e.g., 4.4), which are likely to be encountered in recent Linux distributions.
What should I do if I want this makefile to work with any version of GNU make and bmake?
Asked by Mateusz Piotrowski
(4983 rep)
Jan 27, 2023, 10:38 AM