1# SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors. 2# SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause 3 4# Output using the 216-color rules mode 5rule_file = $(notdir $(1)) 6rule_path = $(patsubst %/,%,$(dir $(1))) 7last_path = $(notdir $(patsubst %/,%,$(dir $(1)))) 8ansicolor = $(shell echo $(call last_path,$(1)) | cksum | cut -b1-2 | xargs -IS expr 2 \* S + 17) 9emacs_out = @printf " %10s %s/%s\n" $(1) $(call rule_path,$(2)) $(call rule_file,$(2)) 10color_out = @if [ -t 1 ]; then \ 11 printf " %10s \033[38;5;%d;1m%s\033[m/%s\n" \ 12 $(1) $(call ansicolor,$(2)) \ 13 $(call rule_path,$(2)) $(call rule_file,$(2)); else \ 14 printf " %10s %s\n" $(1) $(2); fi 15# if TERM=dumb, use it, otherwise switch to the term one 16output = $(if $(TERM:dumb=),$(call color_out,$1,$2),$(call emacs_out,$1,$2)) 17 18# if V is set to non-nil, turn the verbose mode 19quiet = $(if $(V),$($(1)),$(call output,$1,$@);$($(1))) 20 21# make-4.3 allows string literals like "#include" in variables, but older versions need "\#include". Specifically, the following code: 22# 23# X := $(shell echo "#foo") 24# 25# works with make-4.3, but fails with previous versions: 26# 27# Makefile:1: *** unterminated call to function 'shell': missing ')'. Stop. 28# 29# Older versions work if you spell it "\#foo", but 4.3 will include the backslash. We define $(HASH), which works consistently across versions. 30HASH := \# 31