1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 # user notifications and formatting
22 define gb_Output__format_type
23 [$(word 2,$(1) build
clean) $(2)]
26 define gb_Output__format_target
30 define gb_Output_error
34 define gb_Output_announce_title
37 define gb_Output_announce_bell
41 $(info [info $(2)] $(1))
45 $(warning
$(NEWLINE
)[WARN
$(2)] !!!$(NEWLINE
)[WARN
$(2)] !!! $(1)$(NEWLINE
)[WARN
$(2)] !!!)
48 gb_Output_ESCAPE
:= $(shell echo|awk
'BEGIN { printf "%c", 27 }' -)
49 gb_Output_BELL
:= $(shell echo|awk
'BEGIN { printf "%c", 7 }' -)
51 # default to color output, if interactive
52 ifeq ($(origin gb_COLOR
),undefined
)
53 ifneq ($(MAKE_TERMOUT
),)
54 # Cygwin mintty has issues where gb_Output_error is swallowed
55 # but git-bash/wsl-as-helper seems fine with it
56 ifneq ($(OS
)$(MSYSTEM
),WNT
)
62 # only enable colorized output if
64 # - we have a known term
65 gb_KNOWN_TERM
:=Eterm aterm gnome kterm linux putty rxvt rxvt-unicode screen xterm xterm xtermc cygwin
66 gb_KNOWN_TERM
+=$(patsubst %,%-color
,$(gb_KNOWN_TERM
))
67 gb_KNOWN_TERM
+=$(patsubst %-color
,%-256color
,$(gb_KNOWN_TERM
))
68 gb_KNOWN_TERM
+=$(patsubst %-color
,%+256color
,$(gb_KNOWN_TERM
))
69 gb_KNOWN_TERM
+=$(patsubst %,screen.
%,$(gb_KNOWN_TERM
))
70 ifneq ($(strip $(gb_COLOR
)),)
71 ifneq ($(filter $(TERM
),$(gb_KNOWN_TERM
)),)
73 gb_Output_COLOR_RESET
:= $(gb_Output_ESCAPE
)[0m
74 gb_Output_COLOR_RESETANDESCAPE
:= $(gb_Output_COLOR_RESET
)$(gb_Output_ESCAPE
)
76 gb_Output_COLOR_OUTBUILD_LEVEL1
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;40m
77 gb_Output_COLOR_OUTBUILD_LEVEL2
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;40m
78 gb_Output_COLOR_OUTBUILD_LEVEL3
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;40m
79 gb_Output_COLOR_OUTBUILD_LEVEL4
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;40m
80 gb_Output_COLOR_OUTBUILD_LEVEL5
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;1;46m
81 gb_Output_COLOR_OUTBUILD_LEVEL6
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;1;44m
83 gb_Output_COLOR_INBUILD_LEVEL1
:= $(gb_Output_COLOR_RESETANDESCAPE
)[36;40m
84 gb_Output_COLOR_INBUILD_LEVEL2
:= $(gb_Output_COLOR_RESETANDESCAPE
)[36;1;40m
85 gb_Output_COLOR_INBUILD_LEVEL3
:= $(gb_Output_COLOR_RESETANDESCAPE
)[32;40m
86 gb_Output_COLOR_INBUILD_LEVEL4
:= $(gb_Output_COLOR_RESETANDESCAPE
)[32;1;40m
87 gb_Output_COLOR_INBUILD_LEVEL5
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;1;46m
88 gb_Output_COLOR_INBUILD_LEVEL6
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;1;44m
90 gb_Output_COLOR_OUTCLEAN_LEVEL1
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;40m
91 gb_Output_COLOR_OUTCLEAN_LEVEL2
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;40m
92 gb_Output_COLOR_OUTCLEAN_LEVEL3
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;40m
93 gb_Output_COLOR_OUTCLEAN_LEVEL4
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;40m
94 gb_Output_COLOR_OUTCLEAN_LEVEL5
:= $(gb_Output_COLOR_RESETANDESCAPE
)[33;1;41m
95 gb_Output_COLOR_OUTCLEAN_LEVEL6
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;1;41m
97 gb_Output_COLOR_INCLEAN_LEVEL1
:= $(gb_Output_COLOR_RESETANDESCAPE
)[33;40m
98 gb_Output_COLOR_INCLEAN_LEVEL2
:= $(gb_Output_COLOR_RESETANDESCAPE
)[33;1;40m
99 gb_Output_COLOR_INCLEAN_LEVEL3
:= $(gb_Output_COLOR_RESETANDESCAPE
)[31;40m
100 gb_Output_COLOR_INCLEAN_LEVEL4
:= $(gb_Output_COLOR_RESETANDESCAPE
)[31;1;40m
101 gb_Output_COLOR_INCLEAN_LEVEL5
:= $(gb_Output_COLOR_RESETANDESCAPE
)[33;1;41m
102 gb_Output_COLOR_INCLEAN_LEVEL6
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;1;41m
104 gb_Output_COLOR_ERROR
:= $(gb_Output_COLOR_RESETANDESCAPE
)[37;1;41m
106 define gb_Output__format_type
107 $(subst :, ,$(word 2,$(1) \
108 $(gb_Output_COLOR_OUTBUILD_LEVEL
$(3))[$(gb_Output_COLOR_INBUILD_LEVEL
$(3))$(subst $(WHITESPACE
),:,$(2))$(gb_Output_COLOR_OUTBUILD_LEVEL
$(3))] \
109 $(gb_Output_COLOR_OUTCLEAN_LEVEL
$(3))[$(gb_Output_COLOR_INCLEAN_LEVEL
$(3))$(subst $(WHITESPACE
),:,$(2))$(gb_Output_COLOR_OUTCLEAN_LEVEL
$(3))]))$(gb_Output_COLOR_RESET
)
112 define gb_Output_info
113 $(info $(gb_Output_COLOR_OUTBUILD_LEVEL6
)[$(gb_Output_COLOR_INBUILD_LEVEL6
)info $(2)$(gb_Output_COLOR_OUTBUILD_LEVEL6
)]$(gb_Output_COLOR_RESET
) $(1))
116 define gb_Output_warn
117 $(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
) !!!)
120 define gb_Output_error
121 $(error
$(gb_Output_COLOR_ERROR
)$(1)$(gb_Output_COLOR_RESET
))
127 # only enable title output if
129 # - we have a known term
130 ifneq ($(strip $(gb_TITLES
)),)
131 ifneq ($(filter $(TERM
),$(gb_KNOWN_TERM
)),)
132 define gb_Output_announce_title
133 $(info $(gb_Output_ESCAPE
)]2;gbuild
: $(1)$(gb_Output_BELL
)$(gb_Output_ESCAPE
)[A
)
136 $(call gb_Output_announce_title
,...
)
141 # only enable bell output if
143 # - gb_TTY is true (not piping to a file)
144 ifneq ($(strip $(gb_BELL
)),)
145 define gb_Output_announce_bell
146 $(info $(gb_Output_BELL
)$(gb_Output_ESCAPE
)[A
)
150 define gb_Output_announce_str
151 $(call gb_Output__format_type
,$(2),$(3),$(4)) $(call gb_Output__format_target
,$(1))
154 define gb_Output_announce
155 $(info $(call gb_Output_announce_str
,$(1),$(2),$(3),$(4)))
158 # vim: set noet sw=4: