[Top][All Lists]

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

Re: wish: multiple target patterns in a static pattern rule

From: Paul D. Smith
Subject: Re: wish: multiple target patterns in a static pattern rule
Date: Tue, 13 Apr 2004 16:00:49 -0400

%% Britton Kerin <address@hidden> writes:

  bk> I have a program gob2 which does this:

  bk>      some_file.gob -> {some_file.c some_file.h some_file-private.h}

  bk> So I would like to be able to write this static pattern rule:

  bk>      # This rule says how to generate C files from GOB files.
  bk>      $($(MN)_GOB_GENERATED_FILES): %.c %.h %-private.h: %.gob
  bk>              $($(MN)_GOB2) $<

  bk> Implicit rules can handle multiple target patterns, is there any
  bk> reason static pattern rules couldn't also?

The reason is that static pattern rules are shorthand for writing
explicit rules, not longhand for writing implicit rules.

That is, a static pattern rule is turned into a long list of explicit
rules as the makefile is read in, and so it has all the behaviors of an
explicit rule instead of the behaviors of an implicit rule.

Changing that would be a major change to the way make works.

  bk> There could be a simple requirement that each element of the
  bk> TARGETS match exactly one of the target patterns.  The workaroud
  bk> requires me to split up the GOB_GENERATED_FILES variable into
  bk> three and write three static pattern rules to get the effect I
  bk> want, which is a bit clunky,

You don't have to split it into three from a user's perspective: you
could split it into three in the static pattern rules themselves,
something like:

  $(filter %.h,$($(MN)_GOB_GENERATED_FILES)): %.h: %.gob


Slightly less clunky.

  bk> especially since (with automatic dependency tracking) I don't have
  bk> to care about header files much, and don't have any reason to put
  bk> them in seperate variables.

I'm assuming there's some reason you can't just use an implicit rule
here in the first place.  If you don't use implicit rules you'll have to
be careful to use a dummy target if you want to have a single command
line generate all those files: explicit (and static pattern) rules don't
work like that.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "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]