rm -rf mingw
 
-./configure --prefix=`pwd`/mingw --host=i586-mingw32msvc --enable-shared --disable-static --without-matlab --without-octave --without-python --without-guile && make -j4 && make install
+./configure --prefix=`pwd`/mingw --host=i586-mingw32msvc --with-mthreads --enable-shared --disable-static --without-matlab --without-octave --without-python --without-guile && make -j4 && make install
 
 cd mingw/bin
 for dll in *.dll; do
 
 fi
 AC_SUBST(NLOPT_SUFFIX)
 
+AC_ARG_WITH(mthreads,
+        [AC_HELP_STRING([--with-mthreads], [use -mthreads compiler flag])],
+        with_mthrads=$withval,with_mthreads=no)
+if test "x$with_mthreads" = xyes; then
+   CFLAGS="$CFLAGS -mthreads"
+   CXXFLAGS="$CXXFLAGS -mthreads"
+fi
+
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_HEADER_STDC
 AC_HEADER_TIME