[Top][All Lists]

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

Re: Static Pattern use of function in Prereq

From: Paul D. Smith
Subject: Re: Static Pattern use of function in Prereq
Date: Tue, 17 Feb 2004 15:18:09 -0500

%% Jaye Speaks <address@hidden> writes:
  js> trying to build a Makefile that will run each src/*.htmlpp through
  js> cpp to preprocess ifdefs resulting in customer version of .html
  js> pages and have these .html pages created in the appropriate
  js> customer version directory.

  js> My questions are related to implementing the targets and prereqs
  js> somewhat dynamically.  My current design is to utilize Static Pattern
  js> rules to generate the prereqs, but it looks like you can't utilize
  js> text transformation functions in the prereq pattern.

Correct.  Rule targets and prerequisites are completely parsed when the
makefile is read in.  Patterns aren't resolved until after that is
done.  So, the functions operate on the pattern not the instantiation of
the pattern.

  js> 1. Is there a way to modify the prereq in a Static Pattern using
  js>    text functions.  If not, what is another solution.

Not really.  You can have multiple pattern rules using different
prerequisites, but you'd have to list a separate rule for each

Since you are going to rebuild the output for every customer if the
source changes anyway, one way to solve the problem is do it all in one

  SRCDIR := src

  SRCS := $(notdir $(wildcard $(SRCDIR)/*.htmlpp))

  $(foreach B,$(BUILDS),$(B)/%.html) : $(SRCDIR)/%.htmlpp
        rm -f $(addsuffix /$*.html,$(BUILDS))
        $(foreach B,$(BUILDS),$(PP) -D$(B) $< > $(B)/$*.html &&) true

or something like that (note the above is completely untested).

If you don't like that idea you'll have to use $(eval ...) to
dynamically create new rules.

  js> 2. What are some acceptable ways to pass multiple variables to a
  js> rule.

You can't "pass variables to a rule".  Variables (except for target- or
pattern-specific variables) are global and have their values defined
globally.  When a string is expanded all variables are replaced with
whatever value they have at that time.

  js> In my makefile below, is parse up the target variable to determine
  js> its path and reuse that as a value I need in the command.  Doesn't
  js> seem like the best implementation.

The only alternative would be to use target-specific variables.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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