Compare commits
11 Commits
master
...
e2814b08e1
| Author | SHA1 | Date | |
|---|---|---|---|
| e2814b08e1 | |||
|
2f33669330
|
|||
|
cee27356f6
|
|||
|
f358103f79
|
|||
|
4c51ade750
|
|||
|
0d2d466dac
|
|||
|
8cc2a71235
|
|||
|
fa026b7eda
|
|||
|
7bc84ab8a3
|
|||
|
e59538a3bd
|
|||
|
a9f7fd7f75
|
@@ -1,4 +1,3 @@
|
|||||||
*.pdf
|
*.pdf
|
||||||
*.epub
|
*.epub
|
||||||
Makefile
|
|
||||||
*.xcf
|
*.xcf
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
help: ## Print the help message
|
||||||
|
$(info Make a single pdf by hitting the tab key a lot)
|
||||||
|
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
|
||||||
|
sort | \
|
||||||
|
column -s ':' -t
|
||||||
|
|
||||||
|
# Search should not include slides separated by '***', as those are for mdp, not pandoc.
|
||||||
|
markdown != find slides/ -maxdepth 2 -type f -name "*.md" -exec grep -LF '***' '{}' ';'
|
||||||
|
pdfs = $(patsubst %.md, %.pdf, $(markdown))
|
||||||
|
|
||||||
|
$(pdfs): %.pdf: %.md
|
||||||
|
pandoc -t beamer -V theme:Warsaw -i $< -o $@
|
||||||
|
|
||||||
|
.PHONY: show
|
||||||
|
show: $(pdfs) ## Generate all pdfs
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: ## Delete all pdfs
|
||||||
|
find . -name "*.pdf" -exec rm '{}' ';'
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
# Radionice
|
## Radionice
|
||||||
|
|
||||||
First run ./configure to generate a Makefile using folders in this directory
|
Usage: `make`
|
||||||
|
|
||||||
Then you can run make to generate pdf beamer slides
|
## Dependecies:
|
||||||
|
#### For Debian:
|
||||||
|
```
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install pandoc
|
||||||
|
sudo apt install tikzit
|
||||||
|
```
|
||||||
|
#### For Arch:
|
||||||
|
TODO
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
FOLDERS=$(cd slides/ ; echo *)
|
|
||||||
|
|
||||||
rm -f Makefile
|
|
||||||
echo -n 'all:' >> Makefile
|
|
||||||
for i in $FOLDERS ; do echo -n " $i.pdf" >> Makefile ; done
|
|
||||||
echo "" >> Makefile
|
|
||||||
|
|
||||||
for i in $FOLDERS ; do echo -e "$i.pdf:\n\tpandoc -t beamer -V theme:Warsaw -i slides/$i/$i.md -o slides/$i/$i.pdf\n" >> Makefile ; done
|
|
||||||
|
|
||||||
echo -ne "clean:\n\trm -f" >> Makefile
|
|
||||||
for i in $FOLDERS; do echo -n " slides/$i/$i.pdf" >> Makefile ; done
|
|
||||||
echo "" >> Makefile
|
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
# Generalizing Makefiles for All Occasions
|
||||||
|
|
||||||
|
- Rules are bad,
|
||||||
|
- standards are good,
|
||||||
|
- habits are better.
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# General Standards
|
||||||
|
|
||||||
|
- `make help`
|
||||||
|
- `make check`
|
||||||
|
- `sudo make install`
|
||||||
|
|
||||||
|
**NB:** we separate `make` from `make install` so that the files are not build with the user `root` as the owner.
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Service Standards
|
||||||
|
|
||||||
|
- `make backup.tgz`
|
||||||
|
- `make install`
|
||||||
|
|
||||||
|
## Service Backups in Two Files
|
||||||
|
|
||||||
|
- `configs`: configuration files, all tracked in git.
|
||||||
|
- `store`: passwords and binary files, not tracked in git.
|
||||||
|
|
||||||
|
## New Abilities Unlocked
|
||||||
|
|
||||||
|
- Open Access Administration.
|
||||||
|
- Sharing admin configs with hacker spaces.
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
## BEHOLD: The Everything Makefile
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
```make
|
||||||
|
CONFIGS = $(patsubst /%,%,$(shell cat configs))
|
||||||
|
STORE = $(patsubst /%,%,$(shell cat store))
|
||||||
|
CP = mkdir -p $(dir $@) && cp -a
|
||||||
|
IGNORE_FILE = $(shell test -d .git/info && echo .git/info/exclude || echo .gitignore)
|
||||||
|
GIT_COMMIT = git commit -m"add $@" --no-gpg-sign --no-signoff
|
||||||
|
SELECTOR != command -v sk || command -v fzy || command -f fzf
|
||||||
|
.PHONY: all
|
||||||
|
all: init backup.tgz $(IGNORE_FILE)
|
||||||
|
backup.tgz: $(CONFIGS) $(STORE)
|
||||||
|
tar czf $@ $^
|
||||||
|
$(IGNORE_FILE): store
|
||||||
|
echo $(STORE) backup.tgz | tr ' ' '\n' > $@
|
||||||
|
.PHONY: init
|
||||||
|
init: configs store
|
||||||
|
configs store:
|
||||||
|
while con="$$(find /var /etc/ /sys/ -maxdepth 2 -mindepth 1 -type f 2>/dev/null | $(SELECTOR) -p "Select files for $@\nPress Ctrl+d once done")"; do \
|
||||||
|
echo "$$con"; \
|
||||||
|
done > $@
|
||||||
|
$(CONFIGS): %: /%
|
||||||
|
$(CP) $< $@
|
||||||
|
git add $@
|
||||||
|
$(GIT_COMMIT)
|
||||||
|
$(info made git commit for $@)
|
||||||
|
$(STORE): %: /%
|
||||||
|
$(CP) $< $@
|
||||||
|
clean:
|
||||||
|
$(RM) -r $(CONFIGS) $(STORE) backup.tgz
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
## Example: Soft Serve Makefile
|
||||||
|
|
||||||
|
<br>
|
||||||
|
The `configs` file:
|
||||||
|
|
||||||
|
```
|
||||||
|
/etc/soft-serve.conf
|
||||||
|
/var/lib/soft-serve/data/config.yaml
|
||||||
|
/var/lib/soft-serve/data/file
|
||||||
|
/etc/nginx/sites-enabled/soft.dmz.rs
|
||||||
|
/etc/nginx/sites-available/soft.dmz.rs
|
||||||
|
```
|
||||||
|
|
||||||
|
<br>
|
||||||
|
The `store` file:
|
||||||
|
|
||||||
|
```
|
||||||
|
/var/lib/soft-serve/data/lfs
|
||||||
|
/var/lib/soft-serve/data/repo
|
||||||
|
/var/lib/soft-serve/data/soft
|
||||||
|
/etc/letsencrypt/archive/soft
|
||||||
|
/etc/letsencrypt/live/soft.dm
|
||||||
|
/var/lib/soft-serve/data/ssh/
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Other Build Systems
|
||||||
|
|
||||||
|
> "*What if I want to use this other thing, instead of a makefile?"
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Other Build Systems (Sans Heresy)
|
||||||
|
|
||||||
|
> "*What if I want to use this other thing, instead of a makefile?"
|
||||||
|
|
||||||
|
- Easy: just use a Makefile.
|
||||||
|
|
||||||
|
|
||||||
|
```make
|
||||||
|
|
||||||
|
[ ... ]
|
||||||
|
|
||||||
|
public/: src/
|
||||||
|
python build_pages.py
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
CONFIGS = $(patsubst /%,%,$(shell cat configs))
|
||||||
|
STORE = $(patsubst /%,%,$(shell cat store))
|
||||||
|
CP = mkdir -p $(dir $@) && cp -a
|
||||||
|
IGNORE_FILE = $(shell test -d .git/info && echo .git/info/exclude || echo .gitignore)
|
||||||
|
GIT_COMMIT = git commit -m"add $@" --no-gpg-sign --no-signoff
|
||||||
|
SELECTOR != command -v sk || command -v fzy || command -f fzf
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: init backup.tgz $(IGNORE_FILE)
|
||||||
|
|
||||||
|
backup.tgz: $(CONFIGS) $(STORE)
|
||||||
|
tar czf $@ $^
|
||||||
|
|
||||||
|
$(IGNORE_FILE): store
|
||||||
|
echo $(STORE) backup.tgz | tr ' ' '\n' > $@
|
||||||
|
|
||||||
|
.PHONY: init
|
||||||
|
init: configs store
|
||||||
|
|
||||||
|
configs store:
|
||||||
|
while con="$$(find /var /etc/ /sys/ -maxdepth 2 -mindepth 1 -type f 2>/dev/null | $(SELECTOR) -p "Select files for $@\nPress Ctrl+d once done")"; do \
|
||||||
|
echo "$$con"; \
|
||||||
|
done > $@
|
||||||
|
|
||||||
|
$(CONFIGS): %: /%
|
||||||
|
$(CP) $< $@
|
||||||
|
git add $@
|
||||||
|
$(GIT_COMMIT)
|
||||||
|
$(info made git commit for $@)
|
||||||
|
$(STORE): %: /%
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) -r $(CONFIGS) $(STORE) backup.tgz
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
*
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
MONTHS != date +%B && date -d '1 month' +%B
|
||||||
|
IP != dig +short myip.opendns.com @resolver1.opendns.com
|
||||||
|
CITY != curl -s http://api.db-ip.com/v2/free/$(IP) | grep city | cut -d: -f2 | tr -d '"'
|
||||||
|
|
||||||
|
TITLES = $(MONTHS)
|
||||||
|
TITLES += $(CITY)
|
||||||
|
|
||||||
|
BOOKS = $(patsubst %,Books/%.md,$(TITLES))
|
||||||
|
|
||||||
|
$(BOOKS):
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
fortune -l > $@
|
||||||
|
|
||||||
|
progs += $(BOOKS)
|
||||||
|
|
||||||
|
dross += Books/
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
cows = $(patsubst Forts/fortune_%.md,Cows/cow-%.txt,$(wildcard Forts/fortune_*.md))
|
||||||
|
|
||||||
|
$(cows): Cows/cow-%.txt: Forts/fortune_%.md
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
cat $< | cowsay > $@
|
||||||
|
|
||||||
|
progs += forts
|
||||||
|
progs += $(cows)
|
||||||
|
dross += Cows/
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
fnums != seq 8 | sort -R | head -2
|
||||||
|
forts = $(patsubst %,Forts/fortune_%.md,$(fnums))
|
||||||
|
|
||||||
|
$(forts):
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
fortune -s > $@
|
||||||
|
|
||||||
|
progs += $(forts)
|
||||||
|
|
||||||
|
dross += Forts/
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
filter = $(shell cowsay -l | sort -R | head -1)
|
||||||
|
|
||||||
|
zoo = $(patsubst Forts/fortune_%.md,Zoo/animal-%.md,$(forts))
|
||||||
|
|
||||||
|
$(zoo): Zoo/animal-%.md: Forts/fortune_%.md
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
echo '```' > $@
|
||||||
|
cat $< | cowsay -f $(filter) >> $@
|
||||||
|
echo '```' >> $@
|
||||||
|
|
||||||
|
progs += forts
|
||||||
|
progs += $(zoo)
|
||||||
|
|
||||||
|
dross += Zoo/
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
*
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
CHECKER = command -v
|
||||||
|
.PHONY: check
|
||||||
|
check:
|
||||||
|
$(CHECKER) fortune >/dev/null
|
||||||
|
$(CHECKER) cowsay >/dev/null
|
||||||
|
|
||||||
|
file: | check
|
||||||
|
fortune | cowsay > $@
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
forts/big_fort.txt: forts/short.txt forts/long.txt
|
||||||
|
cat forts/short.txt forts/long.txt > forts/big_fort.txt
|
||||||
|
|
||||||
|
forts/:
|
||||||
|
mkdir forts
|
||||||
|
|
||||||
|
forts/short.txt: forts/
|
||||||
|
fortune -s > forts/short.txt
|
||||||
|
|
||||||
|
forts/long.txt: forts/
|
||||||
|
fortune -l > forts/long.txt
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
forts/big_fort.txt: forts/short.txt forts/long.txt
|
||||||
|
cat $^ > $@
|
||||||
|
|
||||||
|
README.md:
|
||||||
|
echo "For an example makefile for python" > $@
|
||||||
|
echo "check out the nd6 dice-roller at" >> $@
|
||||||
|
echo "ssh -p 2222 soft.dmz.rs -t nd6" >> $@
|
||||||
|
|
||||||
|
|
||||||
|
forts/: README.md
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
forts/short.txt: forts/
|
||||||
|
fortune -s > $@
|
||||||
|
|
||||||
|
forts/long.txt: forts/
|
||||||
|
fortune -l > $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf forts
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../PS/omni_makefile
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
IMAGES = $(wildcard jpgs/*)
|
||||||
|
COL = $(patsubst jpgs/%,collection/%,$(IMAGES))
|
||||||
|
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
$(info try 'show' or 'output')
|
||||||
|
.PHONY: show
|
||||||
|
show:
|
||||||
|
$(info IMAGES is $(IMAGES))
|
||||||
|
$(info Col is $(COL))
|
||||||
|
|
||||||
|
.PHONY: output
|
||||||
|
output: $(COL)
|
||||||
|
|
||||||
|
collection/%.jpg: jpgs/%.jpg
|
||||||
|
mkdir -p $(@D)
|
||||||
|
cp $< $@
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
CP = ln -f
|
||||||
|
|
||||||
|
output: pngs/ldap.png
|
||||||
|
|
||||||
|
jpgs/ldap.jpg: ../../ldap/ldap.jpg
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
pngs/%.png: jpgs/%.jpg
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
$(info making $(@F) in $(@D))
|
||||||
|
magick $< $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) -r pngs jpgs
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
include /etc/os-release
|
||||||
|
DAY != date +%d
|
||||||
|
MESSAGE != fortune -s
|
||||||
|
|
||||||
|
motd_$(DAY):
|
||||||
|
$(info Hello $(USER))
|
||||||
|
$(info Placing message:)
|
||||||
|
echo "Welcome to $(NAME)" > $@
|
||||||
|
echo $(MESSAGE) >> $@
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
title:
|
||||||
|
- Making Makefiles
|
||||||
|
author:
|
||||||
|
- Malin
|
||||||
|
|
||||||
|
theme:
|
||||||
|
- Warsaw
|
||||||
|
colortheme:
|
||||||
|
- orchid
|
||||||
|
---
|
||||||
|
|
||||||
|
(presentation in presentation.md)
|
||||||
@@ -0,0 +1,314 @@
|
|||||||
|
# Intro
|
||||||
|
|
||||||
|
The fundamental problem:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git submodule update --init soundscape
|
||||||
|
cargo build --release
|
||||||
|
install -pm755 target/release/tap /usr/local/bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
*But you can't type this for each run.*
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
## First Solution
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/sh
|
||||||
|
git submodule update --init soundscape
|
||||||
|
cargo build --release
|
||||||
|
install -pm755 target/release/tap /usr/local/bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
At this point, every test takes 10 minutes.
|
||||||
|
|
||||||
|
## Second Solution
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/sh
|
||||||
|
[ -f soundscape/.git ] || git submodule update --init soundscape
|
||||||
|
[ -f target/release/tap ] || cargo build --release
|
||||||
|
[ -f target/release/tap ] || \
|
||||||
|
install -pm755 target/release/tap /usr/local/bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Makefile Solutions
|
||||||
|
|
||||||
|
- input, process, output.
|
||||||
|
- automatic idempotence
|
||||||
|
|
||||||
|
```bash
|
||||||
|
INSTALL_DIR = /usr/local/bin
|
||||||
|
|
||||||
|
soundscape/.git:
|
||||||
|
git submodule update --init soundscape
|
||||||
|
|
||||||
|
/usr/local/bin/tap: target/release/tap
|
||||||
|
install -pm755 target/release/tap $(INSTALL_DIR)
|
||||||
|
|
||||||
|
target/release/tap: src soundscape/.git
|
||||||
|
cargo build --release
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# The Three Sigils
|
||||||
|
|
||||||
|
Readable, but slow:
|
||||||
|
|
||||||
|
```make fort_1
|
||||||
|
forts/big_fort.txt: forts/short.txt forts/long.txt
|
||||||
|
cat forts/short.txt forts/long.txt > forts/big_fort.txt
|
||||||
|
|
||||||
|
forts/:
|
||||||
|
mkdir forts
|
||||||
|
|
||||||
|
forts/short.txt: forts/
|
||||||
|
fortune -s > forts/short.txt
|
||||||
|
|
||||||
|
forts/long.txt: forts/
|
||||||
|
fortune -l > forts/long.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
| Make this | From That | From These |
|
||||||
|
|:---------:|:---------:|:----------:|
|
||||||
|
| `$@` | `$<` | `$^` |
|
||||||
|
|
||||||
|
|
||||||
|
```make fort_2
|
||||||
|
forts/big_fort.txt: forts/short.txt forts/long.txt
|
||||||
|
cat $^ > $@
|
||||||
|
|
||||||
|
forts/: README.md
|
||||||
|
mkdir $@
|
||||||
|
forts/short.txt: forts/
|
||||||
|
fortune -s > $@
|
||||||
|
forts/long.txt: forts/
|
||||||
|
fortune -l > $@
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Gotcha: Directories
|
||||||
|
|
||||||
|
|
||||||
|
```make fort_2
|
||||||
|
forts/big_fort.txt: forts/short.txt forts/long.txt
|
||||||
|
cat $^ > $@
|
||||||
|
|
||||||
|
forts/: README.md
|
||||||
|
mkdir $@
|
||||||
|
forts/short.txt: forts/
|
||||||
|
fortune -s > $@
|
||||||
|
forts/long.txt: forts/
|
||||||
|
fortune -l > $@
|
||||||
|
|
||||||
|
README.md:
|
||||||
|
echo "Find the fortunes in the fort dir" > $@
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
|
||||||
|
```make vars
|
||||||
|
include /etc/os-release
|
||||||
|
DAY != date +%d
|
||||||
|
MESSAGE != fortune -s
|
||||||
|
|
||||||
|
motd_$(DAY):
|
||||||
|
$(info Placing message:)
|
||||||
|
echo "Welcome to $(NAME)" > $@
|
||||||
|
echo $(MESSAGE) >> $@
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gotcha: Hanging Quotes
|
||||||
|
|
||||||
|
> echo "Welcome to "Arch Linux""
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
## Add New Variables
|
||||||
|
|
||||||
|
```make
|
||||||
|
make -f vars -e MESSAGE="Red alert, all hands on deck!"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gotcha: Quote, or Risk Escape
|
||||||
|
|
||||||
|
```make
|
||||||
|
make -f vars -e MESSAGE="<h1> HTML Headers </h1>"
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Gotcha: Variables from Shell
|
||||||
|
|
||||||
|
This works:
|
||||||
|
|
||||||
|
```make
|
||||||
|
file:
|
||||||
|
$(info Hello $(USER))
|
||||||
|
```
|
||||||
|
|
||||||
|
...but not this:
|
||||||
|
|
||||||
|
```make
|
||||||
|
file:
|
||||||
|
user=bob
|
||||||
|
echo $user
|
||||||
|
```
|
||||||
|
|
||||||
|
Nor this:
|
||||||
|
|
||||||
|
```make
|
||||||
|
numbers:
|
||||||
|
for x in 1 2 3 4 5; do
|
||||||
|
echo $x
|
||||||
|
done > $@
|
||||||
|
```
|
||||||
|
|
||||||
|
Nor this:
|
||||||
|
|
||||||
|
```make
|
||||||
|
numbers:
|
||||||
|
for x in 1 2 3 4 5; do echo $x ; done > $@
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
### Ugly Fixes are Ugly
|
||||||
|
|
||||||
|
This works, but don't.
|
||||||
|
|
||||||
|
```make
|
||||||
|
file:
|
||||||
|
for x in 1 2 ;\
|
||||||
|
do echo $$x ;\
|
||||||
|
done > $@
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
# Phonies, and the Problems with Lies
|
||||||
|
|
||||||
|
## Clean
|
||||||
|
|
||||||
|
|
||||||
|
```make
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
git clean -fdX
|
||||||
|
```
|
||||||
|
|
||||||
|
## Gotcha: Recompiling without Changes
|
||||||
|
|
||||||
|
```make
|
||||||
|
CHECKER = command -v
|
||||||
|
.PHONY: check
|
||||||
|
check:
|
||||||
|
$(CHECKER) fortune >/dev/null
|
||||||
|
$(CHECKER) cowsay >/dev/null
|
||||||
|
|
||||||
|
file: check # Needs a '|'
|
||||||
|
fortune | cowsay > $@
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
## Non-Compiling Checks
|
||||||
|
|
||||||
|
- `make` -n
|
||||||
|
- *Gotcha*: shell output variables.
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
# The Fourth Sigil: `%`
|
||||||
|
|
||||||
|
Create standardized rules with `%`.
|
||||||
|
|
||||||
|
|
||||||
|
```make rules
|
||||||
|
CP = ln -f
|
||||||
|
|
||||||
|
output: pngs/ldap.png
|
||||||
|
|
||||||
|
jpgs/ldap.jpg: ../../ldap/ldap.jpg
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
$(CP) $< $@
|
||||||
|
|
||||||
|
pngs/%.png: jpgs/%.jpg
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
$(info making $(@F) in $(@D))
|
||||||
|
magick $< $@
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Bling: makefile2graph
|
||||||
|
|
||||||
|
```graph
|
||||||
|
|
||||||
|
┌────────────────┐ ┌────────────────────┐
|
||||||
|
│ forts/long.txt │ ◀── │ forts/ │
|
||||||
|
└────────────────┘ └────────────────────┘
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
│ ▼
|
||||||
|
│ ┌────────────────────┐
|
||||||
|
│ │ forts/short.txt │
|
||||||
|
│ └────────────────────┘
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
│ ▼
|
||||||
|
│ ┌────────────────────┐
|
||||||
|
└──────────────────▶ │ forts/big_fort.txt │
|
||||||
|
└────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gotcha: The Binary is Called `make2graph`
|
||||||
|
|
||||||
|
- Works with GUI tools maybe, IDK, I don't use Windows.
|
||||||
|
- Some systems can use `graph-easy`, but it's outdated.
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Patsubst and Wildcards
|
||||||
|
|
||||||
|
|
||||||
|
```make pats
|
||||||
|
IMAGES = $(wildcard jpgs/*)
|
||||||
|
COL = $(patsubst jpgs/%,collection/%,$(IMAGES))
|
||||||
|
|
||||||
|
.PHONY: show
|
||||||
|
show:
|
||||||
|
$(info IMAGES is $(IMAGES))
|
||||||
|
$(info Col is $(COL))
|
||||||
|
|
||||||
|
.PHONY: output
|
||||||
|
output: $(COL)
|
||||||
|
|
||||||
|
collection/%.jpg: jpgs/%.jpg
|
||||||
|
mkdir -p $(@D)
|
||||||
|
cp $< $@
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Use Cases
|
||||||
|
|
||||||
|
- Backups
|
||||||
|
- Making Websites
|
||||||
|
* `git clone https://gitlab.com/bindrpg/blag`
|
||||||
|
- `NOT installations`
|
||||||
|
- ...but maybe installations?
|
||||||
|
- Setting
|
||||||
Reference in New Issue
Block a user