[H-GEN] gnu make command-line target ordering problems?

Martin Pool martinp at mincom.com
Sun Oct 17 21:19:20 EDT 1999


[ Humbug *General* list - semi-serious discussions about Humbug and
Unix-related topics. ]

Byron Ellacott wrote:

> >   make clean dep all install
> >it's at least bad form: depending on the makefile, make could well
> >decide that it doesn't _need_ to delete files because it's going to
> >rebuild them later.  However,

That's a bad example, as not many makefiles would be written that way,
but 

> I would consider this *wildly* incorrect behaviour under any circumstances;
> regardless of what make *thinks* the "rm foo.o" command may do, I want make
> to execute the command, not make assumptions about not needing to execute
> it.  

What do you expect make to do?  It's whole _purpose_ is to make
assumptions about what commands it should execute and when.  It only
makes assumptions you specify in the makefile and implicit rules.

The distinction is that Make is a graph processor, not a scripting
language.  A dependency on foo isn't the same as "gosub make_foo",
rather it just adds a dependency edge.

A better example, taken from the 3.77 manual, is

% An example of appropriate use is to avoid including `.d' files during 
% clean rules (see section Generating Dependencies Automatically), so
make 
% won't create them only to immediately remove them again: 
%
% sources = foo.c bar.c
% 
% ifneq ($(MAKECMDGOALS),clean)
% include $(sources:.c=.d)
% endif

Plenty of existing makefiles have trouble coping with this situation.

> As you noted in a later post, using the -j flag could cause problems
> with the "clean" target removing files created by the build target, but
> since I don't use the -j flag (it often results in load blowout, especially
> on single processor systems) the behaviour of the above command is exactly
> what one expects.

That's why you should use the option arguments to limit load average and
number of processors.

 make -j2 all

works well on a single processor system as when one task is waiting for
disk the other can be compiling.

> I cannot see any way to get make itself to decide to remove a file, but I
> did only give the info pages a cursory glance.
> 
> As a side note, I agree with Ben on the counter intuitive nature of having
> those multiple targets executed in parallel.

What do you think the "parallel" option should do?

-- 
 /\\\  Mincom | Martin Pool          | martinp at mincom.com
// \\\        | Software Engineer    | Phone: +61 7 3303-3333
\\ ///        | Mincom Ltd.          | 
 \///         | Teneriffe, Brisbane  | Speaking for myself only

--
This is list (humbug) general handled by majordomo at lists.humbug.org.au .
Postings only from subscribed addresses of lists general or general-post.



More information about the General mailing list