.OBJDIR is a variable, not a special target. It somehow worked with FreeBSD's
make but it didn't with OpenBSD, because that line defined the first target
that would be executed if not extra command line arguments were given.
BSDmakefile, the make script for *BSD platforms had the following defects.
1. The output of which(1) was not redirected to /dev/null and it got printed
every time make was launched. Also the $(.TARGETS) target did not have
.SILENT dependency and would print the call to gmake, which was also
inconsistent with the rest of the BSDmakefile.
2. GNU make would be called twice if any target was given:
$ make show-version-full
/usr/local/bin/gmake
12.0.0-dev-68-ee5b102142+gitea-1.22.0
"gmake" "--no-print-directory" show-version-full
12.0.0-dev-68-ee5b102142+gitea-1.22.0
For reasons that I don't fully understand, the first call came from .DEFAULT,
and the other from $(.TARGETS).
3. Invalid use of $(.TARGETS) instead of $@ in build commands would cause
multiple more invocations if more than one target was specified, for example:
$ make -f BSDmakefile show-version-minor show-version-major
/usr/local/bin/gmake
12.0
12
"gmake" "--no-print-directory" show-version-minor show-version-major
12.0
12
"gmake" "--no-print-directory" show-version-minor show-version-major
12.0
12
Here gmake is called three times in total.
After this change:
• the default rule EMPTY is called if no explicit target is specified in
the command line,
• otherwise $(.TARGETS) are expanded and called one by one,
• .DONE has been removed; it was not used anywhere and it is not a keyword,
• FRC (a.k.a. FORCE) is not needed as adding to .PHONY is sufficient,
• $(JARG) has been moved before current target $@ as this is a command line
switch; it's spurious as parallel compilation is not supported anyway.
1. `make build` fails because `||` and `&&` have the same precedence in
sh/bash, so the `false` command always evaluated (leading to an error).
```
+ which gmake /usr/local/bin/gmake
+ false
*** Failed target: .BEGIN
*** Failed command: which "gmake" || printf "Error: GNU Make is
required!\n\n" 1>&2 && false
*** Error code 1
```
2. When `GPREFIX` is set to an empty string with quotation marks,
`gmake` mistakenly thinks that it's a file name:
``` gmake: *** empty string invalid as file name. Stop. ```
The syntax of the gitea Makefile is not platform-agnostic and is
specific to the GNU version of `make`. BSD platforms such as FreeBSD
ship with bmake (BSD make) as their default `make` program; attempting
to compile gitea by simply executing `make` causes a wall of errors to
show as a result of syntax incompatible with BSD make.
If a file named `BSDmakefile` is present, `bmake` will give it
preference over a generic `Makefile`. This `BSDmakefile` is taken from
the BSD-licensed `gmake-proxy` project [0], which transparently proxies
all `make` commands to `gmake` (GNU make) on systems where `bmake` is
the default, and if `gmake` is not installed an error message is
displayed.
[0]: https://github.com/neosmart/gmake-proxy