[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pulling parts from a filename.
From: |
Todd Showalter |
Subject: |
Re: Pulling parts from a filename. |
Date: |
Wed, 9 Jun 2010 10:03:14 -0400 |
On Wed, Jun 9, 2010 at 4:46 AM, Oleksandr Gavenko <address@hidden> wrote:
> FOO_FNT = foo_14.fnt foo_13.fnt foo_10.fnt
> BAR_FNT = bar_12.fnt bar_9.fnt
>
> FNT = $(FOO_FNT) $(BAR_FNT)
>
> all: $(FNT)
>
> $(FOO_FNT): foo_%.fnt: foo.otf
> fontgen -f $* $< $@
>
> $(BAR_FNT): bar_%.fnt: bar.otf
> fontgen -f $* $< $@
Thanks, but this doesn't quite solve the problem; I've already
got something akin to that in my current makefile. What I'm trying to
determine is if there's a way I can (sanely) unify the $(FOO_FNT) and
$(BAR_FNT) rules, so I don't have to add another one for $(BAZ_FNT)
and $(QUUX_FNT) and so on somewhere down the road. What I want is a
rule for which the target is $(FNT).
These makefiles get reused from project to project, and what I'm
aiming for is a generic font makefile that can simply include $(FNT)
from another file so that the makefile itself never has to be touched.
If the rules have to be rewritten to match the target filenames then
my scheme won't work.
If make had regex backreferences (not that I'm advocating that,
just using it as a tool to explain the effect I'm looking for...), it
might look like:
FNT = foo_14.fnt bar_12.fnt
$(FNT): %_%.fnt: $(%1).otf
fontgen -p $(%2) $< $@
Where $(%1) is the expansion of the first % in the target, and so forth.
I have a feeling it could be done fairly easily with $(eval), but
I'm trying to keep things simple if I can. I know I could also do it
recursively:
-- makefile --
%.fnt: FORCE
@make -sC font.make -DSIZE=$(patsubst %_,,$(basename $@))
$(patsubst _%,.fnt,$@)
-- font.make
%.fnt: %.otf
@fontgen -p $(SIZE) $< $(basename $@)_$(SIZE).fnt
But the recursive method has several problems, not the least being
that the dependency chain is broken in several ways; the above will
always rebuild when invoked.
So, I have brute-force ways of doing what I need to; the question
is merely whether there's a more elegant way of doing this than my
current sledgehammer approach.
Todd.
--
Todd Showalter, President,
Electron Jump Games, Inc.