>Synopsis: cannot add prerequisites without commands in make(1)
>Category: user
>Environment:
System : OpenBSD 6.9
Details : OpenBSD 6.9 (GENERIC.MP) #4: Tue Aug 10 08:12:23 MDT 2021
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
Architecture: OpenBSD.amd64
Machine : amd64
>Description:
It looks like OpenBSD make does not allow adding prerequisites to a target
without any command.
According to POSIX specifications, a target rule that adds prerequisites but no
commands can be used to add more dependencies.
>From https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
A target that has prerequisites, but does not have any commands, can be
used to add to the prerequisite list for that target. Only one target rule
for any given target can contain commands.
Given the following Makefile to add test.txt prerequisites to a target seems to
remove the default rule to generate it.
>How-To-Repeat:
$ echo "int main(void) {}" > main.c
$ cat > Makefile
test.txt:
touch test.txt
main: test.txt
=== FreeBSD 13 make ===
$ make main
touch test.txt
cc -O2 -pipe main.c -o main
=== GNU make 4.3 ===
$ make main
touch test.txt
cc main.c test.txt -o main
=== Portable bmake 20210420, Alpine Linux ===
$ bmake main
touch test.txt
cc -pipe -g -o main main.c
=== OpenBSD make ===
$ make main
touch test.txt