Dear Emacs maintainers, thanks to the work of Chris Zheng and Eli Zaretskii we can build Emacs on MSYS2 with MinGW-w64. However, the process is not completely painless: xpm support needs manual tweaking of CFLAGS, configure script must be run with special flags, and make sometimes crashes for the "emacs$(EXEEXT)" target. I am submitting my proposed fixes for these three issues (based on the latest trunk version of Emacs). With this fix I can successfully compile 64-bit Emacs using MSYS2 and MinGW-w64 with automatic xpm support, and the process follows the same easy steps as described in nt/INSTALL (just running ./autogen.sh, ./configure --prefix=..., and make). I intend to submit some additional MSYS2+MinGW-w64 documentation (file nt/INSTALL) should this patch be accepted. Best regards, Karol