If you ever build a large project, you may notice the entering/leaving directory messages in the output of make command, for example:
mingw32-make: Entering directory ‘C:/myproject’
mingw32-make: Leaving directory ‘C:/myproject’
These messages are not the output of the commands such as “cd” in your Makefile. In fact, the Entering/Leaving directory messages are the output of the make command in your Makefile. Yes, in a Makefile you can call the make command again to make another Makefile. This is so called recursive make.
In normal cases, the make command does not print such messages. The messages are only printed when the make command detects that it is being run by another (parent) make process. The “Enter directory…” messages are output by make at the beginning when it is run.
You can force the make command to print such messages with the
--print-directory option, i.e., mingw32-make –print-directory. Then mingw32-make will print “Entering directory …” when it starts and print “Leaving directory…” when it ends, even it is not being run by another mingw32-make.
Note that the directory in these messages is the directory you run the make command, not the directory that contains the Makefile.
Also note the digit in the square brackets. It is not the thread# or job # in multi-threading or parallel jobs. It is the value of make variable
MAKELEVEL . The first make command has 0
MAKELEVEL . When it executes a second make command, the second make command gets 1
MAKELEVEL . If the second make command calls another make command, the third make command gets 2
MAKELEVEL ,…. If MAKELEVEL=0, “” will be omitted in the “Entering/Leaving directory” messages.