Skip to content

Commit

Permalink
Improve Makefile printing
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
jasmin-j committed May 25, 2017
1 parent 3e0774c commit 260f2cf
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ CVS
*.so
gen_version_suffix.h
pages/*.cpp
css/*.cpp
javascript/*.cpp
po/*.mo
po/live.pot
.dependencies
Expand Down
37 changes: 23 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 }')
Expand Down Expand Up @@ -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
Expand All @@ -123,7 +127,7 @@ endif
### For all recursive Targets:

recursive-%:
@$(MAKE) $*
@$(MAKE) --no-print-directory $*

### Internationalization (I18N):
PODIR := po
Expand All @@ -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")
Expand All @@ -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
Expand All @@ -172,26 +179,26 @@ 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)
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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
15 changes: 12 additions & 3 deletions css/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
38 changes: 38 additions & 0 deletions global.mk
Original file line number Diff line number Diff line change
@@ -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

15 changes: 12 additions & 3 deletions javascript/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 10 additions & 3 deletions pages/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) $< > $@
Expand All @@ -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
Expand Down

0 comments on commit 260f2cf

Please sign in to comment.