--- flip.c~0	2001-07-15 22:37:13.000000000 +0300
+++ flip.c	2007-09-21 22:49:33.343750000 +0300
@@ -235,7 +235,7 @@ enum choices which;
    SGFTIME timestamp;  /* save file timestamp here, restore later */
    int errstat = 0;
    char *p;             /* temp file ptr */
-#ifdef IX
+#if defined(IX) || defined(__MINGW32__)
    struct stat ifilestat;
 #endif
 
@@ -251,7 +251,7 @@ enum choices which;
       if ((infile = fopen (fname, R_PL_B)) != NULL) {
          fclose (infile);
          infile = fopen (fname, RB);
-#ifdef IX
+#if defined(IX) || defined(__MINGW32__)
 	 if (stat (fname, &ifilestat)) {
 	   /* can't get the file's permissions */
 	   char *buf = malloc(strlen(fname)+strlen(myname)+3);
@@ -367,7 +367,7 @@ enum choices which;
                SETFT (fptr, fname, timestamp);
                fclose (fptr);
             }
-#ifdef IX
+#if defined(IX) || defined(__MINGW32__)
 	    if (chmod(fname, ifilestat.st_mode)) {
 	      /* can't set the file's permissions */
 	      char *buf = malloc(strlen(fname)+strlen(myname)+3);
--- flip.h~0	1995-04-27 00:51:17.000000000 +0300
+++ flip.h	2007-09-21 23:00:26.437500000 +0300
@@ -24,6 +24,11 @@ ANSI-compatibility strategy:
 # define    STDINCLUDE
 #endif /* TURBOC */
 
+#ifdef __MINGW32__
+# define    ANSIPROTO
+# define    STDINCLUDE
+#endif /* __MINGW32__ */
+
 
 
 #include <stdio.h>
@@ -152,6 +157,32 @@ void spec_exit PARMS ((void));
 # define SPEC_EXIT
 #endif /* VMS */
 
+#ifdef __MINGW32__
+# define PATHSIZE    261
+# define BIGBUF      16384
+# define DELFILE     remove
+# define MVFILE      rename
+# define SIG_T int
+# define SPEC_INIT
+# define SPEC_EXIT
+# define CHECK_BREAK
+# define PICKNAME
+# define USE_SIG
+# define INT_EXIT    127
+# include <io.h>
+# include <sys/types.h>          /* for file time */
+# include <sys/stat.h>           /* for file time */
+  typedef struct stat            SGFTIME;
+# define GETFT(file,name,var)    fstat(fileno(file),&var)
+# include <sys/utime.h>
+# define SETFT(file,name,var)    do { struct utimbuf x;			\
+                                      x.actime = var.st_atime;		\
+                                      x.modtime = var.st_mtime;		\
+				      utime (name, &x);			\
+                                  } while (0)
+# define BINCHAR(c)  (c) == 0
+#endif
+
 /************************************************************/
 /*** remaining definitions should not need to be changed ****/
 /************************************************************/
--- Makefile.~0	2001-07-14 07:49:52.000000000 +0300
+++ Makefile	2007-09-21 22:52:32.796875000 +0300
@@ -17,6 +17,9 @@ DISTFILES=CHECKSUM.S FILES FLIP.MAN FLIP
 
 #   "make sys_v"        makes executable flip for System V Release 2
 #   "make bsd"          makes executable flip for 4.3BSD
+#   "make uport"        makes executable flip for Uport
+#   "make ultrix"       makes executable flip for Ultrix
+#   "make mingw"        makes executable flip for MS-Windows using MinGW
 #   "make install"      moves flip into BINDIR, copies flip.1 into MANDIR
 #   "make clean"        deletes object and executable files
 
@@ -34,6 +37,7 @@ CFLAGS =
 CFMORE = -c -DNDEBUG -O -DVERSION=\"$(VERSION)\"
 LD = cc
 LDFLAGS = -o flip
+EXEEXT =
 
 # If your system does not supply getopt as a library function,
 # add getopt.o to the RHS list on the next line and uncomment the
@@ -45,7 +49,7 @@ OBJS = flip.o
 
 nothing:
 	@echo \
-	'Please type "make sys_v", "make bsd", "make uport", or "make ultrix"'
+	'Please type "make sys_v", "make bsd", "make uport", "make mingw", or "make ultrix"'
 
 sys_v:
 	make "CFLAGS=-DSYS_V -DIX" flip
@@ -59,14 +63,17 @@ bsd:
 ultrix:
 	make "CFLAGS=-DBSD -DULTRIX_BUG" flip
 
-flip: $(OBJS)
+mingw:
+	make CC=gcc "CFLAGS=-Wall -O2 -gdwarf-2 -g3" LD=gcc EXEEXT=.exe "LDFLAGS=-gdwarf-2 -g3 -o flip.exe" flip.exe
+
+flip$(EXEEXT): $(OBJS)
 	$(LD) $(LDFLAGS) $(OBJS)
 
 flip.o: flip.c flip.h
 	$(CC) $(CFLAGS) $(CFMORE) $*.c
 
 clean:
-	rm -f *.o core flip
+	rm -f *.o core flip$(EXEEXT)
 
 install:
 	mv flip $(BINDIR)
