outline makefiles
This commit is contained in:
15
system/Makefiles/graph-easy.md
Normal file
15
system/Makefiles/graph-easy.md
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "Makefile Graphs"
|
||||
tags: [ "system", "makefiles", "graph" ]
|
||||
---
|
||||
|
||||
If you have `graph-easy` (often in the package `perl-graph-easy` or similar), you can make a graph from the makefile with `make2graph` (the package is often called `makefile2graph`).
|
||||
|
||||
Start with the command to 'make all targets' (`-B`), and 'do a dummy run' (`-n`) with debug into (`-d`):
|
||||
|
||||
```bash
|
||||
make -Bnd
|
||||
make -Bnd | make2graph
|
||||
make -Bnd | make2graph | graph-easy --boxart
|
||||
```
|
||||
|
57
system/Makefiles/patterns.md
Normal file
57
system/Makefiles/patterns.md
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
---
|
||||
title: "Makefile Patterns"
|
||||
tags: [ "system", "makefiles" ]
|
||||
---
|
||||
|
||||
Using the [basic example](../Makefile.md), you can make a complete backup of all backup files.
|
||||
This file will depend upon everything inside the `$(storage_directory)`.
|
||||
Unlike `bash`, you can't just say `storage_directory/*`: the pattern must be stated as a 'wildcard'.
|
||||
|
||||
```make
|
||||
$(storage_directory)/backup.tgz: $(wildcard $(storage_directory)/*.md)
|
||||
tar czf $@ $^
|
||||
```
|
||||
|
||||
The `make` rules start by processing variables:
|
||||
|
||||
```make
|
||||
backups/backup.tgz: $(wildcard backups/*.md)
|
||||
tar czf backups/backup.tgz $^
|
||||
```
|
||||
|
||||
Then the `wildcard` variable equals whichever backup files are in the `backups/` directory:
|
||||
|
||||
```make
|
||||
backups/backup.tgz: backups/backup_29.md backups/backup_30.md
|
||||
tar czf backups/backup.tgz backups/backup_29.md backups/backup_30.md
|
||||
```
|
||||
|
||||
|
||||
The phony `backup` target should now point to this tar backup.
|
||||
|
||||
|
||||
```make
|
||||
current_minute != date +%M
|
||||
|
||||
storage_directory = backups
|
||||
|
||||
.PHONY: backup
|
||||
backup: $(storage_directory)/backup.tgz
|
||||
$(storage_directory)/backup.tgz: $(wildcard $(storage_directory)/*.md)
|
||||
tar czf $@ $^
|
||||
|
||||
README.md: Makefile
|
||||
echo "Basic makefile example." > $@
|
||||
echo "" >> $@
|
||||
echo '```' >> $@
|
||||
cat $< >> $@
|
||||
echo '```' >> $@
|
||||
|
||||
$(storage_directory)/backup_$(current_minute).md: README.md
|
||||
mkdir -p $(@D)
|
||||
cp $< $@
|
||||
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user