Correct some mistakes and inclarities

This commit is contained in:
Midgard 2020-06-11 17:18:53 +02:00
parent 58d3d29bb9
commit 7946b4dff7
Signed by untrusted user who does not match committer: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -1,6 +1,6 @@
title: SVG + makefile = slide deck
summary: "You don't need LibreOffice to prepare your presentation -- or: an introduction to makefiles"
published: 2020-06-02
published: 2020-06-11
---
@ -16,7 +16,7 @@ Traditionally makefiles are used for C programs, but you can use them for absolu
Even this website is built by a makefile.
Want to join me and write one together?
Putting the name of our output file in a variable will make it to change it later, if we'd ever want that.
Putting the name of our output file in a variable will make it easy to change it later, if we'd ever want that.
```makefile
OUTPUT = slides.pdf
```
@ -57,23 +57,23 @@ $(OUTPUT): $(SLIDES_PDF)
pdfjoin $+ -o "$@"
```
It is common to create a `clean` to clean up.
It is common to create a target `clean` to delete output and intermediary files.
```makefile
clean:
rm -rf "$(OUTPUT)" build/
```
If you now create a file `clean` and run `make clean`, *make* will quite contently say it doesn't need to do anything: the file `clean` exists and it depends on nothing else.
If you now create a file named `clean` and run `make clean`, *make* will quite contently say it doesn't need to do anything: the file `clean` exists and has no dependencies that could have been modified.
To avoid this, non-file targets must be marked as "phony".
```makefile
.PHONY: clean
```
# Creating directories
If you would use our makefile up to now, Inkscape would fail, complaining that `build/` doesn't exist.
If you were to use our makefile up to now, Inkscape would fail, complaining that `build/` doesn't exist.
This is to be expected, since directories have to be created before you can place files in them.
Much to my dismay, there seems to be no clean, standard way to create the necessary directories in *make*.
In my opinion, this is *make*'s single biggest shortcoming.
In my opinion, this is *make*s single biggest shortcoming.
There [are a few ways](https://www.cmcrossroads.com/article/making-directories-gnu-make), none of them elegant.
For our simple makefile, we can just put `@mkdir -p $(@D)` in each rule.