github.com/blixtra/rkt@v0.8.1-0.20160204105720-ab0d1add1a43/makelib/verbosity.mk (about) 1 # This file provides some functions for controlling the verbosity of make 2 # rules. 3 4 # 5 # Translate english word arguments to a numeric level. 6 # 7 8 ifeq ($V,silent) 9 override V := 0 10 endif 11 12 ifeq ($V,quiet) 13 override V := 0 14 endif 15 16 ifeq ($V,info) 17 override V := 1 18 endif 19 20 ifeq ($V,all) 21 override V := 2 22 endif 23 24 ifeq ($V,raw) 25 override V := 3 26 endif 27 28 # if V is empty or bogus, default to info verbosity 29 ifeq ($(filter $V,0 1 2 3),) 30 override V := 1 31 endif 32 33 # 34 # basic functions used by all predicates 35 # 36 37 # returns a non-empty value if $V is one of the $1 verbosity levels 38 define veq 39 $(filter $V,$1) 40 endef 41 42 # 43 # predicates 44 # 45 46 # expands to $1 if $V is 0 47 define v0 48 $(if $(call veq,0),$1) 49 endef 50 51 # expands to $1 if $V is 1 52 define v1 53 $(if $(call veq,1),$1) 54 endef 55 56 # expands to $1 if $V is 2 57 define v2 58 $(if $(call veq,2),$1) 59 endef 60 61 # expands to $1 if $V is 3 62 define v3 63 $(if $(call veq,3),$1) 64 endef 65 66 # expands to $1 if $V is greater than 0 67 define vg0 68 $(if $(call veq,1 2 3),$1) 69 endef 70 71 # expands to $1 if $V is greater than 1 72 define vg1 73 $(if $(call veq,2 3),$1) 74 endef 75 76 # expands to $1 if $V is greater than 2 77 define vg2 78 $(if $(call veq,3),$1) 79 endef 80 81 # expands to $1 if $V is lower than 1 82 define vl1 83 $(if $(call veq,0),$1) 84 endef 85 86 # expands to $1 if $V is lower than 2 87 define vl2 88 $(if $(call veq,0 1),$1) 89 endef 90 91 # expands to $1 if $V is lower than 3 92 define vl3 93 $(if $(call veq,0 1 2),$1) 94 endef 95 96 # expands to $1 if $V is either 1 or 2 (truncated verbosity) 97 define vt 98 $(if $(call veq,1 2),$1) 99 endef 100 101 # 102 # functions and variables used inside make rules 103 # 104 105 # expands to a bash snippet printing shortcut and parameters if 106 # predicate returns a non-empty value 107 # 1 - predicate (vlX, vgX, vX, or vt for X in <0,3>) 108 # 2 - shortcut (max 12 characters, like CC, DEPSGLOB, etc) 109 # 3 - other parameters, printed after shortcut 110 # 111 # Example: $(call vb,vl2,STUFF,foo/bar) will print the following text 112 # if the verbosity level is lower than 2: 113 # 114 # STUFF foo/bar 115 define vb 116 $(call $1,printf ' %-12s %s\n' '$2' "$3";) 117 endef 118 119 # This variable should be used as the first thing in the recipe to 120 # stop echoing the recipe for lower verbosity levels. It also sets up 121 # the shell to fail on the first failed command - this is usually 122 # needed anyway, as lower verbosity levels often add additional 123 # commands to the recipe to print nice messages. 124 VQ = $(call vl3,@set -e;) 125 126 # This shortens the paths by removing the absolute src directory from 127 # them. So it truncates /home/foo/projects/rkt/<builddir>/tmp/... to 128 # <builddir>/tmp/... 129 define vsp 130 $(subst $(MK_TOPLEVEL_ABS_SRCDIR)/,,$1) 131 endef 132 133 # This shortens the paths by removing the Godeps workspace part. So it 134 # truncates 135 # github.com/coreos/rkt/Godeps/_workspace/src/github.com/appc/spec/schema 136 # to <Godeps>/github.com/appc/spec/schema. 137 define vsg 138 $(subst $(REPO_PATH)/Godeps/_workspace/src,<Godeps>,$1) 139 endef