From 1ea3ad28aef1620005e64e44b61d84490e530523 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 25 Mar 2018 09:21:37 +0200 Subject: [PATCH] Add quiet mode to the Makefile system The standard Makefile output is very noisy and it can be difficult to filter the interesting information from this noise. In quiet mode the standard Makefile output will be suppressed and instead a short human readable description of the current task is shown. E.g. > make adv7511.zed Building axi_clkgen library [library/axi_clkgen/axi_clkgen_ip.log] ... OK Building axi_hdmi_tx library [library/axi_hdmi_tx/axi_hdmi_tx_ip.log] ... OK Building axi_i2s_adi library [library/axi_i2s_adi/axi_i2s_adi_ip.log] ... OK Building axi_spdif_tx library [library/axi_spdif_tx/axi_spdif_tx_ip.log] ... OK Building util_i2c_mixer library [library/util_i2c_mixer/util_i2c_mixer_ip.log] ... OK Building adv7511_zed project [projects/adv7511/zed/adv7511_zed_vivado.log] ... OK Quiet mode is enabled by default since it generates a more human readable output. It can be disabled by passing VERBOSE=1 to make or setting the VERBOSE environment variable to 1 before calling make. E.g. > make adv7511.zed VERBOSE=1 make[1]: Entering directory 'library/axi_clkgen' rm -rf *.cache *.data *.xpr *.log component.xml *.jou xgui *.ip_user_files *.srcs *.hw *.sim .Xil .timestamp_altera vivado -mode batch -source axi_clkgen_ip.tcl >> axi_clkgen_ip.log 2>&1 ... Signed-off-by: Lars-Peter Clausen --- Makefile | 3 ++ library/Makefile | 2 ++ library/interfaces/Makefile | 11 ++++-- library/scripts/library.mk | 11 ++++-- projects/scripts/project-altera.mk | 11 ++++-- projects/scripts/project-toplevel.mk | 5 +++ projects/scripts/project-xilinx.mk | 11 ++++-- quiet.mk | 50 ++++++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 quiet.mk diff --git a/Makefile b/Makefile index df60677e4..4d2d0434d 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ ## Auto-generated, do not modify! #################################################################################### #################################################################################### + +include quiet.mk + help: @echo "" @echo "Please specify a target." diff --git a/library/Makefile b/library/Makefile index 22df69e16..3f07c61dd 100644 --- a/library/Makefile +++ b/library/Makefile @@ -5,6 +5,8 @@ #################################################################################### #################################################################################### +include ../quiet.mk + .PHONY: all lib clean clean-all all: lib diff --git a/library/interfaces/Makefile b/library/interfaces/Makefile index a67554d42..5e69904ad 100644 --- a/library/interfaces/Makefile +++ b/library/interfaces/Makefile @@ -5,6 +5,8 @@ #################################################################################### #################################################################################### +include ../../quiet.mk + M_DEPS := interfaces_ip.tcl M_DEPS += ../scripts/adi_env.tcl M_DEPS += ../scripts/adi_ip.tcl @@ -36,10 +38,15 @@ xilinx: if_xcvr_cm.xml if_xcvr_cm_rtl.xml if_xcvr_ch.xml if_xcvr_ch_rtl.xml if_g clean:clean-all clean-all: - rm -rf $(M_FLIST) + $(call clean, \ + $(M_FLIST), \ + interface definitions) %.xml: $(M_DEPS) - $(M_VIVADO) interfaces_ip.tcl >> interfaces_ip.log 2>&1 + $(call build, \ + $(M_VIVADO) interfaces_ip.tcl, \ + interfaces_ip.log, \ + interface definitions) #################################################################################### #################################################################################### diff --git a/library/scripts/library.mk b/library/scripts/library.mk index 8d56498f9..e0a4b2701 100644 --- a/library/scripts/library.mk +++ b/library/scripts/library.mk @@ -5,6 +5,8 @@ # Assumes this file is in library/scripts/library.mk HDL_LIBRARY_PATH := $(subst scripts/library.mk,,$(lastword $(MAKEFILE_LIST))) +include $(HDL_LIBRARY_PATH)../quiet.mk + VIVADO := vivado -mode batch -source CLEAN_TARGET := *.cache @@ -30,7 +32,9 @@ all: altera xilinx clean: clean-all clean-all: - rm -rf $(CLEAN_TARGET) + $(call clean, \ + $(CLEAN_TARGET), \ + $(HL)$(LIBRARY_NAME)$(NC) library) ifneq ($(ALTERA_DEPS),) @@ -59,7 +63,10 @@ xilinx: xilinx_dep component.xml component.xml: $(XILINX_DEPS) -rm -rf $(CLEAN_TARGET) - $(VIVADO) $(LIBRARY_NAME)_ip.tcl >> $(LIBRARY_NAME)_ip.log 2>&1 + $(call build, \ + $(VIVADO) $(LIBRARY_NAME)_ip.tcl, \ + $(LIBRARY_NAME)_ip.log, \ + $(HL)$(LIBRARY_NAME)$(NC) library) xilinx_dep: @for lib in $(XILINX_LIB_DEPS); do \ diff --git a/projects/scripts/project-altera.mk b/projects/scripts/project-altera.mk index def2f4052..8418881f7 100644 --- a/projects/scripts/project-altera.mk +++ b/projects/scripts/project-altera.mk @@ -6,6 +6,8 @@ HDL_PROJECT_PATH := $(subst scripts/project-altera.mk,,$(lastword $(MAKEFILE_LIST))) HDL_LIBRARY_PATH := $(HDL_PROJECT_PATH)../library/ +include $(HDL_PROJECT_PATH)../quiet.mk + ifeq ($(NIOS2_MMU),) NIOS2_MMU := 1 endif @@ -62,7 +64,9 @@ all: lib $(PROJECT_NAME).sof clean: - rm -rf $(CLEAN_TARGET) + $(call clean, \ + $(CLEAN_TARGET), \ + $(HL)$(PROJECT_NAME)$(NC) project) clean-all: clean @for lib in $(LIB_DEPS); do \ @@ -71,7 +75,10 @@ clean-all: clean $(PROJECT_NAME).sof: $(M_DEPS) -rm -rf $(CLEAN_TARGET) - $(ALTERA) system_project.tcl >> $(PROJECT_NAME)_quartus.log 2>&1 + $(call build,\ + $(ALTERA) system_project.tcl, \ + $(PROJECT_NAME)_quartus.log, \ + $(HL)$(PROJECT_NAME)$(NC)) lib: @for lib in $(LIB_DEPS); do \ diff --git a/projects/scripts/project-toplevel.mk b/projects/scripts/project-toplevel.mk index f648940fa..ad8dcd8e6 100644 --- a/projects/scripts/project-toplevel.mk +++ b/projects/scripts/project-toplevel.mk @@ -2,6 +2,11 @@ ## Copyright 2018(c) Analog Devices, Inc. #################################################################################### +# Assumes this file is in projects/scripts/project-toplevel.mk +HDL_PROJECT_PATH := $(subst scripts/project-toplevel.mk,,$(lastword $(MAKEFILE_LIST))) + +include $(HDL_PROJECT_PATH)../quiet.mk + SUBDIRS := $(dir $(wildcard */Makefile)) # Create virtual targets "$project/all", "$project/clean", "$project/clean-all" diff --git a/projects/scripts/project-xilinx.mk b/projects/scripts/project-xilinx.mk index 161ce4794..517de9fd5 100644 --- a/projects/scripts/project-xilinx.mk +++ b/projects/scripts/project-xilinx.mk @@ -6,6 +6,8 @@ HDL_PROJECT_PATH := $(subst scripts/project-xilinx.mk,,$(lastword $(MAKEFILE_LIST))) HDL_LIBRARY_PATH := $(HDL_PROJECT_PATH)../library/ +include $(HDL_PROJECT_PATH)../quiet.mk + VIVADO := vivado -mode batch -source CLEAN_TARGET := *.cache @@ -38,7 +40,9 @@ M_DEPS += $(foreach dep,$(LIB_DEPS),$(HDL_LIBRARY_PATH)$(dep)/component.xml) all: lib $(PROJECT_NAME).sdk/system_top.hdf clean: - rm -rf $(CLEAN_TARGET) + $(call clean, \ + $(CLEAN_TARGET), \ + $(HL)$(PROJECT_NAME)$(NC) project) clean-all: clean @for lib in $(LIB_DEPS); do \ @@ -47,7 +51,10 @@ clean-all: clean $(PROJECT_NAME).sdk/system_top.hdf: $(M_DEPS) -rm -rf $(CLEAN_TARGET) - $(VIVADO) system_project.tcl >> $(PROJECT_NAME)_vivado.log 2>&1 + $(call build, \ + $(VIVADO) system_project.tcl, \ + $(PROJECT_NAME)_vivado.log, \ + $(HL)$(PROJECT_NAME)$(NC) project) lib: @for lib in $(LIB_DEPS); do \ diff --git a/quiet.mk b/quiet.mk new file mode 100644 index 000000000..4f804f6dd --- /dev/null +++ b/quiet.mk @@ -0,0 +1,50 @@ +#################################################################################### +## Copyright 2018(c) Analog Devices, Inc. +#################################################################################### + +ifdef MAKE_TERMOUT + ESC:=$(shell printf '\033') + GREEN:=$(ESC)[1;32m + RED:=$(ESC)[1;31m + HL:=$(ESC)[0;33m + NC:=$(ESC)[0m +else + GREEN:= + RED:= + HL:= + NC:= +endif + +ifneq ($(VERBOSE),1) + MAKEFLAGS += --quiet + + # build - Run a build command + # $(1): Command to execute + # $(2): Logfile name + # $(3): Textual description of the task + define build + @echo -n "Building $(strip $(3)) [$(HL)$(CURDIR)/$(strip $(2))$(NC)] ..." + $(strip $(1)) >> $(strip $(2)) 2>&1; \ + (ERR=$$?; if [ $$ERR = 0 ]; then \ + echo " $(GREEN)OK$(NC)"; \ + else \ + echo " $(RED)FAILED$(NC)\nFor details see $(HL)$(CURDIR)/$(strip $(2))$(NC)\n"; \ + fi; exit $$ERR) + endef + + # clean - Run a clean command + # $(1): Files to remove + # $(2): Textural description of the task + define clean + @echo "Cleaning $(strip $(2)) ..." + -rm -rf $(strip $(1)) + endef +else + define build + $(strip $(1)) >> $(strip $(2)) 2>&1 + endef + + define clean + -rm -rf $(strip $(1)) + endef +endif