You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
style="float: right; margin-left: 10px; margin-bottom: 10px; width: 25%" /> *mxmake*[mɪks meɪk] generates a project-specific Makefile by using an extensible library of configurable Makefile snippets.
Copy file name to clipboardExpand all lines: docs/source/make.md
+22-20Lines changed: 22 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,24 +19,26 @@ If the dependencies are up-to-date, "make" will skip the build process for the t
19
19
20
20
This way, "make" can handle the complex and interdependent steps to form processes of a project, automatically handling the correct order of steps and avoiding unnecessary execution of steps.
21
21
22
-
## The "phony" target
22
+
## The "PHONY" target
23
23
24
-
In "make", a "phony" target is a special type of target that is used to define a target that is not a file or directory. Phony targets are used to describe actions that need to be performed but do not result in a file that can be used as a target in another rule.
24
+
In "make", a "PHONY" target is a special type of target that is used to define a target that is not a file or directory.
25
+
Phony targets are used to describe actions that need to be performed but do not result in a file that can be used as a target in another rule.
25
26
26
-
For example, a common use case for a phony target is to define a "clean" target that removes all generated files.
27
-
A makefile could have a rule like the following:
27
+
For example, a common use case for a PHONY target is to define a "clean" target that removes all generated files.
28
+
A Makefile could have a rule like the following:
28
29
29
-
```makefile
30
+
```Makefile
30
31
.PHONY: clean
31
32
32
33
clean:
33
34
rm -rf build
34
35
```
35
36
36
-
The ".PHONY" line indicates that the "clean" target is a phony target. When "make clean" is run, the command in the rule will be executed to remove the "build" directory.
37
+
The ".PHONY" line indicates that the "clean" target is a PHONY target.
38
+
When "make clean" is run, the command in the rule will be executed to remove the "build" directory.
37
39
38
-
Phony targets are useful because they provide a way to define targets that don't correspond to files and can be used to perform arbitrary actions such as cleaning the build directory or running tests.
39
-
Additionally, "make" considers phony targets to always be out-of-date, so the commands for a phony target will always be executed, even if its dependencies are up-to-date.
40
+
PHONY targets are useful because they provide a way to define targets that don't correspond to files and can be used to perform arbitrary actions such as cleaning the build directory or running tests.
41
+
Additionally, "make" considers PHONY targets to always be out-of-date, so the commands for a PHONY target will always be executed, even if its dependencies are up-to-date.
40
42
This can be useful when you want to guarantee that an action is performed, such as cleaning the build directory before a build.
41
43
42
44
(make-sentinel-files)=
@@ -52,32 +54,32 @@ To overcome this challenge, other methods, such as using sentinel files, can be
52
54
Sentinel files are used to indicate whether a target has been built, or if a process has been completed.
53
55
```
54
56
55
-
For example, a makefile could use a sentinel file to track the state of a build process.
56
-
The makefile could contain a rule like the following:
57
+
For example, a Makefile could use a sentinel file to track the state of a build process.
58
+
The Makefile could contain a rule like the following:
57
59
58
-
```makefile
60
+
```Makefile
59
61
60
62
build: sentinel
61
63
# build commands go here
62
64
63
65
sentinel:
64
-
# build commands go here
65
66
touch sentinel
66
67
```
67
68
68
-
In this example, the "sentinel" file is used to track the state of the build. If the "sentinel" file exists, it means that the build has been completed and the build commands will be skipped.
69
+
In this example, the "sentinel" file is used to track the state of the build.
70
+
If the "sentinel" file exists, it means that the build has been completed and the build commands will be skipped.
69
71
If the "sentinel" file does not exist, the build commands will be executed and the "sentinel" file will be created to indicate that the build has been completed.
70
72
71
73
Sentinel files are useful in "make" because they provide a way to track the state of a build or process, allowing "make" to determine if a target needs to be rebuilt.
72
74
This helps to avoid unnecessary rebuilds, which can save time and resources.
73
75
74
76
## Variables
75
77
76
-
In "make", variables are used to store values that can be referenced in multiple places throughout the makefile. Variables are defined by assigning a value to a name and can be used in rules, dependencies, and commands.
78
+
In "make", variables are used to store values that can be referenced in multiple places throughout the Makefile. Variables are defined by assigning a value to a name and can be used in rules, dependencies, and commands.
77
79
78
-
For example, the following makefile uses a variable to store the name of the compiler:
80
+
For example, the following Makefile uses a variable to store the name of the compiler:
79
81
80
-
```makefile
82
+
```Makefile
81
83
82
84
CC = gcc
83
85
@@ -86,11 +88,11 @@ main: main.c
86
88
```
87
89
88
90
In this example, the "CC" variable is defined with the value "gcc", which is then used in the command to compile the "main.c" file.
89
-
This allows for easy modification of the compiler if needed, as the change only needs to be made in one place, instead of throughout the entire makefile.
91
+
This allows for easy modification of the compiler if needed, as the change only needs to be made in one place, instead of throughout the entire Makefile.
90
92
91
93
Variables can also be used to store values that are generated dynamically, such as the result of a shell command. For example:
92
94
93
-
```makefile
95
+
```Makefile
94
96
95
97
OBJECTS = $(shell ls *.c | sed s/.c/.o/g)
96
98
@@ -102,13 +104,13 @@ In this example, the "OBJECTS" variable is defined as the result of a shell comm
102
104
The "OBJECTS" variable can then be used in the dependencies and command of the "main" target.
103
105
104
106
Variables in "make" can also be overridden on the command line, allowing for easy customization of the build process.
105
-
For example, the following command would use a different compiler than the one defined in the makefile:
107
+
For example, the following command would use a different compiler than the one defined in the Makefile further above:
106
108
107
109
```shell
108
110
make CC=clang
109
111
```
110
112
111
-
This way, "make" variables provide a flexible and convenient way to manage build configurations and reuse values throughout the makefile.
113
+
This way, "make" variables provide a flexible and convenient way to manage build configurations and reuse values throughout the Makefile.
112
114
113
115
There are many more details about variables in the GNU Make Manual.
0 commit comments