Makefile: Difference between revisions
No edit summary |
(→Links) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | |||
An ''executable notebook'' or ''executable cookbook''. | |||
* Makefiles have a version check system built in. For example, if you use a makefile to process a set of jpg's, it takes them all. If you run the makefile again, it only processes the files that where changed. | |||
For example, if you use a makefile to process a set of jpg's, it takes them all. If you run the makefile again, it only processes the files that where changed. | * Makefiles originated on Unix-like systems and are still a primary software build mechanism in such environments. [https://en.wikipedia.org/wiki/Makefile] | ||
==Links== | ==Links== | ||
[https://www.gnu.org/software/make/ GNU Make] | |||
* [https://www.gnu.org/software/make/ GNU Make] | |||
* [https://www.gnu.org/software/make/manual/make.html GNU Make Manual] | |||
* [https://en.wikipedia.org/wiki/Makefile Wikipedia page on Makefiles] | |||
* [https://networkcultures.org/digitalpublishing/2014/10/01/make-book/ Make Book] about make for publishing workflows, written as part of the Digital Publishing Toolkit project | |||
* [https://zgp.org/static/scale12x/# git and make not just for code] | |||
==Git repository: OuNoPo-make == | |||
Development repository: https://git.xpub.nl/OuNoPo-make/ | |||
* RO access: <code>git clone https://git.xpub.nl/repos/OuNoPo-make.git</code> | |||
* RW access: <code>git clone username@git.xpub.nl:/var/www/git.xpub.nl/repos/OuNoPo-make.git</code> | |||
==Example makefile== | ==Example makefile== |
Latest revision as of 07:17, 12 May 2020
An executable notebook or executable cookbook.
- Makefiles have a version check system built in. For example, if you use a makefile to process a set of jpg's, it takes them all. If you run the makefile again, it only processes the files that where changed.
- Makefiles originated on Unix-like systems and are still a primary software build mechanism in such environments. [1]
Links
- GNU Make
- GNU Make Manual
- Wikipedia page on Makefiles
- Make Book about make for publishing workflows, written as part of the Digital Publishing Toolkit project
- git and make not just for code
Git repository: OuNoPo-make
Development repository: https://git.xpub.nl/OuNoPo-make/
- RO access:
git clone https://git.xpub.nl/repos/OuNoPo-make.git
- RW access:
git clone username@git.xpub.nl:/var/www/git.xpub.nl/repos/OuNoPo-make.git
Example makefile
Working with the following structure:
pi@raspberry% tree . ├── images │ ├── 0000.jpg │ ├── 0001.jpg │ ├── 0002.jpg │ └── 0003.jpg ├── Makefile ├── output │ └── a-new-file.txt └── src ├── list.txt ├── plain.txt └── myscript.py
Makefile
images=$(wildcard images/*.jpg) # creates: images/001.jpg images/002.jpg images/000.jpg space:= $(empty) $(empty) newline:= '\n' listtxt:= $(subst $(space),$(newline),$(images)) # subst is a way to do string replacements, it works like this: $(subst $(delimitator),$(replacement),$(list)) # it's used here to make a list of the images, with one filename on each line tesseract: echo $(listtxt) > src/list.txt tesseract src/list.txt src/plain myscript: tesseract cat src/plain.txt | python3 src/myscript.py > output/a-new-file.txt
myscript.py
from sys import stdin, stdout txt = stdin.read() output = txt.replace(' the ', ' ******a***** ') stdout.write(output)