🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3757

GNU Make question - how to write a rule for such a situation

#3757
From: Gupit
Date: Thu, 31 Jan 2002 20:29
57 lines
2700 bytes
Hi,
I am trying to automate a process using GNU Make. 

I have a target say
CREATE_TRACES: $(trace_files)

$(trace_files) is a dynamically generated list of files and expands to
say
1.trace, 2.trace, 3.trace etc at runtime.

Now these trace files themselves are generated using a command say
genTrace. The trace files are generated as a side effect of this
command and are not  direct output. Also, all the trace files are
generated all at once when I run genTrace.
So "genTrace -options" creates 1.trace, 2.trace etc all at the same
time.

If I write

$(trace_files): command.rc
         genTrace -options

make -j will fire off genTrace for each of the .trace file. This is
not what I want.

Trying to use an implicit rule such as
%$(trace_files): %command.rc
        genTrace -options
which will tell make -j to consider the trace targets to depend on the
same command didnt work.
I was trying to do something of the sort:
%fileA %fileB: %fileC
         <command that generates fileA and fileB at the same time>

To get around this I wrote the rule as follow:

$(trace_files): trace_files_created

trace_files_created: command.rc
        genTrace -options && touch $@

This works, but is not clean. If for some reason, trace_files_created
exists, then there is absolutely no check for $(trace_files) and make
considers CREATE_TRACES uptodate. I want make to check if the .trace
files indeed exist before considering CREATE_TRACES uptodate.

I have two questions:
- Is there a way to write the implicit rule as above so I don't have a
intermediate file.

- How do I structure the rules above in a cleaner, efficient way? I
feel what I did is a hack at most.

I am using GNU Make version 3.79.1 on Solaris and Linux.

Much Thanks,
Bill
Technical Details
Message-ID: <1ea0ec40.0201311229.2efb8898@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109f73,890189702c9e654b,start
X-Google-Attributes: gid109f73,public
X-Google-Thread: fc89c,890189702c9e654b,start
X-Google-Attributes: gidfc89c,public
X-Google-ArrivalTime: 2002-01-31 12:29:54 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
From: gupit@yahoo.com (Gupit)
Newsgroups: comp.unix.programmer,gnu.utils.help
Subject: GNU Make question - how to write a rule for such a situation
Date: 31 Jan 2002 12:29:53 -0800
Organization: http://groups.google.com/
Lines: 57
Message-ID: <1ea0ec40.0201311229.2efb8898@posting.google.com>
NNTP-Posting-Host: 209.213.198.25
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1012508994 7004 127.0.0.1 (31 Jan 2002 20:29:54 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 31 Jan 2002 20:29:54 GMT