Basic

-MinGW 64bit
-Msys2 64bit
x86_64 installation

MSYS2 Setup

$pacman -Sy
$pacman -Su
Until no restart of MSYS2 is required

Checking GCC/Gfortran
$ pacman -Ssq gcc
and select collect package like...
$ pacman -S mingw-w64-x86_64-gcc
$ pacman -S mingw-w64-x86_64-gcc-fortran

Enable Make
$ pacman -S make

Configure

If "ERROR(FoX) Cannot open file" error exists, to eliminate
$ ./configure -eneable-xml=no

Intel MKLs
"Space" in directory name makes error, so copy libs to good directory, and eliminate it.
$ ./configure LAPACK_LIBS="/z/dft/qe-6.4.1/extlibs/libmkl_lapack95_ilp64.a" BLAS_LIBS="/z/dft/qe-6.4.1/extlibs/libmkl_blas95_ilp64.a"

when using internal libs, isamax.o error > -enable-parallel=no (?unsolved problem)

sometimes need to set
$ ./configure ARCH=mingw64

Before $make all, edit make.inc
Commenting out
TOPDIR = $(dir $(abspath $(filter %make.inc,$(MAKEFILE_LIST))))

Uncomment
# TOPDIR = /z/DFT/qe-6.4.1

Intel Fortran for Win?

-Launch msys from Intel command line like...
>c:\msys64\usr\bin\bash.exe
-ifort available but mpiifort not?????
insted of mpiifort, use mpifc.bat
So, ifort and mpifc.bat are avalable on msys2 but linux command not available..........

-adding paths for windows environmental variables
C:\msys64\usr\bin
C:\msys64\mingw64\bin

firstly:
$ ./configure cc=gcc ARCH=mingw64 LAPACK_LIBS="/z/dft/qe-6.4.1/extlibs/libmkl_lapack95_ilp64.lib" BLAS_LIBS="/z/dft/qe-6.4.1/extlibs/libmkl_blas95_ilp64.lib"

then configure your make.inc like:
# TOPDIR = $(dir $(abspath $(filter %make.inc,$(MAKEFILE_LIST))))
TOPDIR = /z/dft/qe-6.4.1
DFLAGS = -D_WIN32 -D__FFTW -D__MPI
MPIF90 = mpifc.bat
F90 = mpifc.bat
CC = gcc
F77 = mpifc.bat
LD = mpifc.bat
MPI_LIBS =
(Do not specify MPI_LIBS) (Coexisting different compiler, namely coexiting ifort/mpiifort leads error while compiling fox_init_module_tmp.f90)

some falure example at first
$ PATH=/bin:$PATH
but ifort become buggy...(dis-linked...), but become available with following
$ ifort -Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\AMD64" hoge.f90
OK, not smart.
$ alias ifort='ifort -Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\AMD64"'
create mpifc2.bat or something from mpifc.bat, then change here

set FC=ifort.exe -Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\AMD64"

then mpiifort compiling on msys with make/configure available environment is ready, oh and
$ alias mpiifort='mpifc2.bat'


$ ./configure MPIF90=mpiifort ARCH=mingw64 LAPACK_LIBS="/z/dft/qe-6.4.1/extlibs/libmkl_lapack95_ilp64.lib" BLAS_LIBS="/z/dft/qe-6.4.1/extlibs/libmkl_blas95_ilp64.lib"