I've been using this a few times, and it's really useful for tweaking
big makefiles in ports, or very compact for other stuff.

It's like this, both our make(1) and gmake(1) support recursive variables,
so that:
A = B
C_B = yes

a:
        @echo ${C_$A}}

will display "yes"

this can be used to "specialize" compilation flags on generic rules.

Namely, replace the classic:

.c.o:
        $(CC) -o $@ $(CFLAGS) $<

with:

.c.o:
        $(CC) -o $@ $(CFLAGS) $(CFLAGS_$<) $@

and presto! you can override CFLAGS locally, by setting
CFLAGS_a.c = -O1
for instance, then everything will compile with -O2, except for a.c

variations on this can use $(CFLAGS_${<F}} to have only the file
name, or even $(CFLAGS_${<F:.c=}}  if you'd prefer CFLAGS_a = -O1.

Reply via email to