From 5646c95bfcbfa0a17bb49f77a17ee6cd8bfc780d Mon Sep 17 00:00:00 2001 From: Matt Latusek Date: Wed, 2 Apr 2025 21:15:35 +0000 Subject: [PATCH] Multiple BSDmakefile issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- BSDmakefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/BSDmakefile b/BSDmakefile index 79696eadcf..38c04fe9fb 100644 --- a/BSDmakefile +++ b/BSDmakefile @@ -48,11 +48,12 @@ GPREFIX = .endif .BEGIN: .SILENT - which $(GMAKE) || (printf "Error: GNU Make is required!\n\n" 1>&2 && false) + which $(GMAKE) >/dev/null || (printf "Error: GNU Make is required!\n\n" 1>&2 && false) -.PHONY: FRC -$(.TARGETS): FRC - $(GMAKE) $(GPREFIX) $(GARGS) $(.TARGETS:S,.DONE,,) $(JARG) +.PHONY: EMPTY +EMPTY: .SILENT + $(GMAKE) $(GPREFIX) $(GARGS) $(JARG) -.DONE .DEFAULT: .SILENT - $(GMAKE) $(GPREFIX) $(GARGS) $(.TARGETS:S,.DONE,,) $(JARG) +.PHONY: $(.TARGETS) +$(.TARGETS): .SILENT + $(GMAKE) $(GPREFIX) $(GARGS) $(JARG) $@