From 260f2cf0cb7b724c9ca3f662529e7b6bbb9cbbb6 Mon Sep 17 00:00:00 2001 From: Jasmin Jessich Date: Thu, 25 May 2017 22:21:13 +0200 Subject: [PATCH] Improve Makefile printing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added global.mk with common makefile print macros. Use VERBOSE=1 on the command line to show executed commands. - Removed recursion printing of make. - Suppress “nothing to be done for 'all'” message from make. - gen_version_suffix.h is now always created. --- .gitignore | 2 ++ Makefile | 37 +++++++++++++++++++++++-------------- css/Makefile | 15 ++++++++++++--- global.mk | 38 ++++++++++++++++++++++++++++++++++++++ javascript/Makefile | 15 ++++++++++++--- pages/Makefile | 13 ++++++++++--- 6 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 global.mk diff --git a/.gitignore b/.gitignore index 2ca3fe08..8d534ab5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ CVS *.so gen_version_suffix.h pages/*.cpp +css/*.cpp +javascript/*.cpp po/*.mo po/live.pot .dependencies diff --git a/Makefile b/Makefile index aee7d25d..090b6b6f 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,8 @@ APIVERSION := $(call PKGCFG,apiversion) ### Allow user defined options to overwrite defaults: -include $(PLGCFG) +include global.mk + ### Determine tntnet and cxxtools versions: TNTVERSION = $(shell tntnet-config --version | sed -e's/\.//g' | sed -e's/pre.*//g' | awk '/^..$$/ { print $$1."000"} /^...$$/ { print $$1."00"} /^....$$/ { print $$1."0" } /^.....$$/ { print $$1 }') CXXTOOLVER = $(shell cxxtools-config --version | sed -e's/\.//g' | sed -e's/pre.*//g' | awk '/^..$$/ { print $$1."000"} /^...$$/ { print $$1."00"} /^....$$/ { print $$1."0" } /^.....$$/ { print $$1 }') @@ -96,19 +98,21 @@ SUBDIRS := $(WEB_DIR_PAGES) $(WEB_DIR_CSS) $(WEB_DIR_JAVA) ### The main target: .PHONY: all all: lib i18n + @true ### Implicit rules: $(WEB_DIR_PAGES)/%.o: $(WEB_DIR_PAGES)/%.cpp $(WEB_DIR_PAGES)/%.ecpp - @$(MAKE) -C $(WEB_DIR_PAGES) PLUGINFEATURES="$(PLUGINFEATURES)" $(notdir $@) + @$(MAKE) -C $(WEB_DIR_PAGES) --no-print-directory PLUGINFEATURES="$(PLUGINFEATURES)" $(notdir $@) $(WEB_DIR_CSS)/%.o: - @$(MAKE) -C $(WEB_DIR_CSS) PLUGINFEATURES="$(PLUGINFEATURES)" $(notdir $@) + @$(MAKE) -C $(WEB_DIR_CSS) --no-print-directory PLUGINFEATURES="$(PLUGINFEATURES)" $(notdir $@) $(WEB_DIR_JAVA)/%.o: - @$(MAKE) -C $(WEB_DIR_JAVA) PLUGINFEATURES="$(PLUGINFEATURES)" $(notdir $@) + @$(MAKE) -C $(WEB_DIR_JAVA) --no-print-directory PLUGINFEATURES="$(PLUGINFEATURES)" $(notdir $@) %.o: %.cpp - $(CXX) $(CXXFLAGS) -c $(DEFINES) $(PLUGINFEATURES) $(INCLUDES) $< + $(call PRETTY_PRINT,"CC" $@) + $(Q)$(CXX) $(CXXFLAGS) -c $(DEFINES) $(PLUGINFEATURES) $(INCLUDES) $< ### Dependencies: MAKEDEP = $(CXX) -MM -MG @@ -123,7 +127,7 @@ endif ### For all recursive Targets: recursive-%: - @$(MAKE) $* + @$(MAKE) --no-print-directory $* ### Internationalization (I18N): PODIR := po @@ -134,10 +138,12 @@ I18Npot := $(PODIR)/$(PLUGIN).pot I18Npot_deps = $(PLUGINSRCS) $(wildcard $(WEB_DIR_PAGES)/*.cpp) setup.h epg_events.h $(I18Npot): $(I18Npot_deps) - xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --omit-header -o $@ $(I18Npot_deps) + $(call PRETTY_PRINT,"GT" $@) + $(Q)xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --omit-header -o $@ $(I18Npot_deps) .PHONY: I18Nmo I18Nmo: $(I18Nmo) + @true %.mo: %.po $(if $(DISABLE_I18Nmo_txt),,@echo "Creating *.mo") @@ -157,6 +163,7 @@ $(I18Nmsgs): $(DESTDIR)$(LOCDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo .PHONY: inst_I18Nmsg inst_I18Nmsg: $(I18Nmsgs) + @true # When building in parallel, this will tell make to keep an order in the steps recursive-I18Nmo: subdirs @@ -172,9 +179,7 @@ install-i18n: i18n recursive-inst_I18Nmsg $(VERSIONSUFFIX): FORCE ifneq ($(MAKECMDGOALS),clean) -ifeq ($(MAKELEVEL),$(filter $(MAKELEVEL),0 1)) - ./buildutil/version-util $(VERSIONSUFFIX) || ./buildutil/version-util -F $(VERSIONSUFFIX) -endif + @./buildutil/version-util $(VERSIONSUFFIX) || ./buildutil/version-util -F $(VERSIONSUFFIX) endif .PHONY: subdirs $(SUBDIRS) @@ -182,16 +187,18 @@ subdirs: $(SUBDIRS) $(SUBDIRS): ifneq ($(MAKECMDGOALS),clean) - @$(MAKE) -C $@ PLUGINFEATURES="$(PLUGINFEATURES)" all + @$(MAKE) -C $@ --no-print-directory PLUGINFEATURES="$(PLUGINFEATURES)" all else - @$(MAKE) -C $@ clean + @$(MAKE) -C $@ --no-print-directory clean endif $(SOFILE): $(PLUGINOBJS) $(WEBLIBS) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(PLUGINOBJS) -Wl,--whole-archive $(WEBLIBS) -Wl,--no-whole-archive $(LIBS) -o $@ + $(call PRETTY_PRINT,"LD" $@) + $(Q)$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(PLUGINOBJS) -Wl,--whole-archive $(WEBLIBS) -Wl,--no-whole-archive $(LIBS) -o $@ .PHONY: sofile sofile: $(SOFILE) + @true # When building in parallel, this will tell make to keep an order in the steps recursive-sofile: subdirs @@ -207,7 +214,8 @@ lib: $(VERSIONSUFFIX) subdirs $(PLUGINOBJS) recursive-sofile soinst: $(SOINST) $(SOINST): $(SOFILE) - install -D $< $@ + $(call PRETTY_PRINT,"Installing" $<) + $(Q)install -D $< $@ .PHONY: install-lib install-lib: lib recursive-soinst @@ -217,7 +225,7 @@ install: install-lib install-i18n .PHONY: dist dist: $(I18Npo) - $(MAKE) clean + $(MAKE) --no-print-directory clean @-rm -rf $(TMPDIR)/$(ARCHIVE) @mkdir $(TMPDIR)/$(ARCHIVE) @cp -a * $(TMPDIR)/$(ARCHIVE) @@ -227,6 +235,7 @@ dist: $(I18Npo) .PHONY: clean clean: subdirs + $(call PRETTY_PRINT,"CLN top") @-rm -f $(I18Nmo) $(I18Npot) @-rm -f $(PLUGINOBJS) $(DEPFILE) *.so *.tgz core* *~ @-rm -f $(VERSIONSUFFIX) diff --git a/css/Makefile b/css/Makefile index 0411b303..9655703a 100644 --- a/css/Makefile +++ b/css/Makefile @@ -11,22 +11,31 @@ INCLUDES += -I$(VDRDIR)/include -I.. OBJS := styles.o SRCS := $(patsubst %.o,%.cpp,$(OBJS)) +include ../global.mk + ### The main target: all: libcss.a + @true ### Implicit rules: %.o: %.cpp - $(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(PLUGINFEATURES) $(INCLUDES) $< + $(call PRETTY_PRINT,"CC css/" $@) + $(Q)$(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(PLUGINFEATURES) $(INCLUDES) $< %.cpp: %.css - $(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_CSS) -b -m "text/css" $< + $(call PRETTY_PRINT,"ECPP css/" $@) + $(Q)$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_CSS) -b -m "text/css" $< ### Targets: libcss.a: $(OBJS) - $(AR) r $@ $^ + $(call PRETTY_PRINT,"AR css/" $@) + $(Q)$(AR) r $@ $^ $(AR_NUL) clean: + $(call PRETTY_PRINT,"CLN css/") @rm -f *~ *.o core* libcss.a $(SRCS) dist: clean @echo "Nothing to do for distribution here ..." + +.PRECIOUS: $(SRCS) diff --git a/global.mk b/global.mk new file mode 100644 index 00000000..1c74f37f --- /dev/null +++ b/global.mk @@ -0,0 +1,38 @@ +# +# Add macros and definitions which shall be available for all Makefiles +# This might be added to VDR main directory in the future + +# build mode (0 - non-verbose, 1 - verbose) +VERBOSE ?= 0 + +# Desplay percentage (0 - no percentage, 1 - print xxx% (not 100% accurate!)) +#WITH_PERCENT ?= 0 +# does not work currently +override WITH_PERCENT := 0 + +# pretty print macros + +ifeq ($(WITH_PERCENT),1) + ifndef ECHO + I := i + TARGET_COUNTER = $(words $(I)) $(eval I += i) + TOTAL_TARGETS := $(shell $(MAKE) $(MAKECMDGOALS) --dry-run --file=$(firstword $(MAKEFILE_LIST)) \ + --no-print-directory --no-builtin-rules --no-builtin-variables ECHO="COUNTTHIS" | grep -c "COUNTTHIS") + ECHO = echo "[$(shell expr " $(shell echo $$((${TARGET_COUNTER} * 100 / ${TOTAL_TARGETS})))" : '.*\(...\)$$')%]" + endif +else + ECHO = echo +endif + +ifeq ($(VERBOSE),0) + # Have a look to the VDR Makefile hw to use these macros in Plugins. + + Q = @ + PRETTY_PRINT = @$(ECHO) $(1) + AR_NUL = > /dev/null 2>&1 +else + Q = + PRETTY_PRINT = + AR_NUL = +endif + diff --git a/javascript/Makefile b/javascript/Makefile index 08f0ad70..5465c3cb 100644 --- a/javascript/Makefile +++ b/javascript/Makefile @@ -11,22 +11,31 @@ INCLUDES += -I$(VDRDIR)/include -I.. OBJS := treeview.o SRCS := $(patsubst %.o,%.cpp,$(OBJS)) +include ../global.mk + ### The main target: all: libjavascript.a + @true ### Implicit rules: %.o: %.cpp - $(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(PLUGINFEATURES) $(INCLUDES) $< + $(call PRETTY_PRINT,"CC javascript/" $@) + $(Q)$(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(PLUGINFEATURES) $(INCLUDES) $< %.cpp: %.js - $(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_JS) -b -m "text/javascript" $< + $(call PRETTY_PRINT,"ECPP javascript/" $@) + $(Q)$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_JS) -b -m "text/javascript" $< ### Targets: libjavascript.a: $(OBJS) - $(AR) r $@ $^ + $(call PRETTY_PRINT,"AR javascript/" $@) + $(Q)$(AR) r $@ $^ $(AR_NUL) clean: + $(call PRETTY_PRINT,"CLN javascript/") @rm -f *~ *.o core* libjavascript.a $(SRCS) dist: clean @echo "Nothing to do for distribution here ..." + +.PRECIOUS: $(SRCS) diff --git a/pages/Makefile b/pages/Makefile index 018f2562..ae0710e1 100644 --- a/pages/Makefile +++ b/pages/Makefile @@ -20,16 +20,21 @@ SRCS := $(patsubst %.o,%.cpp,$(OBJS)) ESRCS := $(patsubst %.o,%.ecpp,$(OBJS)) ESRCS_DEPS := $(patsubst %.o,.%.edep,$(OBJS)) +include ../global.mk + ### The main target: all: libpages.a + @true ### Implicit rules: %.o: %.cpp - $(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(PLUGINFEATURES) $(INCLUDES) $< + $(call PRETTY_PRINT,"CC pages/" $@) + $(Q)$(CXX) $(CXXFLAGS) $(TNTFLAGS) -c $(DEFINES) $(PLUGINFEATURES) $(INCLUDES) $< %.cpp: %.ecpp - $(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_CPP) $< + $(call PRETTY_PRINT,"ECPP pages/" $@) + $(Q)$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_CPP) $< .%.edep: %.ecpp @$(ECPPC) -M $(ECPPFLAGS) $(ECPPFLAGS_CPP) $< > $@ @@ -47,9 +52,11 @@ endif ### Targets: libpages.a: $(OBJS) - $(AR) r $@ $^ + $(call PRETTY_PRINT,"AR pages/" $@) + $(Q)$(AR) r $@ $^ $(AR_NUL) clean: + $(call PRETTY_PRINT,"CLN pages/") @rm -f *~ *.o core* libpages.a $(SRCS) $(DEPFILE) $(ESRCS_DEPS) dist: clean