[Top][All Lists]

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

Re: Lint for Makefiles

From: Kaz Kylheku (gmake)
Subject: Re: Lint for Makefiles
Date: Mon, 12 Apr 2021 12:09:09 -0700
User-agent: Roundcube Webmail/0.9.2

On 2021-04-02 11:50, Christian Hujer wrote:
Hey Kaz,

thanks for pointing that out.
I was primarily interested in GNU Makefiles only, but it's always good
to have a broader perspective to make the tool more useful for others.

If I'm not mistaken, `$(RM)` doesn't always expand to `rm -f` but to
something else like `delete/nolog` on VMS for example.

I Christian,

Here is something I have discovered which is tangentially relevant
to the RM discussion.

GNU Make deletes intermediate targets: targets
whose necessity it has itself deduced via application of implicit
rules, and which it has created, but which are not explicitly
listed as goals anywhere.

For instance, if you write a %.s: %.c rule for converting C
to assembler, and then %.o: %.s for assembling it, and then
wrote a rule foo.o: foo.c, make will deduce that it has to make
the intermediate foo.s. Since you don't mention any foo.s,
it will delete it when the build is done.

What I discovered is that this deletion is done with an
unlink() call in the source code, even though the code prints a
message suggesting that "rm" is being used.

For each file, the code first unlinks the file, and then puts
out the name of the file preceded by "rm " if it is the first
file, or else by " ". Finally, a newline is issued.

(In the case when make is terminating due to a signal, and deleting
the files for that reason, the messaging is different; no fake
"rm ...".)

So the code will not react to the RM variable. For it to work on
VMS, the unlink call has to be supported somehow.

I think it would be nicer if this logic simply gathered the names of
all the non-precious temporary files into some well-known variable
like INTERMEDIATE_FILES. It could be documented that these are deleted using INTERMEDIATE_RM whose default value is $(RM) $(INTERMEDIATE_FILES).

The user could have reasons to customize this.

For instance, I'd like the removal to observe my VERBOSE variable;
i.e. I would like to insert a @ into the command so it does not
appear, unless enabled by a VERBOSE = y. Looks like that is not

reply via email to

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