I must admit I thought about that idea also, but I wasn't sure about
the portability issue.
You could also think about a autogenerated Make.defs during configure
with then hard coded include paths which should be the fastest
possibility.
Since Make.defs is already copied, perhaps it could also be modified
on the fly.
I am most of the way through converting incdir.sh to a C version,
incdir.c. I will probably submit a PR that just adds the .c file
(without changing the build system). Then we can experiment with it
and make sure we are comfortable before bringing it into the build.
I will first test with Cygwin where I was seeing 7 minutes (still too
long). I won't bother if there is no significant improvement.
Okay.. I have submitted the C version of incdir.sh and it is a lot
faster. That is PR 1148. Please do review.
I using Cygwin which did not have the terrible performance as you are
seeing under MSYS2. I but I still got a substantial improvement, from 7
minutes down to 5 minutes and 20 seconds. That is 75% from the previous
time. I bet you do a lot better than that. I believe it should be even
faster than it was before (not forks at all!).
The new .c file is NOT yet hooked into the build system. There are
special instructions available in the PR 1148 comments under the Testing
section. Essentially, you override the definition of INCDIR as
incdir.sh changing it to be incdir.exe (and, of course, you have to
build incdir.exe manually).