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