Ok, as you might have noticed, I have begun work on a makefile generator.
Have a look into config/make.tmpl to get an idea how it works.

To see how it works, look at this example:

%define compile_q cmd=$(CC) opt=$(CFLAGS) from=$< to=$@ err=$*.err
	@$(ECHO) "Compiling $(CURDIR)/%(from)..."
	@%(cmd) %(opt) -c %(from) -o %(to) 2>&1|tee %(err)
	@if test ! -s %(err); then rm %(err) ; else true ; fi
%end

This defines a template called "compile_q" (compile quiet) which accepts
the arguments cmd, opt, from, to and err. All arguments have (reasonable)
defaults. The template would be used as so:

$(OBJDIR)/%.o: %.c
	%compile_q

If you must have special options, use it like this:

$(OBJDIR)/%.o: %.c
	%compile_q opt=$(MY_SPECIAL_CFLAGS)

Note that currently, the options must be a single word (ie. no spaces).

If you want to change a makefile so that it uses the new templates, copy
it to "makefile.src" and add at least "%include_deps" to the end of the
makefile. The name is somewhat wrong. This template contains also the rule
to regenerate the makefile from the makefile.src.

To create your first version, use

	gawk -f $(TOP)/scripts/genmf.gawk --assign TOP=$(TOP) \
		makefile.src > makefile

After that, you can edit makefile.src and it will remake the makefile
automatically (the same happens if $(TOP)/scripts/genmf.gawk or
$(TOP)/config/make.tmpl change).

DONE:

- Allow for spaces in options
- You will have to both commit makefile.src and makefile :-/ One solution
might be to remove the makefiles from the CVS server but how do you get
the first version if there is no makefile ?

TODO:

- Allow for recursive templates (ie. use a template in a template)
- Allow host-specific templates

PROBLEMS:

- The first makefile is somewhat complicated to create

Ok, that's it for the next four days. Happy Easter to all of you ! And
don't hack too much ;-)
