How to get pid of my make command in the Makefile?

Viewed 16348

I want to use a temp directory that will be unique to this build. How can I get the pid of my make command in the Makefile?

I tried:

TEMPDIR = /tmp/myprog.$$$$

but this seems to store TEMPDIR as /tmp/myprog.$$ and then eval as a new pid for every command which refs this! How do I get one pid for all of them (I'd prefer the make pid, but anything unique will do).

Thanks in advance.

6 Answers

Here is the answer to your question, which nobody seemed to want to give you:

TEMPDIR := /tmp/myprog.$(shell ps -o ppid $$$$)

Of course, this is not guaranteed to be unique.

Related