At some point I was helping a friend with doing a website for his stepfather. Since it was only five pages I wanted to have something very simple to generate html pages from a header, a body and footer where header and footer would of course be the same for every page.
My "brilliant" idea was to combine the gcc preprocessor with make to achieve this and here is the Makefile i wrote:
CFLAGS=-x c -E -P
OBJS:=$(patsubst %.tmpl, %.html, $(SOURCES))
%.html: %.tmpl $(INCLUDES)
$(CC) $(CFLAGS) -o $@ $<
rm -f *.html
CFLAGS are forcing gcc to treat the files as c code, to only run the
preprocessor and to not generate line markers in the output.
Files named *.incl are for example
footer.incl and are
included by *.tmpl files. Every *.tmpl file is turned into a *.html file and
the *.tmpl files can contain statements like:
And of course due to the nature of make a *.html file will only be regenerated if one of it's dependendcies (the corresponding *.tmpl or one of the *.incl) change. No speed improvement for my five html pages setup but it's the idea that counts here ;)