From 8dd672523f14961ae9a3ee18b58ac8bc06561d09 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 17 Nov 2022 08:23:10 +0100 Subject: [PATCH] BUILD: makefile: move default verbosity settings to include/make/verbose.mk The $(Q), $(V), $(cmd_xx) handling needs to be reused in sub-project makefiles and it's a pain to maintain inside the main makefile. Let's just move that into a new subdir include/make/ with a dedicated file "verbose.mk". It slightly cleans up the makefile in addition. --- Makefile | 25 +------------------------ dev/poll/Makefile | 20 ++------------------ dev/tcploop/Makefile | 20 ++------------------ include/make/verbose.mk | 27 +++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 60 deletions(-) create mode 100644 include/make/verbose.mk diff --git a/Makefile b/Makefile index 6902c37c0..8baed6212 100644 --- a/Makefile +++ b/Makefile @@ -123,12 +123,7 @@ # VTEST_PROGRAM : location of the vtest program to run reg-tests. # DEBUG_USE_ABORT: use abort() for program termination, see include/haproxy/bug.h for details -# verbosity: pass V=1 for verbose shell invocation -V = 0 -Q = @ -ifeq ($V,1) -Q= -endif +include include/make/verbose.mk # WARNING: Do not change cc-opt, cc-opt-alt or cc-warning without checking if # clang bug #49364 is fixed. stderr is redirected to /dev/null on @@ -865,24 +860,6 @@ endif # add options at the beginning of the "ld" command line if needed. LDOPTS = $(TARGET_LDFLAGS) $(OPTIONS_LDFLAGS) $(ADDLIB) -ifeq ($V,1) -cmd_CC = $(CC) -cmd_LD = $(LD) -cmd_AR = $(AR) -else -ifeq (3.81,$(firstword $(sort $(MAKE_VERSION) 3.81))) -# 3.81 or above -cmd_CC = $(info $ CC $@) $(Q)$(CC) -cmd_LD = $(info $ LD $@) $(Q)$(LD) -cmd_AR = $(info $ AR $@) $(Q)$(AR) -else -# 3.80 or older -cmd_CC = $(Q)echo " CC $@";$(CC) -cmd_LD = $(Q)echo " LD $@";$(LD) -cmd_AR = $(Q)echo " AR $@";$(AR) -endif -endif - ifeq ($(TARGET),) all: @echo "Building HAProxy without specifying a TARGET is not supported." diff --git a/dev/poll/Makefile b/dev/poll/Makefile index 9a493bb71..0247099ed 100644 --- a/dev/poll/Makefile +++ b/dev/poll/Makefile @@ -1,27 +1,11 @@ +include ../../include/make/verbose.mk + CC = cc OPTIMIZE = -O2 -g DEFINE = INCLUDE = OBJS = poll -V = 0 -Q = @ -ifeq ($V,1) -Q= -endif - -ifeq ($V,1) -cmd_CC = $(CC) -else -ifeq (3.81,$(firstword $(sort $(MAKE_VERSION) 3.81))) -# 3.81 or above -cmd_CC = $(info $ CC $@) $(Q)$(CC) -else -# 3.80 or older -cmd_CC = $(Q)echo " CC $@";$(CC) -endif -endif - poll: poll.c $(cmd_CC) $(OPTIMIZE) $(DEFINE) $(INCLUDE) -o $@ $^ diff --git a/dev/tcploop/Makefile b/dev/tcploop/Makefile index fd80af9b9..6d0a0c259 100644 --- a/dev/tcploop/Makefile +++ b/dev/tcploop/Makefile @@ -1,27 +1,11 @@ +include ../../include/make/verbose.mk + CC = gcc OPTIMIZE = -O2 -g DEFINE = INCLUDE = OBJS = tcploop -V = 0 -Q = @ -ifeq ($V,1) -Q= -endif - -ifeq ($V,1) -cmd_CC = $(CC) -else -ifeq (3.81,$(firstword $(sort $(MAKE_VERSION) 3.81))) -# 3.81 or above -cmd_CC = $(info $ CC $@) $(Q)$(CC) -else -# 3.80 or older -cmd_CC = $(Q)echo " CC $@";$(CC) -endif -endif - tcploop: tcploop.c $(cmd_CC) $(OPTIMIZE) $(DEFINE) $(INCLUDE) -o $@ $^ diff --git a/include/make/verbose.mk b/include/make/verbose.mk new file mode 100644 index 000000000..653974754 --- /dev/null +++ b/include/make/verbose.mk @@ -0,0 +1,27 @@ +# verbosity: pass V=1 for verbose shell invocation +V = 0 +Q = @ +ifeq ($V,1) +Q= +endif + +# Some common commands such as CC/LD/AR are redefined with a cmd_ equivalent +# and are either mapped to a silent rule just indicating what is being done, +# or to themselves depending on the verbosity level. +ifeq ($V,1) +cmd_CC = $(CC) +cmd_LD = $(LD) +cmd_AR = $(AR) +else +ifeq (3.81,$(firstword $(sort $(MAKE_VERSION) 3.81))) +# 3.81 or above +cmd_CC = $(info $ CC $@) $(Q)$(CC) +cmd_LD = $(info $ LD $@) $(Q)$(LD) +cmd_AR = $(info $ AR $@) $(Q)$(AR) +else +# 3.80 or older +cmd_CC = $(Q)echo " CC $@";$(CC) +cmd_LD = $(Q)echo " LD $@";$(LD) +cmd_AR = $(Q)echo " AR $@";$(AR) +endif +endif