# Centralised control over noisy or quiet build output.
# Usage: $(eval $(call set_quiet_build))
define set_quiet_build

# Default to quieter builds. 
# Specify V=1 on the command line or in the environment for verbose builds
#
ifneq ("$$(origin V)", "command line")
  ifneq ("$$(origin V)", "environment")
    ifneq ("$$(origin V)", "file")
      ifeq (,$$(findstring s,$$(MAKEFLAGS)))
        export ARTIMI_QUIETBUILD=1
        MAKEFLAGS+=-s
      endif
    endif
  endif
endif

ifeq ($$(ARTIMI_QUIETBUILD),1)
export QUIETMSG:=@echo
export STDOUT:=
MAKEFLAGS+=-s
else
export QUIETMSG:=@\#
export STDOUT:=>/dev/null
endif
endef

# Export message output functions 
export set_quiet_build 

# Helper to include a string of text iff a particular
# CPU exists for the target chip version.
# Usage: $(call if-cpu,CPU,TEXT,ELSE)
define if-cpu
$(if $(filter $(1),$(ARTIMI_CPU_LIST)),$(2),$(3))
endef

# Export minor support functions and helpers.
export if-cpu

