--- old-chicken/README	Mon Dec 19 10:02:17 2005
+++ new-chicken/README	Mon Dec 19 10:02:17 2005
@@ -291,22 +291,48 @@
 	  C:/chicken-1.66 ... spaces in the path to the existing
 	  CHICKEN installation will cause problems)
 
-	  Sergey Khorev reported how to build Chicken under MinGW with support for shared libraries
-	  with some hacking involved:
+	  Sergey Khorev reported how to build Chicken under MinGW with support 
+		for shared libraries with some hacking involved:
+
+	  1) Install MinGW and MSYS
+	  2) Don't use rxvt (default MSYS shortcut), better run MSYS's shell using command
+		sh --login -i
+	  3) ./configure
+          4) edit Makefile to set BOOTSTRAP_PATH if required
+	  5) patch libtool with
+		sed -e 's/\(deplibs_check_method=\).*/\1"pass_all"/' libtool > libtool.new
+		cp libtool.new libtool
+	  (it seems that libtool tries to be too smart, giving stupid results).
+	  6) mkdir $MINGWDIR/lib/.libs;
+	     cp $MINGWDIR/lib/libws2_32.a $MINGWDIR/lib/.libs/libws2_32.dll.a
+	     where MINGWDIR is the where MinGW is installed
+	  7) make, make install, enjoy
+
+
+	    You might want to use C regular expressions package instead of the 
+	    default one, written in Scheme. 
+	    In this case you should download latest packages from 
+	    http://gnuwin32.sf.net 
+	    (either pcre-*-bin.zip, pcre-*-dep.zip, pcre-*-lib.zip
+		or regex-spencer-*-bin.zip and regex-spencer-*-lib.zip).
+	    Unpack downloaded zip files into one directory.
+	    Steps 1) and 2) as above.
+	    3a)
+	    For simplicity create environment variable with its path, e.g.
+		export RE_DIR=c:/Devel/pcre
+	    Then copy import libraries:
+		cd RE_DIR/lib
+		mkdir .libs
+	    If you use PCRE, issue
+		cp libpcre.dll.a .libs
+	    else
+		cp libregex.dll.a .libs
+	    Put libpcre0.dll or regex.dll somewhere to PATH 
+				    (e.g. WINDOWS\System32)
+	    3b)
+		CFLAGS=-I$RE_DIR/include CPPFLAGS=-I$RE_DIR/include LDFLAGS=-L$RE_DIR/lib ./configure
+	    Other steps like in normal MinGW build
 
-          1) Install MinGW and MSYS
-          2) Don't use rxvt (default MSYS shortcut), better run MSYS's shell using command
-               sh --login -i
-          3) ./configure
-          4) edit Makefile to set BOOTSTRAP_PATH
-          5) patch libtool with
-               sed -e 's/\(deplibs_check_method=\).*/\1"pass_all"/' libtool > libtool.new
-               cp libtool.new libtool
-             (it seems that libtool tries to be too smart, giving stupid results).
-          6) mkdir $MINGWDIR/lib/.libs;
-             cp $MINGWDIR/lib/libws2_32.a $MINGWDIR/lib/.libs/libws2_32.dll.a
-             where MINGWDIR is the where MinGW is installed
-          7) make, make install, enjoy
 
 	  CMake also supports MinGW, so you might try that instead.
 

--- old-chicken/Makefile.am	Mon Dec 19 10:02:17 2005
+++ new-chicken/Makefile.am	Mon Dec 19 10:02:17 2005
@@ -223,22 +223,28 @@
 lib_LTLIBRARIES = libchicken.la libuchicken.la
 
 if IS_MINGW
-chickenlibsources = extras.c match-support.c lolevel.c tinyclos.c utils.c tcp.c pregexp.c posixwin.c stub.c
-chickenulibsources = uextras.c umatch-support.c ulolevel.c utinyclos.c uutils.c utcp.c upregexp.c uposixwin.c stub.c
+POSIX_C = posixwin.c
+UPOSIX_C = uposixwin.c
 else
+POSIX_C = posix.c
+UPOSIX_C = uposix.c
+endif
+
 if USE_PCRE
-chickenlibsources = extras.c match-support.c lolevel.c tinyclos.c utils.c tcp.c pcre.c posix.c stub.c
-chickenulibsources = uextras.c umatch-support.c ulolevel.c utinyclos.c uutils.c utcp.c upcre.c uposix.c stub.c
+REGEX_C = pcre.c
+UREGEX_C = upcre.c
 else
 if USE_PREGEX
