1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24# user notifications and formatting 25 26define gb_Output__format_type 27[ $(word 2,$(1) build clean) $(2) ] 28endef 29 30define gb_Output__format_target 31$(1) 32endef 33 34define gb_Output_error 35$(error $(1)) 36endef 37 38define gb_Output_announce_title 39endef 40 41define gb_Output_announce_bell 42endef 43 44define gb_Output_info 45$(info [ info $(2) ] $(1)) 46endef 47 48define gb_Output_warn 49$(warning $(NEWLINE)[ WARN $(2) ] !!!$(NEWLINE)[ WARN $(2) ] !!! $(1)$(NEWLINE)[ WARN $(2) ] !!!) 50endef 51 52gb_Output_ESCAPE := $(shell echo|awk 'BEGIN { printf "%c", 27 }' -) 53gb_Output_BELL := $(shell echo|awk 'BEGIN { printf "%c", 7 }' -) 54 55# only enable colorized output if 56# - gb_COLOR is set 57# - we have a known term 58ifneq ($(strip $(gb_COLOR)),) 59ifneq ($(filter $(TERM),Eterm aterm gnome kterm linux rxvt rxvt-unicode screen xterm xterm-color),) 60 61gb_Output_COLOR_RESET := $(gb_Output_ESCAPE)[0m 62gb_Output_COLOR_RESETANDESCAPE := $(gb_Output_COLOR_RESET)$(gb_Output_ESCAPE) 63 64gb_Output_COLOR_OUTBUILD_LEVEL1 := $(gb_Output_COLOR_RESETANDESCAPE)[37;40m 65gb_Output_COLOR_OUTBUILD_LEVEL2 := $(gb_Output_COLOR_RESETANDESCAPE)[37;40m 66gb_Output_COLOR_OUTBUILD_LEVEL3 := $(gb_Output_COLOR_RESETANDESCAPE)[37;40m 67gb_Output_COLOR_OUTBUILD_LEVEL4 := $(gb_Output_COLOR_RESETANDESCAPE)[37;40m 68gb_Output_COLOR_OUTBUILD_LEVEL5 := $(gb_Output_COLOR_RESETANDESCAPE)[37;1;46m 69gb_Output_COLOR_OUTBUILD_LEVEL6 := $(gb_Output_COLOR_RESETANDESCAPE)[37;1;44m 70 71gb_Output_COLOR_INBUILD_LEVEL1 := $(gb_Output_COLOR_RESETANDESCAPE)[36;40m 72gb_Output_COLOR_INBUILD_LEVEL2 := $(gb_Output_COLOR_RESETANDESCAPE)[36;1;40m 73gb_Output_COLOR_INBUILD_LEVEL3 := $(gb_Output_COLOR_RESETANDESCAPE)[32;40m 74gb_Output_COLOR_INBUILD_LEVEL4 := $(gb_Output_COLOR_RESETANDESCAPE)[32;1;40m 75gb_Output_COLOR_INBUILD_LEVEL5 := $(gb_Output_COLOR_RESETANDESCAPE)[37;1;46m 76gb_Output_COLOR_INBUILD_LEVEL6 := $(gb_Output_COLOR_RESETANDESCAPE)[37;1;44m 77 78gb_Output_COLOR_OUTCLEAN_LEVEL1 := $(gb_Output_COLOR_RESETANDESCAPE)[37;40m 79gb_Output_COLOR_OUTCLEAN_LEVEL2 := $(gb_Output_COLOR_RESETANDESCAPE)[37;40m 80gb_Output_COLOR_OUTCLEAN_LEVEL3 := $(gb_Output_COLOR_RESETANDESCAPE)[37;40m 81gb_Output_COLOR_OUTCLEAN_LEVEL4 := $(gb_Output_COLOR_RESETANDESCAPE)[37;40m 82gb_Output_COLOR_OUTCLEAN_LEVEL5 := $(gb_Output_COLOR_RESETANDESCAPE)[33;1;41m 83gb_Output_COLOR_OUTCLEAN_LEVEL6 := $(gb_Output_COLOR_RESETANDESCAPE)[37;1;41m 84 85gb_Output_COLOR_INCLEAN_LEVEL1 := $(gb_Output_COLOR_RESETANDESCAPE)[33;40m 86gb_Output_COLOR_INCLEAN_LEVEL2 := $(gb_Output_COLOR_RESETANDESCAPE)[33;1;40m 87gb_Output_COLOR_INCLEAN_LEVEL3 := $(gb_Output_COLOR_RESETANDESCAPE)[31;40m 88gb_Output_COLOR_INCLEAN_LEVEL4 := $(gb_Output_COLOR_RESETANDESCAPE)[31;1;40m 89gb_Output_COLOR_INCLEAN_LEVEL5 := $(gb_Output_COLOR_RESETANDESCAPE)[33;1;41m 90gb_Output_COLOR_INCLEAN_LEVEL6 := $(gb_Output_COLOR_RESETANDESCAPE)[37;1;41m 91 92gb_Output_COLOR_ERROR := $(gb_Output_COLOR_RESETANDESCAPE)[37;1;41m 93 94define gb_Output__format_type 95$(subst :, ,$(word 2,$(1) \ 96 $(gb_Output_COLOR_OUTBUILD_LEVEL$(3))[:$(gb_Output_COLOR_INBUILD_LEVEL$(3))build:$(subst $(WHITESPACE),:,$(2))$(gb_Output_COLOR_OUTBUILD_LEVEL$(3)):] \ 97 $(gb_Output_COLOR_OUTCLEAN_LEVEL$(3))[:$(gb_Output_COLOR_INCLEAN_LEVEL$(3))clean:$(subst $(WHITESPACE),:,$(2))$(gb_Output_COLOR_OUTCLEAN_LEVEL$(3)):]))$(gb_Output_COLOR_RESET) 98endef 99 100define gb_Output_info 101$(info $(gb_Output_COLOR_OUTBUILD_LEVEL6)[ $(gb_Output_COLOR_INBUILD_LEVEL6)info $(2)$(gb_Output_COLOR_OUTBUILD_LEVEL6) ]$(gb_Output_COLOR_RESET) $(1)) 102endef 103 104define gb_Output_warn 105$(warning $(NEWLINE)$(gb_Output_COLOR_OUTCLEAN_LEVEL6)[ $(gb_Output_COLOR_INCLEAN_LEVEL6)WARN $(2)$(gb_Output_COLOR_OUTCLEAN_LEVEL6) ]$(gb_Output_COLOR_RESET) !!!$(NEWLINE)$(gb_Output_COLOR_OUTCLEAN_LEVEL6)[ $(gb_Output_COLOR_INCLEAN_LEVEL6)WARN $(2)$(gb_Output_COLOR_OUTCLEAN_LEVEL6) ]$(gb_Output_COLOR_RESET) !!! $(1)$(NEWLINE)$(gb_Output_COLOR_OUTCLEAN_LEVEL6)[ $(gb_Output_COLOR_INCLEAN_LEVEL6)WARN $(2)$(gb_Output_COLOR_OUTCLEAN_LEVEL6) ]$(gb_Output_COLOR_RESET) !!!) 106endef 107 108define gb_Output_error 109$(error $(gb_Output_COLOR_ERROR)$(1)$(gb_Output_COLOR_RESET)) 110endef 111 112endif 113endif 114 115# only enable title output if 116# - gb_TITLES is set 117# - we have a known term 118ifneq ($(strip $(gb_TITLES)),) 119ifneq ($(filter $(TERM),Eterm aterm gnome kterm rxvt rxvt-unicode screen xterm xterm-color),) 120define gb_Output_announce_title 121$(info $(gb_Output_ESCAPE)]2;gbuild: $(1)$(gb_Output_BELL)$(gb_Output_ESCAPE)[A) 122endef 123 124$(call gb_Output_announce_title,...) 125 126endif 127endif 128 129# only enable bell output if 130# - gb_BELL is set 131# - gb_TTY is true (not piping to a file) 132ifneq ($(strip $(gb_BELL)),) 133define gb_Output_announce_bell 134$(info $(gb_Output_BELL)$(gb_Output_ESCAPE)[A) 135endef 136endif 137 138define gb_Output_announce 139$(info $(call gb_Output__format_type,$(2),$(3),$(4)) $(call gb_Output__format_target,$(1))) 140endef 141 142 143# vim: set noet sw=4 ts=4: 144