-----BEGIN PGP SIGNED MESSAGE-----
This is a very simple Make example for people who have never heard of Make.
Say you wrote your resume in LaTeX. Maybe you also want to include a picture of
yourself! You have two files:
where resume.tex includes portrait.jpg in the source. Here is how you can
generate your resume:
$ pdflatex resume.tex
portrait.jpg resume.pdf resume.tex
But then you realize the file size of your resume is very large! You can reduce
the size of your portrait:
$ convert portrait.jpg -resize 256x256 portrait_small.jpg
portrait.jpg portrait_small.jpg resume.pdf resume.tex
and then edit resume.tex to use the new portrait file. If you ever change your
resume, you have to re-run pdflatex. Also, if you ever change your portrait
(e.g. you have grown a beard (or shaved it)), you must re-run convert AND
pdflatex! That's a lot of work!
With GNU Make, the whole build process becomes very easy. Just write a file
named "makefile" containing these two rules:
resume.pdf : resume.tex portrait_small.jpg
portrait_small.jpg : portrait.jpg
convert portrait.jpg -resize 256x256 portrait_small.jpg
Now, if you ever change anything, all you need to do is run make:
$ make resume.pdf
and you have your resume! In the makefile above, there are two "rules". Each
rule looks like this:
TARGET_FILE : REQUIRED_FILE_1 REQUIRED_FILE_2 ...
commands that generate the "target" file from the "required" files
can be multiple lines (must indent with tab)
In the makefile that generates your resume, Make attempts to create the target
"resume.pdf", but that requires "portrait_small.jpg" which might be old or
might not exist. It looks for another rule with a target named
"portrait_small.jpg" and finds it right below. After creating
portrait_small.jpg, it can go back to the first rule and generate your resume.
This is all the Make I needed to know to get by as an undergraduate in the
Computer Science department at UCLA. It's an extremely useful skill!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
-----END PGP SIGNATURE-----
back to Troy's homepage