Correct some mistakes and inclarities
This commit is contained in:
parent
58d3d29bb9
commit
7946b4dff7
1 changed files with 6 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
||||||
title: SVG + makefile = slide deck
|
title: SVG + makefile = slide deck
|
||||||
summary: "You don't need LibreOffice to prepare your presentation -- or: an introduction to makefiles"
|
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.
|
Even this website is built by a makefile.
|
||||||
Want to join me and write one together?
|
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
|
```makefile
|
||||||
OUTPUT = slides.pdf
|
OUTPUT = slides.pdf
|
||||||
```
|
```
|
||||||
|
@ -57,23 +57,23 @@ $(OUTPUT): $(SLIDES_PDF)
|
||||||
pdfjoin $+ -o "$@"
|
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
|
```makefile
|
||||||
clean:
|
clean:
|
||||||
rm -rf "$(OUTPUT)" build/
|
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".
|
To avoid this, non-file targets must be marked as "phony".
|
||||||
```makefile
|
```makefile
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
```
|
```
|
||||||
|
|
||||||
# Creating directories
|
# 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.
|
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*.
|
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.
|
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.
|
For our simple makefile, we can just put `@mkdir -p $(@D)` in each rule.
|
Loading…
Reference in a new issue