help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pulling parts from a filename.


From: Philip Guenther
Subject: Re: Pulling parts from a filename.
Date: Wed, 9 Jun 2010 17:06:59 -0700

On Tue, Jun 8, 2010 at 7:24 PM, Todd Showalter <address@hidden> wrote:
>    I've got a (perhaps somewhat interesting) problem that I can't see
> a particularly easy solution to.  I'm taking an opentype font and
> baking several raster fonts from it using a tool.  If my target is
> (say) foo14.fnt, I want to call:
>
> fontgen -p 14 foo.otf foo14.fnt
>
>    The target filename indicates the point size at which the font
> needs to be generated, and I'd rather automate it.  The important
> thing here is that there may be several fonts; I don't want to have to
> hardcode the font names if I don't have to.
>
>    I can't see any obvious way to do this in make:
>
> %.fnt: ???
>    fontgen -p ??? ??? $@
>
>    I *think* if I require the targets to be of the form foo_14.fnt I
> can use $(patsubst) to isolate the parts.
>
> %,fnt: ???
>    fontgen -p $(patsubst %_,,$@) $(patsubst _%,.otf,$@) $@
>
>    But I'm at a when it comes to the dependency.  I'm not sure how to
> tell make that x_y.fnt depends on x.otf for arbitrary x and y.
>
>    Am I missing something?

Yes: second expansion:

.SECONDEXPANSION:
%.fnt: $$(basename $$(subst _,.,$$*)).otf
        fontgen -p $(patsubst .%,%,$(suffix $(subst _,.,$*))) $< $@

The other tricky thing there is that $(suffix) and $(basename) do
something that $(patsubst) can't.


Philip Guenther



reply via email to

[Prev in Thread] Current Thread [Next in Thread]