-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (52 loc) · 2.07 KB
/
Copy pathMakefile
File metadata and controls
57 lines (52 loc) · 2.07 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
# =============================
# USAGE
# - include ./MakefileUtils.mk
# - Prefix each command with "## comment" to describe it and enable "make" help
# - Prefix a topic with "### comment" to group items in "make" help
# - Get an unnamed argument: $(call GET_ARG,1)
# - Get a named argument: $(my_arg)
# - Get all unnamed arguments joined:
# - $(call JOIN_ARGS,|,$(ARGS))
# - For commas, use the variable: $(call JOIN_ARGS,$(comma),$(ARGS))
# - Check the number of unnamed arguments: $(call REQUIRE_ARGS, 2,<arg1> <arg2>)
# - The last parameter is used to build an error like: "Usage: make command <arg1> <arg2>"
# - Check that a named argument exists: $(call REQUIRE_VAR,my_arg)
# =============================
include ./MakefileUtils.mk
###
Examples:
# Check if the named argument "name" is provided and print "hello <name>"
# Usage: make foo name=John
# Usage: make foo name="John Doe"
## named argument example
foo:
$(call REQUIRE_VAR,name);
echo "Hello $(name)!"
# Check that 2 unnamed arguments are passed and print "Hello <arg1> you are <arg2> years old"
# Usage: make foo2 John 12
# Note: quoted unnamed arguments are not supported (e.g., make foo2 "John Doe" 12). Use named arguments instead.
## multi unnamed argument example
foo2:
$(call REQUIRE_ARGS, 2,<name> <age>);
@name=$(call GET_ARG,1); \
age=$(call GET_ARG,2); \
printf "Hello %s you are %s years old\n" "$$name" "$$age"
# Ensure at least one unnamed argument, join all with a comma,
# and print "Hello, you gave me this file list: <arg1>,<arg2>,...<argN>"
# Usage: make foo3 file1
# Usage: make foo3 file1 file2 file3
# Note: quoted unnamed arguments are not supported. Use named arguments instead.
## join arguments example
foo3:
$(call REQUIRE_ARGS, 1, file ...file);
@files=$(call JOIN_ARGS,$(comma)); \
printf "Hello, you gave me this file lise : %s\n" "$$files"
# Logger examples
# Usage: make foo4
## logger example
foo4:
$(call log,my log message)
$(call log_info,My info message)
$(call log_warn,My warning message)
$(call log_error,My error message)
$(call log_success,My success message)