|
1 | 1 | ifeq (, $(shell which tput))
|
2 | 2 | # CI environment typically does not support tput.
|
3 | 3 | banner-style = $1
|
| 4 | +else ifeq (, $(TERM)) |
| 5 | + # Terminal type not set, so tput would fail. |
| 6 | + banner-style = $1 |
4 | 7 | else
|
5 | 8 | # print in bold red to bring attention.
|
6 | 9 | banner-style = $(shell tput bold)$(shell tput setaf 1)$1$(shell tput sgr0)
|
7 | 10 | endif
|
8 | 11 |
|
9 |
| -# Variable assignments can affect the semantic of the make targets. |
10 |
| -# Typical use-case: setting VERSION in a release build, since CI |
11 |
| -# doesn't preserve the git environment. |
12 |
| -# |
13 |
| -# We need to translate: |
14 |
| -# "make target VAR=val" to "just VAR=val target" |
15 |
| -# |
16 |
| -# MAKEFLAGS is a string of the form: |
17 |
| -# "abc --foo --bar=baz -- VAR1=val1 VAR2=val2", namely: |
18 |
| -# - abc is the concatnation of all short flags |
19 |
| -# - --foo and --bar=baz are long options, |
20 |
| -# - -- is the separator between flags and variable assignments, |
21 |
| -# - VAR1=val1 and VAR2=val2 are variable assignments |
22 |
| -# |
23 |
| -# Goal: ignore all CLI flags, keep only variable assignments. |
24 |
| -# |
25 |
| -# First remove the short flags at the beginning, or the first long-flag, |
26 |
| -# or if there is no flag at all, the -- separator (which then makes the |
27 |
| -# next step a noop). If there's no flag and no variable assignment, the |
28 |
| -# result is empty anyway, so the wordlist call is safe (everything is a noop). |
29 |
| -tmp-flags = $(wordlist 2,$(words $(MAKEFLAGS)),$(MAKEFLAGS)) |
30 |
| -# Then remove all long options, including the -- separator, if needed. That |
31 |
| -# leaves only variable assignments. |
32 |
| -just-flags = $(patsubst --%,,$(tmp-flags)) |
| 12 | +SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) |
| 13 | +include $(SELF_DIR)/flags.mk |
33 | 14 |
|
34 | 15 | define make-deprecated-target
|
35 | 16 | $1:
|
36 | 17 | @echo
|
37 |
| - @printf %s\\n '$(call banner-style,"make $1 $(just-flags)" is deprecated. Please use "just $(just-flags) $1" instead.)' |
| 18 | + @printf %s\\n '$(call banner-style,Deprecated make call: make $1 $(JUSTFLAGS))' |
| 19 | + @printf %s\\n '$(call banner-style,Consider using just instead: just $(JUSTFLAGS) $1)' |
38 | 20 | @echo
|
39 |
| - just $(just-flags) $1 |
| 21 | + just $(JUSTFLAGS) $1 |
40 | 22 | endef
|
41 | 23 |
|
42 | 24 | $(foreach element,$(DEPRECATED_TARGETS),$(eval $(call make-deprecated-target,$(element))))
|
|
0 commit comments