forgejo/BSDmakefile
Matt Latusek 9289e293fd
Some checks failed
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Integration tests for the release process / release-simulation (push) Has been cancelled
feat: Makefile & BSDmakefile changes (#7455)
This set of commits fixes multiple issues with both make scripts. It started with #7358 and digging into it I found more problems.

@Gusted [commented](https://codeberg.org/forgejo/forgejo/issues/7358#issuecomment-3145145):
>  I do think the place where verify-version gets called should likely be backend instead and the error should likely include extra details on how to fix the error, but that can be discussed in the PR.

I think it should be closest to where `$(FORGEJO_VERSION)` is used and that's part of `$(LDFLAGS)`, so I added it where the latter is used.

When it comes to wording feel free to make suggestions.

**I haven't tested docker builds.**

I believe the most optimal way to do it is to create POSIX-compliant shell script where all those conditionals and variable expansion may be placed, and then that script should generate POSIX-compliant Makefile.

# Testing

## BSDMakefile

Should be launched from a BSD OS. You need to add `-f BSDMakefile` on OpenBSD.

* `make show-version-major show-version-minor`
Should display two lines with version numbers.
* `make TAGS=bindata`
Should launch the building process once.

## Makefile

* `make TAGS=bindata`
Should do the same as `make build`.
* `make `*target*
Should build given target like it used to.
* Copy everything except *.git* and *VERSION* to a separate directory.
`make TAGS=bindata`
Should fail with error “Could not determine FORGEJO_VERSION...”
* Copy everything except *.git* and *VERSION* to a separate directory.
`make clean`
Should execute correctly.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7455
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Matt Latusek <matlib@matlibhax.com>
Co-committed-by: Matt Latusek <matlib@matlibhax.com>
2025-04-27 10:04:32 +00:00

55 lines
2.3 KiB
Makefile

# GNU makefile proxy script for BSD make
#
# Written and maintained by Mahmoud Al-Qudsi <mqudsi@neosmart.net>
# Copyright NeoSmart Technologies <https://neosmart.net/> 2014-2019
# Obtain updates from <https://github.com/neosmart/gmake-proxy>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
JARG =
GMAKE = "gmake"
# When gmake is called from another make instance, -w is automatically added
# which causes extraneous messages about directory changes to be emitted.
# Running with --no-print-directory silences these messages.
GARGS = "--no-print-directory"
.if "$(.MAKE.JOBS)" != ""
JARG = -j$(.MAKE.JOBS)
.endif
# The GNU convention is to use the lowercased `prefix` variable/macro to
# specify the installation directory. Humor them.
GPREFIX =
.if defined(PREFIX) && ! defined(prefix)
GPREFIX = 'prefix = "$(PREFIX)"'
.endif
.BEGIN: .SILENT
which $(GMAKE) >/dev/null || (printf "Error: GNU Make is required!\n\n" 1>&2 && false)
.PHONY: EMPTY
EMPTY: .SILENT
$(GMAKE) $(GPREFIX) $(GARGS) $(JARG)
.PHONY: $(.TARGETS)
$(.TARGETS): .SILENT
$(GMAKE) $(GPREFIX) $(GARGS) $(JARG) $@