I'm trying to build make 3.82 using MinGW (32 bit) in an msys environment. When I test the results out by attempting to rebuild autoconf with this version of make, I hit the following error: cfg.mk:21: *** Recursive variable `PATH' references itself (eventually). Stop.
The line that's causing the trouble for make is: export PATH = $(shell echo "`pwd`/tests:$$PATH")
It's not that there are two instances of PATH in the command. I can change the second PATH to any variable name I want and I still get the error. I can change PATH = to PATH := and I don't get the error. It looks like when make sees PATH =, it assumes it's working with a variable it needs to expand (with f_recursive not f_simple). To get the rest of the variable, it tries to call the shell and run the echo command. For Windows only, before calling CreateProcess to run anything (such as the shell command), there's a call to sync_Path_environment. So, Windows is probably the only platform where make will run into this error. In variable.c, sync_Path_environment, there's a call to:
char *path = allocated_variable_expand ("$(PATH)"); That's the same PATH variable that's being set by cfg.mk. So, make is trying to expand and bring back the value of the variable recursively. In expand.c, recursively_expand_for_file, v->expanding gets set, v->exp_count is not equal 0, so the error message comes up.
Not sure of the best fix for this. Still investigating that part. By the time, PATH is looked up in sync_Path_environment, it appears to have already started to redefine the PATH variable to $(shell echo "`pwd`/tests:$$PATH"). When sync_Path_environment tries to evaluate PATH, it needs to shell out to do so, thus sync_Path_environment gets called recursively and the recursive PATH error occurs.