Commit graph

5 commits

Author SHA1 Message Date
Matt Latusek
2fe193b477 BSDmakefile: remove .OBJDIR
.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.
2025-04-02 21:36:42 +00:00
Matt Latusek
5646c95bfc Multiple BSDmakefile issues
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.
2025-04-02 21:15:35 +00:00
Sergey Zolotarev
cf74f5fc40
Fix build errors on BSD (in BSDMakefile) (#27594)
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. ```
2023-10-13 15:38:27 +00:00
techknowlogick
8aada1849f
update BSDmakefile to latest version from upstream (#24063)
from https://github.com/neosmart/gmake-proxy
2023-04-11 23:42:22 -04:00
Mahmoud Al-Qudsi
7be5935c55 Add BSDmakefile to prevent errors when make is called under FreeBSD (#4446)
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
2018-07-16 20:45:51 +02:00