-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcommon.mk
94 lines (83 loc) · 3.56 KB
/
common.mk
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
# This makefile is included from several other makefiles in the tree.
MAKEFLAGS += --no-builtin-rules
Q?=@
SIL?=--silent
RUNLIM=
ifneq ($(V),)
Q=
SIL=
else
MAKEFLAGS += -s
endif
define NO_RUNLIM_ERR
runlim not found:
To use RESOURCEMONITOR=1, the `runlim` tool must be installed and in your $$PATH.
It must also be a recent version supporting the `-p` option.
You can get it from: [https://github.com/arminbiere/runlim]
endef
define msg =
@printf " %-14s %s\n" $(1) $(2)
endef
define bold_msg =
@#-tput bold 2>/dev/null
@printf -- " %-15s" $(1)
@#-tput sgr0 2>/dev/null
@printf " %s\n" $(2)
endef
# Passing RESOURCEMONITOR=1 will create .runlim files through the source tree with
# information about the time and space taken by each F* invocation.
ifneq ($(RESOURCEMONITOR),)
ifeq ($(shell which runlim),)
_ := $(error $(NO_RUNLIM_ERR)))
endif
ifneq ($(MONID),)
MONPREFIX=$(MONID).
endif
RUNLIM=runlim -p -o $@.$(MONPREFIX)runlim
endif
# Ensure that any failing rule will not create its target file.
# In other words, make `make` less insane.
.DELETE_ON_ERROR:
.DEFAULT_GOAL:=__undef
.PHONY: __undef
__undef:
$(error "This makefile does not have a default goal")
# Check that a variable is defined. If not, abort with an (optional) error message.
need = \
$(if $(value $(strip $1)),, \
$(error Need a value for $(strip $1)$(if $2, ("$(strip $2)"))))
# Check that a variable is defined and pointing to an executable.
# Is there no negation in make...?
# Wew! this was interesting to write. Especially the override part.
need_exe = \
$(if $(value $(strip $1)), \
$(if $(wildcard $(value $(strip $1))), \
$(if $(shell test -x $(value $(strip $1)) && echo 1), \
$(eval override $(strip $1):=$(abspath $(value $(strip $1)))), \
$(error $(strip $1) ("$(value $(strip $1))") is not executable)), \
$(if $(shell which $(value $(strip $1))), \
$(eval override $(strip $1):=$(shell which $(value $(strip $1)))), \
$(error $(strip $1) ("$(value $(strip $1))") does not exist and is not in PATH (cwd = $(CURDIR))))), \
$(error Need an executable for $(strip $1)$(if $2, ("$(strip $2)")))) \
need_file = \
$(if $(value $(strip $1)), \
$(if $(wildcard $(value $(strip $1))), \
$(if $(shell test -f $(value $(strip $1)) && echo 1), \
$(eval override $(strip $1):=$(abspath $(value $(strip $1)))), \
$(error $(strip $1) ("$(value $(strip $1))") is not executable)), \
$(error $(strip $1) ("$(value $(strip $1))") does not exist (cwd = $(CURDIR)))), \
$(error Need a file path for $(strip $1)$(if $2, ("$(strip $2)")))) \
need_dir = \
$(if $(value $(strip $1)), \
$(if $(wildcard $(value $(strip $1))), \
$(if $(shell test -d $(value $(strip $1)) && echo 1), \
$(eval override $(strip $1):=$(abspath $(value $(strip $1)))), \
$(error $(strip $1) ("$(value $(strip $1))") is not executable)), \
$(error $(strip $1) ("$(value $(strip $1))") is not a directory (cwd = $(CURDIR)))), \
$(error Need an *existing* directory path for $(strip $1)$(if $2, ("$(strip $2)")))) \
need_dir_mk = \
$(if $(value $(strip $1)), \
$(if $(shell mkdir -p $(value $(strip $1)) && echo 1), \
$(eval override $(strip $1):=$(abspath $(value $(strip $1)))), \
$(error $(strip $1) ("$(value $(strip $1))") is not a directory (mkdir failed, cwd = $(CURDIR)))), \
$(error Need a directory path for $(strip $1)$(if $2, ("$(strip $2)")))) \