-chickenlibsources = extras.c match-support.c lolevel.c tinyclos.c utils.c tcp.c pregexp.c posix.c stub.c
-chickenulibsources = uextras.c umatch-support.c ulolevel.c utinyclos.c uutils.c utcp.c upregexp.c uposix.c stub.c
+REGEX_C = pregexp.c
+UREGEX_C = upregexp.c
 else
-chickenlibsources = extras.c match-support.c lolevel.c tinyclos.c utils.c tcp.c regex.c posix.c stub.c
-chickenulibsources = uextras.c umatch-support.c ulolevel.c utinyclos.c uutils.c utcp.c uregex.c uposix.c stub.c
-endif
+REGEX_C = regex.c
+UREGEX_C = uregex.c
 endif
 endif
+
+chickenlibsources = extras.c match-support.c lolevel.c tinyclos.c utils.c tcp.c $(REGEX_C) $(POSIX_C) stub.c
+chickenulibsources = uextras.c umatch-support.c ulolevel.c utinyclos.c uutils.c utcp.c $(UREGEX_C) $(UPOSIX_C) stub.c
 
 libchicken_la_SOURCES = runtime.c library.c eval.c profiler.c scheduler.c $(chickenlibsources) \
   srfi-1.c srfi-4.c srfi-13.c srfi-14.c srfi-18.c

--- old-chicken/configure.in	Mon Dec 19 10:02:17 2005
+++ new-chicken/configure.in	Mon Dec 19 10:02:17 2005
@@ -132,24 +132,44 @@
 
 AC_CHECK_LIB(pcre, pcre_compile, [PCREFUNCS=1],[AC_MSG_RESULT([no PCRE regex package available])])
 AC_CHECK_FUNC(regcomp, [REGEXFUNCS=1],[AC_MSG_RESULT([no POSIX regex package available])])
+AC_CHECK_LIB(regex, regcomp, [REGEXLIB=1],[AC_MSG_RESULT([no separate POSIX regex library available])])
 
 if test -n "${PREGEXP}"; then
   REGEXHEADER=
   PCREHEADER=  
 fi
 
-AM_CONDITIONAL(USE_PCRE, [test -n "${PCREHEADER}" -a -n "${PCREFUNCS}"])
-AM_CONDITIONAL(USE_PREGEX, [test -z "${REGEXHEADER}" -o -z "${REGEXFUNCS}"])
+if test -n "${REGEXLIB}"; then
+  REGEXFUNCS=1
+fi
+
+if test -n "${PCREHEADER}" -a -n "${PCREFUNCS}"; then
+  PCREUSABLE=1
+fi
+
+if test -n "${REGEXHEADER}" -a -n "${REGEXFUNCS}"; then
+  REGEXUSABLE=1
+fi
+
+if test -n "${PCREUSABLE}" -o -n "${REGEXUSABLE}"; then
+  ANYREUSABLE=1
+fi
+
+AM_CONDITIONAL(USE_PCRE, [test -n "${PCREUSABLE}" -a -z "${PREGEXP}"])
+AM_CONDITIONAL(USE_PREGEX, [test -n "${PREGEXP}" -o -z "${ANYREUSABLE}"])
 AC_SUBST(SHLIBS)
 AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"; SHLIBS="$SHLIBS -ldl"])
 
-if test -n "${PREGEXP}"; then
+if test -n "${PREGEXP}" -o -z "${ANYREUSABLE}"; then
   AC_MSG_RESULT([using pregexp])
-elif test -n "${PCREHEADER}" -a -n "${PCREFUNCS}"; then
+elif test -n "${PCREUSABLE}"; then
   LIBS="$LIBS -lpcre"; SHLIBS="$SHLIBS -lpcre"
   AC_MSG_RESULT([using PCRE])
 else
-  AC_MSG_RESULT([using libc regex])
+  if test -n "${REGEXLIB}"; then
+    LIBS="$LIBS -lregex"; SHLIBS="$SHLIBS -lregex"
+  fi
+  AC_MSG_RESULT([using regex])
 fi
 
 AC_CHECK_LIB(ffi, ffi_prep_cif, [LIBS="$LIBS -lffi"; SHLIBS="$SHLIBS -lffi"])

