Makefile: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
Line 6: Line 6:
==Links==
==Links==
[https://www.gnu.org/software/make/ GNU Make]
[https://www.gnu.org/software/make/ GNU Make]
==Example makefile==
<pre>
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
</pre>

Revision as of 17:33, 22 February 2018

Makefiles are used in compiling processes.

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.

Links

GNU Make

Example 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