help-make
[Top][All Lists]
Advanced

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

Re: more matching power than "%" for pattern rules


From: Paul D. Smith
Subject: Re: more matching power than "%" for pattern rules
Date: Wed, 11 Oct 2000 17:06:38 -0400

%% Regarding more matching power than "%" for pattern rules; you wrote:

  rjd> $(TOBJS): %.o : <need something here>
  rjd>  $(ISIP_CPLUS_COMPILER) $(I_FLAGS) $(CPLUS_FLAGS) $(C_FLAGS) -o $*.o 
`echo $* | $(MTEMPLATE_PARSER) source_name` -DISIP_TEMPLATE_TARGET="`echo $* | 
$(MTEMPLATE_PARSER) template_args`"

  rjd> I'd like for the dependency to be the individual source file. I've
  rjd> tried these two variations:

  rjd> $(TOBJS): %.o : `echo % | $(MTEMPLATE_PARSER) source_name`

This won't work; GNU make doesn't grok ``.  That's a shell feature, not
a make feature.

  rjd> and

  rjd> $(TOBJS): %.o : $(shell echo % | $(MTEMPLATE_PARSER) source_name)

This won't work, because the shell function is expanded when the
makefile is invoked, but at that time the "%" pattern isn't expanded,
it's just the literal character "%", so that's what's being passed to
the shell.

  rjd> So is there any way to get a shell command executed on the dependency
  rjd> list? Or to do a more powerful search than a single "%" character that
  rjd> must be exactly the same in two files with no other variations?

Not really.  Make doesn't currently allow for any very convenient method
of dynamically constructing rules in complex ways like this.

The easiest way to do what you want is to take advantage of make's
auto-re-exec feature to construct a makefile segment dynamically.

That is, define this:

  $(TOBJS):
        $(ISIP_CPLUS_COMPILER) ...

  include tobjs_rules.mk

  tobjs_rules.mk: Makefile
        rm -f $@
        for f in $(TOBJS:.o=); do \
          echo "$$f.o: `echo $$f | $(MTEMPLATE_PARSER) source_name` >> $@; \
        done

Hopefully you get the idea; if not let me know.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          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



reply via email to

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