0

I'm trying to learn the location of the temp directory a user is configured to use. The GNU Make manual mentions TMPDIR in the Directory Variables section:

[runstatedir] directory should not be cleaned except perhaps at reboot, while the general /tmp (TMPDIR) may be cleaned arbitrarily.

But I can't find TMPDIR documented in Directory Variables, Implicit Variables or Automatic Variables.

Somewhat surprisingly (to me), searching is not producing useful hits. I found a couple of questions on Stack Overflow about creating a unique temp directory based on a PID (here and here), but nothing for a temp directory we are supposed to use at build time for scratch work.

Does GNU Make provide a variable for the temporary directory to use during a build? If so, what is it?

If not, then what should we do to learn the temporary directory configured for a user? In this case, I'm wondering what the practice is.

jww
  • 97,681
  • 90
  • 411
  • 885

1 Answers1

2

TMPDIR is not a standard Make or shell variable. It is what tempnam(3) checks when creating a tempfile path (defaulting to "/tmp").

gmake does use tempnam hence $TMPDIR. But you (the invoker of gmake) are the one who sets it.

Mischa
  • 2,240
  • 20
  • 18
  • GNU make provides no such variable. It has no way of inventing or discovering such a value. It *uses* TMPDIR if someone *else* sets it. hth – Mischa Jul 29 '17 at 01:06