-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.mk
More file actions
72 lines (59 loc) · 1.34 KB
/
Copy pathfunctions.mk
File metadata and controls
72 lines (59 loc) · 1.34 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
#
# Library of functions called by our build system.
#
ifeq ($(VERBOSE)$(V),)
SILENT := @
SILENT_OUTPUT := 1> /dev/null 2> /dev/null
endif
define LOG_RAW
printf "[%s]\t%s\n" "$(1)" "$(2)"
endef
define LOG
@$(LOG_RAW)
endef
define COMPILE
$(call LOG,$(1),$(2))
$(SILENT)mkdir -p $(dir $(2))
endef
define INSTALL
$(call LOG,INST,$(1) $(2))
$(SILENT)rsync $(3) --mkpath -mrl $(1) $(2);
endef
define INSTALL_RAW
$(call LOG_RAW,INST,$(1) $(2))
rsync $(3) --mkpath -mrl $(1) $(2);
endef
# No other way to print a newline character ...
define newline
endef
# Easily assert that an executable exists
define ASSERT_EXE_EXISTS
@$(foreach exe,$(1), \
if ! which $(exe) 1>/dev/null 2>/dev/null ; then \
echo "$(exe): not found in PATH" >&2; \
exit 1; \
fi; \
)
endef
# Make sure that an executable uses a specific version
define CHECK_VERSION
$(call ASSERT_EXE_EXISTS,$(1)) \
if ! $(1) --version | grep '$(2)' > /dev/null; then \
echo "error: $(1): invalid version (expected $(2))" >&2; \
exit 1; \
fi
endef
ifneq ($(VERBOSE)$(V),)
define MAKE_RECURSIVE
$(call LOG,MAKE,$(3)$(2))
$(SILENT)$(MAKE) -C $(1) $(2) $(4)
endef
else
define MAKE_RECURSIVE
$(call LOG,MAKE,$(3)$(2))
$(SILENT)$(MAKE) -C $(1) $(2) $(4) 1> $(1)/make.log 2> $(1)/make.err
endef
endif
define ASSERT_DEFINED
$(if $($(1)),,$(error $(1) is not defined))
endef