make all file names lowercase
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", "make", "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
|
||||
```
|
||||
|
20
system/makefiles/help.md
Normal file
20
system/makefiles/help.md
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: "make help target"
|
||||
tags: [ "system", "make", "help" ]
|
||||
---
|
||||
|
||||
Make your first target 'help' to give an overview of the main targets.
|
||||
Running `make help` will search for text which starts with `## ` and show what that target does.
|
||||
|
||||
```make
|
||||
.PHONY: help
|
||||
help: ## Print the help message.
|
||||
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
|
||||
sort | \
|
||||
column -s ':' -t
|
||||
|
||||
.PHONY: clean
|
||||
clean: ## Remove generated files.
|
||||
$(RM) $(defaults)
|
||||
```
|
||||
|
55
system/makefiles/patterns.md
Normal file
55
system/makefiles/patterns.md
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
title: "Makefile Patterns"
|
||||
tags: [ "system", "make" ]
|
||||
---
|
||||
|
||||
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 $< $@
|
||||
|
||||
```
|
||||
|
||||
|
98
system/makefiles/python_projects.md
Normal file
98
system/makefiles/python_projects.md
Normal file
@@ -0,0 +1,98 @@
|
||||
---
|
||||
title: "Python Projects with Makefiles"
|
||||
tags: [ "tutorial", "system", "makefiles", "graphviz", "python" ]
|
||||
requires: [ "Makefiles" ]
|
||||
---
|
||||
|
||||
If you have a python script which requires a packages - e.g. `graphviz` - you can automate the setup with a `Makefile`.
|
||||
The `Makefile` will:
|
||||
|
||||
1. Make three copies of an 8-line installer script.
|
||||
2. Use one of the installer script to install local packages.
|
||||
3. Install a symbolic link to python.
|
||||
3. Make a script called `activate`, which tells python to use
|
||||
|
||||
# Context
|
||||
|
||||
Python coders don't like updating their projects, they just expect everyone to install the same version of everything that they have.
|
||||
Historically, people dealt with this by installing only half a dozen copies of `graphviz`; but now each python project uses a local environment, with a local copy of `graphviz`, which means everyone gets to install a new copy of `graphviz` every time they try out a project.
|
||||
|
||||
Downloading 40MB of software for each 40-line script you write is called 'virtual environments' because it sounds cool.
|
||||
We can make it even cooler with `make`, but not yet, because python - like the fae of old - will not fetch anything until you know its true name.
|
||||
|
||||
# Setup
|
||||
|
||||
```sh
|
||||
command -v python
|
||||
realpath `!!`
|
||||
```
|
||||
|
||||
You must reveal that true path, because `python` is always a relative symbolic link, to an absolute symbolic link, which leads to a shortcut.
|
||||
We can finally let `make` know how to invoke python, and where it will install `graphviz`.
|
||||
|
||||
If your python's version is '3.14', then python needs its packages placed in `${somewhere}/lib/python3.14/site-packages/`.
|
||||
You must create a new, local, name for these packages, because - like the fey of old - python demands a private name in return for revealing its true name.
|
||||
|
||||
I'll call mine `camelot`, because the path is long and arduous.
|
||||
Set up the Makefiles like this:
|
||||
|
||||
```make
|
||||
py_link != command -v python
|
||||
py != realpath $(py_link)
|
||||
version != basename $(py)
|
||||
|
||||
virtenv = camelot
|
||||
```
|
||||
|
||||
Now you can ask for a local `pip` script, which can install the python packages:
|
||||
|
||||
```make
|
||||
[...]
|
||||
|
||||
$(virtenv)/bin/pip:
|
||||
$(py) -m venv $(virtenv)
|
||||
```
|
||||
|
||||
Finally, list the packages you want in `requirements.txt`, and make `pip` install from it.
|
||||
|
||||
|
||||
```sh
|
||||
ppkg=graphviz
|
||||
echo ${ppkg} > requirements.txt
|
||||
```
|
||||
|
||||
```make
|
||||
[...]
|
||||
|
||||
pkgs = $(virtenv)/lib/$(version)/site-packages/
|
||||
|
||||
$(pkgs): $(virtenv)/bin/pip
|
||||
$(pkgs): requirements.txt
|
||||
$(virtenv)/bin/pip install -r $<
|
||||
```
|
||||
|
||||
The complete Makefile looks like this:
|
||||
|
||||
|
||||
```make
|
||||
all: .default
|
||||
|
||||
py_link != command -v python
|
||||
py != realpath $(py_link)
|
||||
version != basename $(py)
|
||||
|
||||
virtenv = camelot
|
||||
|
||||
$(virtenv)/bin/pip:
|
||||
$(py) -m venv $(virtenv)
|
||||
|
||||
pkgs = $(virtenv)/lib/$(version)/site-packages/
|
||||
|
||||
$(pkgs): $(virtenv)/bin/pip
|
||||
$(pkgs): requirements.txt
|
||||
$(virtenv)/bin/pip install -r $<
|
||||
|
||||
.PHONY: .default
|
||||
.default: $(pkgs)
|
||||
```
|
||||
|
Reference in New Issue
Block a user