If you use Cheetah, please support the project and register by clicking here:


13.8 Makefiles

If your project has several templates and you get sick of typing ``cheetah compile FILENAME.tmpl'' all the time-much less remembering which commands to type when-and your system has the make command available, consider building a Makefile to make your life easier.

Here's a simple Makefile that controls two templates, ErrorsTemplate and InquiryTemplate. Two external commands, inquiry and receive, depend on ErrorsTemplate.py. Aditionally, InquiryTemplate itself depends on ErrorsTemplate.

all:  inquiry  receive

.PHONY:  all  receive  inquiry  printsource

printsource:
        a2ps InquiryTemplate.tmpl ErrorsTemplate.tmpl

ErrorsTemplate.py:  ErrorsTemplate.tmpl
        cheetah compile ErrorsTemplate.tmpl

InquiryTemplate.py:  InquiryTemplate.tmpl ErrorsTemplate.py
        cheetah compile InquiryTemplate.tmpl

inquiry: InquiryTemplate.py  ErrorsTemplate.py

receive: ErrorsTemplate.py

Now you can type make anytime and it will recompile all the templates that have changed, while ignoring the ones that haven't. Or you can recompile all the templates receive needs by typing make receive. Or you can recompile only ErrorsTemplate by typing make ErrorsTemplate. There's also another target, ``printsource'': this sends a Postscript version of the project's source files to the printer. The .PHONY target is explained in the make documentation; essentially, you have it depend on every target that doesn't produce an output file with the same name as the target.

If you use Cheetah, please support the project and register by clicking here: