diff --git a/ext/fox16/extconf.rb b/ext/fox16/extconf.rb
index 631704557d022fe62a6a3e85d677b8f36a640f2f..62dfbb9eb0276a13709cfbc59a7770b3de14dd59 100755
--- a/ext/fox16/extconf.rb
+++ b/ext/fox16/extconf.rb
@@ -95,6 +95,29 @@ def do_cygwin_setup
   end
 end
 
+def do_mingw_setup
+  extra_libs = %w{stdc++ glu32 opengl32 wsock32 comctl32 mpr gdi32 winspool}
+  extra_libs.each do |lib|
+    $libs = append_library($libs, lib)
+  end
+# have_header("sys/time.h")
+  have_header("signal.h")
+  if have_library("z", "deflate")
+    have_library("png", "png_create_read_struct")
+  end
+  have_library("jpeg", "jpeg_mem_init")
+  have_library("tiff", "TIFFSetErrorHandler")
+  $libs = append_library($libs, "FOX-1.6")
+  $CFLAGS = $CFLAGS + " -fpermissive -DWIN32 -Iinclude"
+  if is_fxscintilla_build?
+    FileUtils.move('scintilla_wrap.cpp.bak', 'scintilla_wrap.cpp') if FileTest.exist?('scintilla_wrap.cpp.bak')
+    $CFLAGS = $CFLAGS + " -DWITH_FXSCINTILLA -DHAVE_FOX_1_6"
+    $libs = append_library($libs, "fxscintilla")
+  else
+    FileUtils.move('scintilla_wrap.cpp', 'scintilla_wrap.cpp.bak') if FileTest.exist?('scintilla_wrap.cpp')
+  end
+end
+
 def do_mswin32_setup
   extra_libs = %w{glu32 opengl32 mpr wsock32 comctl32 winspool shell32 advapi32 shell32 gdi32 user32}
   extra_libs.each do |lib|
@@ -193,8 +216,10 @@ unless fxscintilla_support_suppressed?
 end
 
 # Platform-specific modifications
-if RUBY_PLATFORM =~ /cygwin/ || RUBY_PLATFORM =~ /mingw/
+if RUBY_PLATFORM =~ /cygwin/
   do_cygwin_setup
+elsif RUBY_PLATFORM =~ /mingw/
+  do_mingw_setup
 elsif RUBY_PLATFORM =~ /mswin32/
   do_mswin32_setup
 elsif RUBY_PLATFORM =~ /darwin/