From 94e72b16e7d15a2943d9420e86765d6dca71a2f2 Mon Sep 17 00:00:00 2001
From: Henry Kroll III <henry@comptune.com>
Date: Thu, 2 Dec 2010 20:16:32 -0800
Subject: [PATCH] Add --enable-cygwin option to build on windows with
 cygwin+mingw32

---
 configure | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index f42ec8d3..f38628fe 100755
--- a/configure
+++ b/configure
@@ -36,6 +36,7 @@ cc="gcc"
 host_cc="gcc"
 ar="ar"
 strip="strip"
+cygwin="no"
 cpu=`uname -m`
 case "$cpu" in
   i386|i486|i586|i686|i86pc|BePC|i686-AT386)
@@ -133,6 +134,8 @@ for opt do
   ;;
   --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86
   ;;
+  --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86
+  ;;
   --enable-cross) build_cross="yes"
   ;;
   --disable-static) disable_static="yes"
@@ -243,7 +246,8 @@ echo "  --sysroot=PREFIX         prepend PREFIX to library/include paths []"
 echo "  --cc=CC                  use C compiler CC [$cc]"
 echo "  --disable-static         make libtcc.so instead of libtcc.a"
 echo "  --with-libgcc            use /lib/libgcc_s.so.1 instead of libtcc.a"
-echo "  --enable-mingw32         build windows version with mingw32"
+echo "  --enable-cygwin          build windows version on windows with mingw32"
+echo "  --enable-mingw32         build windows version on linux with mingw32"
 echo "  --extra-cflags=          extra compiler flags"
 echo "  --extra-ldflags=         extra linker options"
 echo "  --with-selinux           use mmap instead of exec mem"
@@ -367,6 +371,12 @@ if test "$mingw32" = "yes" ; then
   echo "CONFIG_WIN32=yes" >> config.mak
   echo "#define CONFIG_WIN32 1" >> $TMPH
 fi
+if test "$cygwin" = "yes" ; then
+  echo "#ifndef _WIN32" >> $TMPH
+  echo "#define _WIN32" >> $TMPH
+  echo "#endif" >> $TMPH
+  echo "AR=ar" >> config.mak
+fi
 if test "$bigendian" = "yes" ; then
   echo "WORDS_BIGENDIAN=yes" >> config.mak
   echo "#define WORDS_BIGENDIAN 1" >> $TMPH