Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gmake and filter inside an implicit rule

70 views
Skip to first unread message

Riccardo de Maria

unread,
May 12, 2002, 2:52:19 PM5/12/02
to
I've problems using filter function to find prerequisites.
My static rule is:

FIND_FILES =$(filter $(1)-%,$(FIG_FILE_NAMES:=.eps))
$(FILE_NAMES:=.dvi): %.dvi :%.tex $(call FIND_FILES,%)

where
FILE_NAMES = cap1 cap2 cap3
FIG_FILE_NAMES = cap1-1 cap2-1 cap2-2 cap3-1 cap3-2

My aim is to make a set of rules like these

cap1.dvi: cap1.tex cap1-1.eps
cap2.dvi: cap2.tex cap2-1.eps cap2-2.eps
cap3.dvi: cap3.tex cap3-1.eps cap3-2.eps

I don't understand why my static rule doesn't work, the problem could
be the double use of % as 'stem' for rule and 'wildcard' for filter,
but I'm not sure.

Thanks

Riccardo de Maria

Paul D. Smith

unread,
May 12, 2002, 6:02:50 PM5/12/02
to
%% r.de...@tiscalinet.it (Riccardo de Maria) writes:

rdm> I've problems using filter function to find prerequisites.
rdm> My static rule is:

rdm> FIND_FILES =$(filter $(1)-%,$(FIG_FILE_NAMES:=.eps))
rdm> $(FILE_NAMES:=.dvi): %.dvi :%.tex $(call FIND_FILES,%)

You cannot call functions, etc. on the patterns, nor can you use auto
variables such as $@, etc. in prerequisite lines.

Functions and variables in target and prerequisites are evaluated when
the makefile is read in, before patterns or auto variables are
instantiated.

--
-------------------------------------------------------------------------------
Paul D. Smith <psm...@gnu.org> Find some GNU make tips at:
http://www.gnu.org http://www.paulandlesley.org/gmake/
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist

Riccardo de Maria

unread,
May 13, 2002, 5:10:39 AM5/13/02
to
"Paul D. Smith" <psm...@gnu.org> wrote in message news:<p5adr5g...@lemming.engeast.baynetworks.com>...

> Functions and variables in target and prerequisites are evaluated when
> the makefile is read in, before patterns or auto variables are
> instantiated.

What a pity! Do you know a way for doing what I want?

I have a large number of cap*-*.fig files and cap*.tex files thus
making dependances tree by hand is very tedious.

Riccardo de Maria

Soren A.

unread,
May 19, 2002, 3:55:57 PM5/19/02
to
"Paul D. Smith" <psm...@gnu.org> wrote in
news:p5adr5g...@lemming.engeast.baynetworks.com on 12 May 2002:

> Find some GNU make tips at:

http://www.paulandlesley.org/gmake/

BTW, Paul, your site explaining how to properly use VPATH and how to set
up multi-architecture builds is (pretending that I'm younger and hipper
than I realy am) "AWESOME" and it has truly changed my life as a hacker.
Kudos.

Soren Andersen
--
# Advanced (or lunatic, depending on your POV) examples of Gmake use:
# || MakefileWorkshop: ||
# http://home.att.net/~perlspinr/makefiles/makefileworkshop.html
#########################################################

igx31

unread,
Mar 9, 2020, 6:14:53 AM3/9/20
to
Le dimanche 12 mai 2002 20:52:19 UTC+2, Riccardo de Maria a écrit :
> I've problems using filter function to find prerequisites.
> [...]

Hello,

We've been having the same issue in one of our projects, and had to resort to using Secondary Expansion for that - cf. https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html

More precisely, we had to build several libraries, named lib/libxxxx.a, from sources named src/xxxx_*.c. This is the rule we have written :

.SECONDEXPANSION:

$(LIB_DIR)/$(LIB_PRE)%$(LIB_SUF): $$(filter $(OBJ_DIR)/%_$\%$(OBJ_SUF), $(OBJ))
$(AR) $(ARFLAGS) $@ $^

In your case, I'm pretty sure it would look something like that (without using your own variables, but it will probably be easy to translate) :

EPS_FILES=$(wildcard cap*.eps)

.SECONDEXPANSION:

cap%.dvi: cap%.tex $$(filter cap%-$\%.eps, $(EPS_FILES))
@echo Building $@ from $^

Hope this helps,
0 new messages