|
Unix Programming - make: Automating Your Recipes - make in Non-C/C++ Development
make in Non-C/C++ Development
make is not just useful for C/C++
recipes, however. Scripting languages like those we described in
Chapter14 may not require
conventional compilation and link steps, but there are often other
kinds of dependencies that
make(1)
can help you with.
Suppose, for example, that you actually generate part of your
code from a specification file, using one of the techniques from Chapter9. You can use
make to tie the spec file and the generated
source together. This will ensure that whenever you change the spec
and remake, the generated code will automatically be rebuilt.
It's quite common to use makefile productions to express recipes
for making documentation as well as code. You'll often see this
approach used to automatically generate PostScript or other derived
documentation from masters written in some markup language (like HTML
or one of the Unix document-macro languages we'll survey in Chapter18). In fact, this sort of use is so
common that it's worth illustrating with a case study.
Case Study: make for Document-File Translation
In the
fetchmail makefile,
for example, you'll see three productions that relate files named
FAQ, FEATURES, and
NOTES to HTML sources
fetchmail-FAQ.html,
fetchmail-features.html, and
design-notes.html.
The HTML files are meant to be accessible on the fetchmail Web
page, but all the HTML markup makes them uncomfortable to look at
unless you're using a browser. So the FAQ,
FEATURES, and NOTES are
flat-text files meant to be flipped through quickly with an editor or
pager program by someone reading the fetchmail
sources themselves (or, perhaps, distributed to FTP sites that don't
support Web access).
The flat-text forms can be made from their HTML masters by using
the common open-source program
lynx(1).
lynx is a Web browser for text-only
displays; but when invoked with the -dump option it
functions reasonably well as an HTML-to-ASCII formatter.
With the productions in place, the developer can edit the HTML
masters without having to remember to manually rebuild the flat-text
forms afterwards, secure in the knowledge that
FAQ, FEATURES, and
NOTES will be properly rebuilt whenever they are
needed.
[an error occurred while processing this directive]
|