bug-make
[Top][All Lists]
Advanced

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

Re: BUG: Setting RM variable does not work


From: Paul Smith
Subject: Re: BUG: Setting RM variable does not work
Date: Fri, 11 May 2018 14:35:55 -0400

On Fri, 2018-05-11 at 13:23 -0400, Jim Anderson wrote:
> I'm attaching the following files for what looks to be a bug in make:

Hi Jim; thanks for your email.  In general we prefer that the contents
be embedded in the mail itself rather than in attachments.  Most
particularly the description of the problem.  If you want to attach a
diff or patch, or a larger makefile, that's OK.

> The bug is that I set the variable 'RM' equal to the value
> 'post', but it has no effect on make.

That's not true.  It has the same effect as setting any other variable.

> As I read section 10.3, "Variables Used by Implicit Rules",
> if I set RM to 'post', then when implicit rules are invoked
> by make, the command used should be 'post', not 'rm'. By
> the way, the documentation says 'rm -f' is the default,
> but 'rm' is being called.

"rm -f" IS the default, and the variable RM IS being used, _when
implicit rules are invoked_ which is what the documentation says.

You can see the list of implicit rules that make knows by running make
with the "-p" option, perhaps like this:

    make -p -f/dev/null

There you will see the default setting of RM:

  # default
  RM = rm -f

And various uses of it in implicit rules, like this which constructs a
C source file from a lex file:

  %.c: %.l
  #  recipe to execute (built-in):
          @$(RM) $@
           $(LEX.l) $< > $@

If you were to set "RM = post" and cause this implicit rule to be
invoked, then you'd see the "post" would be used here not "rm -f" (or
"rm").

The confusion here appears to stem from believing that when make
removes intermediate files that's some sort of implicit rule.  It's
not: that behavior is not implemented by any rules at all, and so the
setting of the RM variable isn't relevant.

Removal of the intermediate files is handled directly by make using the
unlink(2) system call; make merely prints the string "rm ..." as a hint
to the user as to what's going on.  Perhaps that's just confusing and
make should print "Removing ..." instead so it was more clear it wasn't
actually running any sort of remove command.

Currently in make there's no way to control what operations are used to
remove intermediate files (because, as I say above, it's not handled
like a rule by invoking a shell... make directly removes the files
using a system call).

If what you'd like to do is avoid having intermediate files removed at
all, you can do this in various ways.  If what you'd like to do is use
a user-defined command to remove intermediate files, that would need to
be an enhancement to GNU make.

Cheers!



reply via email to

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