CSC282 2015S, Class 10: Improved Make
Overview
- Preliminaries.
- A quick review of Make.
- Variables in Make.
- Some standard variables for C programs.
- Another example: Document development.
- Automatic variables.
- Generic rules.
- Standard make rules.
- Other useful techniques.
- Miscellaneous tools and techniques.
Preliminaries
Admin
- Remember that there's an excellent free book on Make (listed in
the course front door). You learn make, like most tools, by
using it in your own work.
- Homework one of two:
- Version a: Create a full make suite for some useful C project,
including options for cleaning, packaging, and more. (This
version assumes that you look up the standard targets.)
- Version b: Find a particularly creative makefile and explain
some interesting parts.
Questions
A quick review of Make
Goals
- Make it easier to compile and update projects.
- When you update something like a header file, it knows that
it has to recompile, and recompiles only what is necessary.
- Document the steps needed for compilinga
- We've documented in a computer-usable format
- A human who knows the syntax could also follow them
Format
- Create a file called
Makefile
Need to specify target, action, dependencies
target: dependencies
\t action1
\t action2
...
We can include variables in our makefile (see next section)
- Targets can either be particular files or virtual targets
Learned from writing your own
- Broader issue: How to deal with a project that has a lot of .c and
.h files.
- It makes you more efficient.
- It's relatively easy to do.
- If you have just one target, you can just type
make. If you
have multiple targets, typing make only makes the first one.
- Standard practice: First target is called
default and lists
all the things you really want to make.
Variables in Make
Some standard variables for C programs
Make has a lot of standard rules (e.g., for building .o files from
.c files). We can customize using variables.
Another example: Document development
Sam's web sites
- Simple things: Don't write in HTML
- Write in Markdown (.md)
- Write in Docbook/SGML - HTML + variables!
- Rules for converting
- SGML/Docbook -> html
- md -> html
Multiple steps
- html -> postscript
- postscript -> pdf
Automatic variables
Generic rules
Standard make rules
Other useful techniques
Miscellaneous tools and techniques