From e99b32cacb54914ea5ceea683737a43ad7296a59 Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Mon, 20 Mar 2023 15:00:15 +0000 Subject: [PATCH] common.mak: make *clean targets mutually exclusive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'clean' build targets can be specified alongside other targets, which causes an immediate removal of build artifacts. Make 'clean' targets mutually exclusive to avoid this issue and display an error if 'clean' is used in combination with other targets. Reviewed-by: Benjamin Block Reviewed-by: Steffen Eiden Reviewed-by: Jan Höppner Signed-off-by: Marc Hartmayer Signed-off-by: Steffen Eiden --- common.mak | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common.mak b/common.mak index a380c770..9b226aae 100644 --- a/common.mak +++ b/common.mak @@ -17,6 +17,13 @@ BUILD_ARCH := $(shell uname -m | sed -e 's/i.86/i386/' -e 's/sun4u/sparc64/' -e # 'HOST_ARCH' is the architecture of the machine that will run the compiled output HOST_ARCH ?= $(BUILD_ARCH) +# The `*clean` targets are mutually exclusive to all other targets +ifneq ($(filter %clean,$(MAKECMDGOALS)),) + ifneq ($(MAKECMDGOALS),$(filter %clean,$(MAKECMDGOALS))) + $(error The *clean targets are mutually exclusive to all other targets) + endif +endif + # Global definitions # The variable "DISTRELEASE" should be overwritten in rpm spec files with: # "make DISTRELEASE=%{release}" and "make install DISTRELEASE=%{release}"