Pathname mangling in MSYS + MinGW with nested Makefile

For this article, we use an executable which prints out all of its arguments

#include <stdio.h>

int main(int argc, char** argv)
{
  int i;
  printf("Parameters\n");
  printf("----------\n");
  for (i = 0 ; i < argc ; ++i) {
    printf("[%d] %s\n", i, argv[i]);
  }
  return 0;
}

Nested Makefiles

Create a directory structure with nested Makefiles.

$ find .
.
./Makefile
./showargs.exe
./src
./src/Makefile

Contents of the Makefiles are as follows:

all:
	cd src && $(MAKE)
all:
	../showargs / /usr

Results

$ make
cd src && make
make[1]: Entering directory '/home/user/test/src'
../showargs / /usr
Parameters
----------
[0] C:\msys64\home\user\test\showargs.exe
[1] C:/msys64/
[2] C:/msys64/usr
make[1]: Leaving directory '/home/user/test/src'
$ mingw32-make.exe
cd src && C:/msys64/mingw64/bin/mingw32-make
mingw32-make[1]: Entering directory 'C:/msys64/home/user/test/src'
../showargs / /usr
Parameters
----------
[0] ../showargs
[1] /
[2] /usr
mingw32-make[1]: Leaving directory 'C:/msys64/home/user/test/src'