Index: src/makemake.tcl
===================================================================
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -674,6 +674,218 @@
 .PHONY: clobber
 clobber: clean
 	del /F *.exe
 }
 
+}
+
+if { ![string compare -nocase "MinGW" [lindex $argv 0]] } {
+
+puts {# DO NOT EDIT
+#
+# This file is automatically generated. Instead of editing this file, edit
+# "makemake.tcl" then run "tclsh src/makemake.tcl mingw > win/Makefile.MinGW"
+# to regenerate this file.
+#
+
+#### Make a binary with all libraries statically linked.
+#
+FOSSIL_BUILD_STATIC = 1
+
+#### Enable HTTPS support via OpenSSL.
+#
+# FOSSIL_ENABLE_SSL = 1
+
+#### The toplevel directory of the source tree.  Fossil can be built
+#    in a directory that is separate from the source tree.  Just change
+#    the following to point from the build directory to the src/ folder.
+#
+SRCDIR = $(dir $(lastword $(MAKEFILE_LIST)))/../src
+
+#### A subdirectory in the build directory which receives the object
+#    files generated during the build.
+#
+OBJDIR = ./obj
+
+#### The suffix to add to executable files. ".exe" for windows.
+#    Nothing for unix.
+#
+E = .exe
+
+#### C Compiler and options for use in building executables that
+#    will run on the platform that is doing the build.  This is used
+#    to compile code-generator programs as part of the build process.
+#    See TCC below for the C compiler for building the finished binary.
+#
+BCC = gcc -g -O2
+
+#### C Compiler and options for use in building executables that 
+#    will run on the target platform.  This is usually the same
+#    as BCC, unless you are cross-compiling.  This C compiler builds
+#    the finished binary for fossil.  The BCC compiler above is used
+#    for building intermediate code-generator tools.
+#
+TCC = gcc -Os -Wall -DFOSSIL_I18N=0
+
+# With HTTPS support
+ifdef FOSSIL_ENABLE_SSL
+TCC += -DFOSSIL_ENABLE_SSL=1
+endif
+
+#### Extra arguments for linking the finished binary.  Fossil needs
+#    to link against the Z-Lib compression library and to the OpenSSL crypto
+#    libraries when FOSSIL_ENABLE_SSL is defined. There are no other
+#    dependencies.
+#
+ifdef FOSSIL_BUILD_STATIC
+  LIB += -static
+  SSLLIBS = -lssl -lcrypto -lgdi32
+else
+  SSLLIBS = -lssl -lcrypto   # OpenSSL Versions >= 1.0.0
+# SSLLIBS = -lssl32 -leay32  # OpenSSL Versions <  1.0.0
+endif
+#
+# OpenSSL:
+ifdef FOSSIL_ENABLE_SSL
+  LIB += $(SSLLIBS)
+endif
+#
+# Normal required libraries:
+LIB += -lz -lws2_32
+
+#### Tcl shell for use in running the fossil testsuite.
+#
+TCLSH = tclsh
+
+#-------------------------------------------------------------------------------
+#           D O   N O T   C H A N G E   A N Y T H I N G   B E L O W
+#-------------------------------------------------------------------------------
+
+XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR)
+}
+puts -nonewline "SRC ="
+foreach s [lsort $src] {
+  puts -nonewline " \\\n  \$(SRCDIR)/$s.c"
+}
+puts "\n"
+puts -nonewline "TRANS_SRC ="
+foreach s [lsort $src] {
+  puts -nonewline " \\\n  \$(OBJDIR)/${s}_.c"
+}
+puts "\n"
+puts -nonewline "OBJ ="
+foreach s [lsort $src] {
+  puts -nonewline " \\\n  \$(OBJDIR)/$s.o"
+}
+puts "\n"
+puts "APPNAME     = $name\$(E)"
+puts "TRANSLATE   = \$(subst /,\\,\$(OBJDIR)/translate\$(E))"
+puts "MAKEHEADERS = \$(subst /,\\,\$(OBJDIR)/makeheaders\$(E))"
+puts "MKINDEX     = \$(subst /,\\,\$(OBJDIR)/mkindex\$(E))"
+puts "VERSION     = \$(subst /,\\,\$(OBJDIR)/version\$(E))"
+
+puts {#
+# Build rules.
+#
+all: $(OBJDIR) $(APPNAME)
+
+install: all
+	strip $(APPNAME)
+	copy $(APPNAME) $(INSTALLPATH)
+
+$(OBJDIR):
+	mkdir $(subst /,\,$(OBJDIR))
+
+$(TRANSLATE): $(SRCDIR)/translate.c
+	$(BCC) -o $@ $<
+
+$(MAKEHEADERS): $(SRCDIR)/makeheaders.c
+	$(BCC) -o $@ $<
+
+$(MKINDEX): $(SRCDIR)/mkindex.c
+	$(BCC) -o $@ $<
+
+$(VERSION): $(SRCDIR)/../win/version.c
+	$(BCC) -o $@ $<
+
+# WARNING. DANGER. Running the testsuite modifies the repository the
+# build is done from, i.e. the checkout belongs to. Do not sync/push
+# the repository after running the tests.
+test: $(APPNAME)
+	$(TCLSH) test/tester.tcl $(APPNAME)
+
+$(OBJDIR)/VERSION.h: $(VERSION) $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest
+	$^ > $@
+
+EXTRAOBJ =\
+  $(OBJDIR)/sqlite3.o \
+  $(OBJDIR)/shell.o \
+  $(OBJDIR)/th.o \
+  $(OBJDIR)/th_lang.o
+
+RESOURCE = $(OBJDIR)/fossil.coff
+
+$(APPNAME): $(OBJDIR)/headers $(OBJ) $(EXTRAOBJ) $(RESOURCE)
+	$(TCC) -o $(APPNAME) $(OBJ) $(EXTRAOBJ) $(RESOURCE) $(LIB)
+
+# This rule prevents make from using its default rules to try build
+# an executable named "manifest" out of the file named "manifest.c"
+#
+$(SRCDIR)/../manifest:
+	# noop
+
+clean:
+	-rmdir /S /Q $(subst /,\,$(OBJDIR))
+
+realclean: clean
+	-del $(APPNAME)
+}
+
+set mhargs {}
+foreach s [lsort $src] {
+  append mhargs " \$(OBJDIR)/${s}_.c:\$(OBJDIR)/$s.h"
+  set extra_h($s) {}
+}
+append mhargs " \$(SRCDIR)/sqlite3.h"
+append mhargs " \$(SRCDIR)/th.h"
+append mhargs " \$(OBJDIR)/VERSION.h"
+puts "\$(OBJDIR)/page_index.h: \$(TRANS_SRC) \$(MKINDEX)"
+puts "\t\$(MKINDEX) \$(TRANS_SRC) >$@"
+puts ""
+puts "\$(OBJDIR)/headers: \$(OBJDIR)/page_index.h \$(MAKEHEADERS) \$(OBJDIR)/VERSION.h"
+puts "\t\$(MAKEHEADERS) $mhargs"
+puts "\tcopy /Y nul: \$(subst /,\\,\$(OBJDIR)/headers >nul)"
+#puts ""
+#puts "headers: Makefile"
+#puts "Makefile:"
+set extra_h(main) \$(OBJDIR)/page_index.h
+puts ""
+foreach s [lsort $src] {
+  puts "\$(OBJDIR)/${s}_.c:\t\$(SRCDIR)/$s.c \$(TRANSLATE)"
+  puts "\t\$(TRANSLATE) \$(SRCDIR)/$s.c >\$(OBJDIR)/${s}_.c"
+  puts "\$(OBJDIR)/$s.o: \$(OBJDIR)/${s}_.c \$(OBJDIR)/$s.h $extra_h($s) \$(SRCDIR)/config.h"
+  puts "\t\$(XTCC) -o \$(OBJDIR)/$s.o -c \$(OBJDIR)/${s}_.c"
+  puts "$s.h: \$(OBJDIR)/headers\n"
+}
+
+puts "\$(OBJDIR)/sqlite3.o: \$(SRCDIR)/sqlite3.c"
+set opt {-DSQLITE_OMIT_LOAD_EXTENSION=1}
+append opt " -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4"
+append opt " -Dlocaltime=fossil_localtime"
+append opt " -DSQLITE_ENABLE_LOCKING_STYLE=0"
+puts "\t\$(XTCC) $opt -c \$(SRCDIR)/sqlite3.c -o \$(OBJDIR)/sqlite3.o\n"
+
+puts "\$(OBJDIR)/shell.o: \$(SRCDIR)/shell.c"
+set opt {-Dmain=sqlite3_shell}
+append opt " -DSQLITE_OMIT_LOAD_EXTENSION=1"
+puts "\t\$(XTCC) $opt -c \$(SRCDIR)/shell.c -o \$(OBJDIR)/shell.o\n"
+
+puts "\$(OBJDIR)/th.o: \$(SRCDIR)/th.c"
+puts "\t\$(XTCC) -I\$(SRCDIR) -c \$(SRCDIR)/th.c -o \$(OBJDIR)/th.o\n"
+
+puts "\$(OBJDIR)/th_lang.o: \$(SRCDIR)/th_lang.c"
+puts "\t\$(XTCC) -I\$(SRCDIR) -c \$(SRCDIR)/th_lang.c -o \$(OBJDIR)/th_lang.o\n"
+
+puts "\$(OBJDIR)/fossil.coff: \$(SRCDIR)/../win/fossil.rc"
+puts "\twindres -I\$(OBJDIR) -I\$(SRCDIR) \$< \$@"
+exit
 }

