-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbase.makefile
More file actions
136 lines (105 loc) · 2.53 KB
/
base.makefile
File metadata and controls
136 lines (105 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
###
##. GNU Make
###
#. Check for GNU Make
ifneq ($(firstword $(shell $(MAKE) --version)),GNU)
$(error Please use GNU Make)
endif
###
##. Disable built-in rules
###
#. Remove all predefined rules
.SUFFIXES:
#. Remove the target if a recipe fails
.DELETE_ON_ERROR:
#. Default to the system shell
SHELL?=/bin/sh
#. Add extra flags to the make command
MAKEFLAGS+=--no-builtin-rules --environment-overrides
###
##. Current working directory
###
CWD=$(eval CWD:=$$(abspath $$(dir $$(firstword $(MAKEFILE_LIST)))))$(CWD)
CWD_PREFIX=$(if $(CWD),$(CWD)/)
###
##. Verbosity
###
VERBOSE?=0
NO_PRINTING_LEVELS?=0
NO_SHELL_PRINTING_LEVELS?=0 1
NO_SHELL_TIMING_LEVELS?=0 1 2
ifneq ($(filter $(VERBOSE),$(NO_PRINTING_LEVELS)),)
Q:=@
MAKEFLAGS+=--no-print-directory
else
Q:=
endif
ifeq ($(filter $(VERBOSE),$(NO_SHELL_PRINTING_LEVELS)),)
SHELL+=-x
endif
ifeq ($(filter $(VERBOSE),$(NO_SHELL_TIMING_LEVELS)),)
SHELL:=time $(SHELL)
endif
#. Run the command without printing "is up to date" messages
silent-% %.silent:%; @true
###
##. Parallelism
###
MAKE_PARALLELISM_OPTIONS=$(eval MAKE_PARALLELISM_OPTIONS:=$$(if $$(shell $$(MAKE) -v | grep "3\|4"), -j $$$$(nproc 2>/dev/null || sysctl -n hw.physicalcpu 2>/dev/null || echo "1"))$$(if $$(shell $$(MAKE) -v | grep "4"), --output-sync=recurse))$(MAKE_PARALLELISM_OPTIONS)
###
##. Default variables
###
TARGET?=
CI?=
###
##. POSIX dependencies - @see https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html
###
define check-base-dependency
ifeq ($$(shell command -v $(1) || which $(1) 2>/dev/null),)
$$(error Please provide the command "$(1)")
endif
endef
$(foreach command,if test printf exit,$(eval $(call check-base-dependency,$(command))))
###
##. Characters
###
empty:=
space:=$(empty) $(empty)
comma:=,
define newline
$(empty)
endef
###
##. Stylesheets
###
STYLE_RESET?=\033[0m
STYLE_TITLE?=\033[1;36m
STYLE_SUCCESS?=\033[32m
STYLE_WARNING?=\033[33m
STYLE_ERROR?=\033[31m
STYLE_DIM?=\033[2m
STYLE_BOLD?=\033[1m
STYLE_UNDERLINE?=\033[4m
ICON_SUCCESS?=\342\234\224 # \u2713
ICON_WARNING?=\342\232\240 # \u26A0
ICON_ERROR?=\342\234\225 # \u2715
###
##. Link
###
#. $(1) is the url, $(2) is the (optional) description
print_link?=printf "\033]8;;%s\033\\\\%s\033]8;;\033\\\\" "$(1)" "$(if $(2),$(2),$(1))"
println_link?=printf "\033]8;;%s\033\\\\%s\033]8;;\033\\\\\n" "$(1)" "$(if $(2),$(2),$(1))"
###
##. Force
###
#. Force the command to run
force: ; @true
.PHONY: force
###
##. Debug
###
#. Debug
debug:
@$(MAKE) -v
@echo "flags: $(MAKE) $(MAKEFLAGS)"
@echo "shell flags: $(shell echo $${MAKE} $${MAKEFLAGS})"