[Top][All Lists]

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

Matching subdirectories in patterns?

From: Roy Stogner
Subject: Matching subdirectories in patterns?
Date: Wed, 23 Sep 2009 11:44:49 -0500 (CDT)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

I'm writing a Makefile for use in building LaTeX documents generated
by other users.  For use with pdflatex, some format conversion of
figures is necessary.  Because the Makefile is intended for reuse in
many different projects, figure names are not known in advance for
generating target names.

Creating targets which turn a flat directory "rawfigs/" full of source
figures into a directory "figs/" full of converted results isn't too
complicated.  The solution I'm using (or rather, the hack I'm using,
since I don't care that it will break for filenames containing

vectorsources := $(shell find rawfigs/ ../common/rawfigs/ -name '*.dia' -o 
-name '*.eps' -o -name '*.ps' -o -name '*.pdf')
vectorfigs := $(shell echo ' ' $(vectorsources) ' ' | sed -e 's> 
\(../common/\)*raw> >g' -e 's/\.[^. ]* /.pdf /g')

This generates a list vectorfigs which, for each source image, creates
a target pdf image with the same filename in a different directory.  A
set of pattern rules then tells make how to build those targets, e.g.:

figs/%.pdf: rawfigs/%.eps
        mkdir -p $(dir $@)
        epstopdf $? -o=$@

However, this doesn't work when rawfigs/ isn't a flat directory.  If a
user has rawfigs/subdir1/fig.eps, the target figs/subdir1/fig.pdf is
correctly added to the vectorfigs list, but when asked to generate it,
make dies with a "no rule to make target" error.  It appears that the
pattern character % doesn't match the directory separator character /
in a target.

Does anyone have any suggestions?  Is there a way to create a pattern
rule (or a patterned vpath directive, perhaps) where the pattern
matches subdirectories?
Roy Stogner

reply via email to

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