m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/makefile.md
diff options
context:
space:
mode:
Diffstat (limited to 'makefile.md')
-rw-r--r--makefile.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/makefile.md b/makefile.md
new file mode 100644
index 0000000..a7a3ab8
--- /dev/null
+++ b/makefile.md
@@ -0,0 +1,30 @@
+# Writing Makefiles
+
+## Pattern rules
+
+In prerequesite, use exactly one `%`. Can then be used in requirements. E.g.
+
+ %.o: %.c
+ # compile .c file to .o
+
+Details: <https://www.gnu.org/software/make/manual/html_node/Pattern-Rules.html>
+
+## Automatic variables
+
+* `$@`: current target
+* `$<`: first prerequisite
+* `$^`: all prerequisites, separated by spaces
+* `$(@F)`: file-within-directory part of target path
+
+More: <https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html>
+
+## Text functions
+
+* `$(var:suffix=replacement)`, syntax sugar for
+ `$(patsubst %suffix, $replacement, $(var))`
+
+More: <https://www.gnu.org/software/make/manual/html_node/Text-Functions.html>
+
+## Quiet commands
+
+By default, `make` prints the command being run. Prepend `@` to silence this.