From f148a9aed7d0c45daf9ce921097e636804c1eb1d Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Thu, 24 Apr 2014 16:23:19 +0200 Subject: [PATCH] Enable colors in Makefile --- Makefile | 36 ++++++++++++++++++++---------------- colors.mk | 25 +++++++++++++++++++++++++ config.mk | 2 ++ doc/Makefile | 5 +++++ 4 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 colors.mk diff --git a/Makefile b/Makefile index 9888151..a08427a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ # See LICENSE file for license and copyright information include config.mk +include colors.mk include common.mk PROJECT = zathura @@ -75,12 +76,12 @@ dbus-interface-definitions.c: data/org.pwmt.zathura.xml $(QUIET)mv dbus-interface-definitions.c.tmp dbus-interface-definitions.c %.o: %.c - $(ECHO) CC $< - @mkdir -p .depend + $(call colorecho,CC,$<) + $(QUIET) mkdir -p .depend $(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep %.do: %.c - $(ECHO) CC $< + $(call colorecho,CC,$<) @mkdir -p .depend $(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep @@ -88,7 +89,7 @@ ${OBJECTS} ${DOBJECTS}: config.mk version.h \ .version-checks/GIRARA .version-checks/GLIB .version-checks/GTK ${PROJECT}: ${OBJECTS} - $(ECHO) CC -o $@ + $(call colorecho,CC,$@) $(QUIET)${CC} ${SFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS} clean: @@ -113,7 +114,7 @@ endif $(QUIET)$(MAKE) -C doc clean ${PROJECT}-debug: ${DOBJECTS} - $(ECHO) CC -o $@ + $(call colorecho,CC,$@) $(QUIET)${CC} ${LDFLAGS} -o $@ ${DOBJECTS} ${LIBS} debug: ${PROJECT}-debug @@ -143,6 +144,7 @@ dist: clean build-manpages $(QUIET)mkdir -p ${PROJECT}-${VERSION}/tests $(QUIET)mkdir -p ${PROJECT}-${VERSION}/po $(QUIET)mkdir -p ${PROJECT}-${VERSION}/doc + $(QUIET)cp LICENSE Makefile config.mk common.mk README AUTHORS \ ${PROJECT}.1.rst ${PROJECT}rc.5.rst ${OSOURCE} ${HEADER} ${PROJECT}.pc.in \ ${PROJECT}.desktop version.h.in \ @@ -188,7 +190,7 @@ build-manpages: $(QUIET)${MAKE} -C doc man install-manpages: build-manpages - $(ECHO) installing manual pages + $(call colorecho,INSTALL,"man pages") $(QUIET)mkdir -m 755 -p ${DESTDIR}${MANPREFIX}/man1 ${DESTDIR}${MANPREFIX}/man5 ifneq "$(wildcard ./doc/_build/man/${PROJECT}.1)" "" $(QUIET)install -m 644 ./doc/_build/man/${PROJECT}.1 ${DESTDIR}${MANPREFIX}/man1 @@ -198,42 +200,44 @@ ifneq "$(wildcard ./doc/_build/man/${PROJECT}rc.5)" "" endif install-headers: ${PROJECT}.pc - $(ECHO) installing header files + $(call colorecho,INSTALL,"header files") $(QUIET)mkdir -m 755 -p ${DESTDIR}${INCLUDEDIR}/${PROJECT} $(QUIET)install -m 644 ${HEADERINST} ${DESTDIR}${INCLUDEDIR}/${PROJECT} - $(ECHO) installing pkgconfig file + + $(call colorecho,INSTALL,"pkgconfig file") $(QUIET)mkdir -m 755 -p ${DESTDIR}${LIBDIR}/pkgconfig $(QUIET)install -m 644 ${PROJECT}.pc ${DESTDIR}${LIBDIR}/pkgconfig install-dbus: - $(ECHO) installing D-Bus interface definitions + $(call colorecho,INSTALL,"D-Bus interface definitions") $(QUIET)mkdir -m 755 -p $(DESTDIR)$(DBUSINTERFACEDIR) $(QUIET)install -m 644 data/org.pwmt.zathura.xml $(DESTDIR)$(DBUSINTERFACEDIR) install: all install-headers install-manpages install-dbus - $(ECHO) installing executable file + $(call colorecho,INSTALL,"executeable file") $(QUIET)mkdir -m 755 -p ${DESTDIR}${PREFIX}/bin $(QUIET)install -m 755 ${PROJECT} ${DESTDIR}${PREFIX}/bin $(QUIET)mkdir -m 755 -p ${DESTDIR}${DESKTOPPREFIX} - $(ECHO) installing desktop file + $(call colorecho,INSTALL,"desktop file") $(QUIET)install -m 644 ${PROJECT}.desktop ${DESTDIR}${DESKTOPPREFIX} $(MAKE) -C po install uninstall-headers: - $(ECHO) removing header files + $(call colorecho,UNINSTALL,"header files") $(QUIET)rm -rf ${DESTDIR}${INCLUDEDIR}/${PROJECT} - $(ECHO) removing pkgconfig file + $(call colorecho,UNINSTALL,"pkgconfig file") $(QUIET)rm -f ${DESTDIR}${LIBDIR}/pkgconfig/${PROJECT}.pc uninstall: uninstall-headers $(ECHO) removing executable file + $(call colorecho,UNINSTALL,"executeable") $(QUIET)rm -f ${DESTDIR}${PREFIX}/bin/${PROJECT} - $(ECHO) removing manual pages + $(call colorecho,UNINSTALL,"man pages") $(QUIET)rm -f ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1 $(QUIET)rm -f ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5 - $(ECHO) removing desktop file + $(call colorecho,UNINSTALL,"desktop file") $(QUIET)rm -f ${DESTDIR}${DESKTOPPREFIX}/${PROJECT}.desktop - $(ECHO) removing D-Bus interface definitions + $(call colorecho,UNINSTALL,"D-Bus interface definitions") $(QUIET)rm -f $(DESTDIR)$(DBUSINTERFACEDIR)/org.pwmt.zathura.xml $(MAKE) -C po uninstall diff --git a/colors.mk b/colors.mk new file mode 100644 index 0000000..7c00b36 --- /dev/null +++ b/colors.mk @@ -0,0 +1,25 @@ +# See LICENSE file for license and copyright information +# + +TPUT ?= /usr/bin/tput +TPUT_AVAILABLE ?= $(shell ${TPUT} -V 2>/dev/null) + +ifdef TPUT_AVAILABLE +ifeq ($(COLOR),1) +COLOR_NORMAL = `$(TPUT) sgr0` +COLOR_ACTION = `$(TPUT) bold``$(TPUT) setaf 3` +COLOR_COMMENT = `$(TPUT) bold``$(TPUT) setaf 2` +COLOR_BRACKET = `$(TPUT) setaf 4` +define colorecho + @echo $(COLOR_BRACKET)" ["$(COLOR_ACTION)$1$(COLOR_BRACKET)"] "$(COLOR_COMMENT)$2$(COLOR_BRACKET) $(COLOR_NORMAL) +endef +else +define colorecho + @echo " [$1]" $2 +endef +endif +else +define colorecho + @echo " [$1]" $2 +endef +endif diff --git a/config.mk b/config.mk index 79592a9..e3d2cef 100644 --- a/config.mk +++ b/config.mk @@ -104,3 +104,5 @@ VALGRIND_SUPPRESSION_FILE = zathura.suppression # set to something != 0 if you want verbose build output VERBOSE ?= 0 +# colors +COLOR ?= 1 diff --git a/doc/Makefile b/doc/Makefile index 058f968..ea26b37 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -2,6 +2,7 @@ # include ../config.mk include ../common.mk +include ../colors.mk include config.mk ifeq ($(shell which $(SPHINX_BIN) >/dev/null 2>&1; echo $$?), 1) @@ -14,15 +15,19 @@ init: $(QUIET)mkdir -p $(SPHINX_BUILDDIR)/ clean: + $(call colorecho,RM,doc/$(SPHINX_BUILDDIR)) $(QUIET)rm -rf $(SPHINX_BUILDDIR)/ html: doxygen + $(call colorecho,DOC,"Build HTML documentation") $(QUIET)$(SPHINX_BIN) -b html $(SPHINX_OPTS) $(SPHINX_BUILDDIR)/html man: doxygen + $(call colorecho,DOC,"Build man pages") $(QUIET)$(SPHINX_BIN) -b man $(SPHINX_OPTS) $(SPHINX_BUILDDIR)/man doxygen: init + $(call colorecho,DOC,"Run doxygen") $(QUIET)$(DOXYGEN_BIN) Doxyfile .PHONY: clean html man