bug-make
[Top][All Lists]
Advanced

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

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


From: Ted Stern
Subject: Re: wish: multiple target patterns in a static pattern rule
Date: Tue, 13 Apr 2004 12:37:39 -0700
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux)

On 13 Apr 2004 at 10:27 PDT, Britton Kerin wrote:
>
> I have a program gob2 which does this:
>
>      some_file.gob -> {some_file.c some_file.h some_file-private.h}
>
> So I would like to be able to write this static pattern rule:
>
>      # This rule says how to generate C files from GOB files.
>      $($(MN)_GOB_GENERATED_FILES): %.c %.h %-private.h: %.gob
>              $($(MN)_GOB2) $<
>
> Implicit rules can handle multiple target patterns, is there any reason
> static pattern rules couldn't also?  There could be a simple requirement
> that each element of the TARGETS match exactly one of the target patterns.
> The workaroud requires me to split up the GOB_GENERATED_FILES variable
> into three and write three static pattern rules to get the effect I want,
> which is a bit clunky, especially since (with automatic dependency
> tracking) I don't have to care about header files much, and don't have any
> reason to put them in seperate variables.
>

Hi Britton, 

One way to do this is something like the following:

    ALLGOBFILES := ... # list of *.gob files

    %.gobdeps: %.gob
         $(MKDEPGOB) $<

    %.c: %.gob
         $(GOB_PROCESS) $<

    %.h:;

    include $(ALLGOBFILES:.gob=.gobdeps)

Your mkdepgob script can create explicit dependencies like

     some_file-private.h: some_file.c
     some_file.h:         some_file.c

to set up evaluation order.

The pattern rule for %.h files never forks a shell -- check for yourself using
make -d.

I think of this style as a "primary file + byproduct file(s)" rule.  You can
reduce potential compilation cascades even further by ensuring that your *.gob
processor compares previously existing output files against the new output and
retains the original timestamp if no changes have been made.

Ted
-- 
 Ted Stern                                 Applications Group
 Cray Inc.                               office: 206-701-2182
 411 First Avenue South, Suite 600         cell: 206-383-1049
 Seattle, WA 98104-2860                     FAX: 206-701-2500

 Frango ut patefaciam -- I break that I may reveal
 (The Paleontological Society motto, equally apropos for debugging)





reply via email to

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