From 2c7b9130499d17a657684fb3c762d608b50d139e Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 5 Sep 2022 15:56:58 +0200 Subject: make: update make.tmpl Add new define 'newline' for use in 'foreach()' Add new $(SHOW) for makefile printing output Add 'make print-VAR' for easier debugging of Makefiles' variables. --- make.tmpl.in | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'make.tmpl.in') diff --git a/make.tmpl.in b/make.tmpl.in index 427fee596..a390553a4 100644 --- a/make.tmpl.in +++ b/make.tmpl.in @@ -13,15 +13,10 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -ifneq ("@SILENT_RULES@","yes") - V ?= 1 -endif -ifeq ($(V),1) - Q= -else - Q=@ -endif +V ?= $(if ("@SILENT_RULES@","yes"),,1) +Q := $(if $(V),,@) +SHOW := $(if $(V),@true,@echo) SHELL = @SHELL@ @@ -134,6 +129,18 @@ PYTHON_PREFIX = $(prefix) python2dir = @PYTHON2DIR@ python3dir = @PYTHON3DIR@ +# Define macro NewLine for use in $(foreach) with 2 blank lines +ifeq (1, $(firstword $(V))) +define newline + + +endef +else +define newline +; +endef +endif + USRLIB_RELPATH = $(shell echo $(abspath $(usrlibdir) $(libdir)) | \ $(AWK) -f $(top_srcdir)/scripts/relpath.awk) @@ -148,6 +155,17 @@ DEFAULT_RUN_DIR = @DEFAULT_RUN_DIR@ DEFAULT_PID_DIR = @DEFAULT_PID_DIR@ DEFAULT_MANGLING = @MANGLING@ +#---------------------------------------------------------------------- +# From http://blog.melski.net/tag/debugging-makefiles/ +# +# Usage: make print-CC print-CXX print-LD +#---------------------------------------------------------------------- +print-%: + @echo '$*=$($*)' + @echo ' origin = $(origin $*)' + @echo ' flavor = $(flavor $*)' + @echo ' value = $(value $*)' + # Setup vpath search paths for some suffixes vpath %.c $(srcdir) vpath %.cpp $(srcdir) @@ -164,6 +182,10 @@ ifndef MAKEFLAGS MAKEFLAGS = @JOBS@ endif +ifneq (1, $(firstword $(V))) +MAKEFLAGS += --no-print-directory +endif + # Handle installation of files ifeq ("@WRITE_INSTALL@", "yes") # leaving defaults @@ -582,6 +604,7 @@ endif ifeq ("$(USE_TRACKING)","yes") ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean lcov lcov-reset \ help check check_local check_cluster check_lvmpolld run-unit-test tags)) +.SECONDARY: # Note: no tabs before -include -include $(SOURCES:.c=.d) $(SOURCES2:.c=.d) $(CXXSOURCES:.cpp=.d) endif -- cgit v1.2.1