🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
9 messages
9 total messages Started by Ian Zimmerman Sat, 24 Jan 2004 18:18
make (possible FAQ)
#3729
Author: Ian Zimmerman
Date: Sat, 24 Jan 2004 18:18
17 lines
1525 bytes
So, how does one handle, in plain make, the situation where multiple
outputs depend on the same input, and the same command updates both
outputs?

The GNU make manual says if both outputs are listed as targets of the
same rule, the command will be run twice, once for each target --- which
isn't what I want.  I remember the real situation was more complex with GNU
make, it tried to optimize this, but it was undocumented and impossible
to figure out.

Also, presumably the documented behavior is what other make implementations
do, and I'd like to stay compatible with them.

-- 
Nothing can be explained to a stone.
Or to a stoned person, either.
Re: make (possible FAQ)
#3730
Author: Maurizio Loreti
Date: Sun, 25 Jan 2004 08:21
12 lines
1552 bytes
Ian Zimmerman <bayard@newsguy.com> writes:

> So, how does one handle, in plain make, the situation where multiple
> outputs depend on the same input, and the same command updates both
> outputs?

target1 target2: input
        command

-- 
Maurizio Loreti                         http://www.pd.infn.it/~loreti/mlo.html
Dept. of Physics, Univ. of Padova, Italy              ROT13: ybergv@cq.vasa.vg
Re: make (possible FAQ)
#3731
Author: Ian Zimmerman
Date: Sun, 25 Jan 2004 18:31
12 lines
1281 bytes
Ian> So, how does one handle, in plain make, the situation where
Ian> multiple outputs depend on the same input, and the same command
Ian> updates both outputs?

Maurizio> target1 target2: input command

Maybe you could read te whole post :-)

-- 
Nothing can be explained to a stone.
Or to a stoned person, either.
Re: make (possible FAQ)
#3732
Author: mike burrell
Date: Sun, 25 Jan 2004 18:47
26 lines
2248 bytes
In gnu.utils.help Ian Zimmerman <bayard@newsguy.com> wrote:
> So, how does one handle, in plain make, the situation where multiple
> outputs depend on the same input, and the same command updates both
> outputs?
> 
> The GNU make manual says if both outputs are listed as targets of the
> same rule, the command will be run twice, once for each target --- which
> isn't what I want.  I remember the real situation was more complex with GNU
> make, it tried to optimize this, but it was undocumented and impossible
> to figure out.

I would just make one output file depend on the other.  e.g., I recall doing
something like this once or twice:

y.tab.h:	y.tab.c
y.tab.c:	foo.y
	yacc -d foo.y

Where yacc creates two output files for one input file.  It's perhaps not
the cleanest way of doing things....

-- 
 /"\                                                 m i k e   b u r r e l l
 \ /     ASCII RIBBON CAMPAIGN                                mikpos@shaw.ca
  X        AGAINST HTML MAIL,
 / \      AND NEWS TOO, dammit
Re: make (possible FAQ)
#3733
Author: Ross Smith
Date: Sun, 25 Jan 2004 18:48
25 lines
1809 bytes
Ian Zimmerman wrote:

> 
> So, how does one handle, in plain make, the situation where multiple
> outputs depend on the same input, and the same command updates both
> outputs?
> 
> The GNU make manual says if both outputs are listed as targets of the
> same rule, the command will be run twice, once for each target ---
> which isn't what I want.

Use an intermediate target that both targets depend on:

.PHONY: both

both:
        command

target1 target2: both

-- 
Ross Smith ......... r-smith@ihug.co.nz ......... Auckland, New Zealand

    "This world is like a burnt steak: small, tough, and the chips
    are always stacked against you." -- Mike
Re: make (possible FAQ)
#3734
Author: Maurizio Loreti
Date: Mon, 26 Jan 2004 06:41
13 lines
1672 bytes
Ian Zimmerman <bayard@newsguy.com> writes:

> Maybe you could read te whole post :-)

I did.  If running "command" is triggered by inadequacy of target1,
but updates both target1 and target2, a second run of command is never
triggered being now target2 up-to-date..

Maybe you could try the suggested solutions :-)

-- 
Maurizio Loreti                         http://www.pd.infn.it/~loreti/mlo.html
Dept. of Physics, Univ. of Padova, Italy              ROT13: ybergv@cq.vasa.vg
Re: make (possible FAQ)
#3735
Author: Barry Margolin
Date: Mon, 26 Jan 2004 08:16
21 lines
1944 bytes
In article <rm7jzfp5z0.fsf@mlinux.pd.infn.it>,
 Maurizio Loreti <mlo@foobar.it> wrote:

> Ian Zimmerman <bayard@newsguy.com> writes:
> 
> > Maybe you could read te whole post :-)
> 
> I did.  If running "command" is triggered by inadequacy of target1,
> but updates both target1 and target2, a second run of command is never
> triggered being now target2 up-to-date..

I don't think that's how make works.  It makes a plan at the beginning.  
So if target1 and target2 are initially out of date, it will plan on 
running the rules that update each of them.  If updating target1 also 
updates target2, it won't revise its plan; it will still run the rule a 
second time to update target2.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Re: make (possible FAQ)
#3736
Author: Maurizio Loreti
Date: Mon, 26 Jan 2004 11:20
24 lines
2173 bytes
Barry Margolin <barmar@alum.mit.edu> writes:

> I don't think that's how make works.  It makes a plan at the beginning.  

No, it doesn't; but this may depend from the implementation.   Look:

        MLO@mlinux 26 $ cat Makefile
        foo bar: quux
                @echo executing
                @touch foo bar
        MLO@mlinux 27 $ rm -f foo bar && touch quux
        MLO@mlinux 28 $ make foo bar
        executing
        make: `bar' is up to date.
        MLO@mlinux 29 $ make --version
        GNU Make 3.80
        Copyright (C) 2002  Free Software Foundation, Inc.
        This is free software; see the source for copying conditions.
        There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
        PARTICULAR PURPOSE.

-- 
Maurizio Loreti                         http://www.pd.infn.it/~loreti/mlo.html
Dept. of Physics, Univ. of Padova, Italy              ROT13: ybergv@cq.vasa.vg
Re: make (possible FAQ)
#3737
Author: mike burrell
Date: Mon, 26 Jan 2004 18:13
18 lines
2062 bytes
In gnu.utils.help Maurizio Loreti <mlo@foobar.it> wrote:
> Barry Margolin <barmar@alum.mit.edu> writes:
>> I don't think that's how make works.  It makes a plan at the beginning.  
> 
> No, it doesn't; but this may depend from the implementation.   Look:

You're right.  It doesn't work so well for parallel builds though:

$ make -j 2 foo bar
executing
executing
$

-- 
 /"\                                                 m i k e   b u r r e l l
 \ /     ASCII RIBBON CAMPAIGN                                mikpos@shaw.ca
  X        AGAINST HTML MAIL,
 / \      AND NEWS TOO, dammit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads