]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: makefile: move default verbosity settings to include/make/verbose.mk
authorWilly Tarreau <w@1wt.eu>
Thu, 17 Nov 2022 07:23:10 +0000 (08:23 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Nov 2022 09:56:35 +0000 (10:56 +0100)
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
dev/poll/Makefile
dev/tcploop/Makefile
include/make/verbose.mk [new file with mode: 0644]

index 6902c37c07a54a2c30f4393d506613d0c9c46547..8baed62121bac16584963c4b6bc9e95e93085436 100644 (file)
--- a/Makefile
+++ b/Makefile
 #   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."
index 9a493bb711f0913eeeaa7854044d7bb706c9207a..0247099ed711e5209092668a06947af01a00b56a 100644 (file)
@@ -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 $@ $^
 
index fd80af9b9c932898a8947d3b35ef84bfeadec5dc..6d0a0c2591354be7143be7a7e4110706f06027a4 100644 (file)
@@ -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 (file)
index 0000000..6539747
--- /dev/null
@@ -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