Added support for regex study and PCRE JIT (ticket #41) optimizations on
configuration phase.
diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf
index 3008f58..e90d023 100644
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -4,8 +4,6 @@
 
 if [ $PCRE != NONE ]; then
     CORE_INCS="$CORE_INCS $PCRE"
-    CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
-    CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
 
     case "$NGX_CC_NAME" in
 
@@ -81,6 +79,12 @@
 
     esac
 
+
+    if [ $PCRE_JIT = YES ]; then
+        have=NGX_HAVE_PCRE_JIT . auto/have
+        PCRE_CONF_OPT="$PCRE_CONF_OPT --enable-jit"
+    fi
+
 else
 
     if [ "$NGX_PLATFORM" != win32 ]; then
@@ -156,12 +160,23 @@
         fi
 
         if [ $ngx_found = yes ]; then
-            CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
-            CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
             CORE_INCS="$CORE_INCS $ngx_feature_path"
             CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
             PCRE=YES
         fi
+
+        if [ $PCRE == YES ]; then
+            ngx_feature="PCRE JIT support"
+            ngx_feature_name="NGX_HAVE_PCRE_JIT"
+            ngx_feature_test="int jit = 0;
+                              pcre_config(PCRE_CONFIG_JIT, &jit);
+                              if (jit != 1) return 1;"
+            . auto/feature
+
+            if [ $ngx_found = yes ]; then
+                PCRE_JIT=YES
+            fi
+        fi
     fi
 
     if [ $PCRE != YES ]; then
diff --git a/auto/lib/pcre/make b/auto/lib/pcre/make
index 9f2c658..a9be75e 100644
--- a/auto/lib/pcre/make
+++ b/auto/lib/pcre/make
@@ -50,7 +50,7 @@
 	cd $PCRE \\
 	&& if [ -f Makefile ]; then \$(MAKE) distclean; fi \\
 	&& CC="\$(CC)" CFLAGS="$PCRE_OPT" \\
-	./configure --disable-shared
+	./configure --disable-shared $PCRE_CONF_OPT
 
 $PCRE/.libs/libpcre.a:	$PCRE/Makefile
 	cd $PCRE \\
diff --git a/auto/modules b/auto/modules
index a8607ee..93e0de9 100644
--- a/auto/modules
+++ b/auto/modules
@@ -396,6 +396,12 @@
     CORE_SRCS="$CORE_SRCS $OPENSSL_SRCS"
 fi
 
+if [ $USE_PCRE = YES ]; then
+    modules="$modules $REGEX_MODULE"
+    CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
+    CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
+fi
+
 if [ $HTTP = YES ]; then
     modules="$modules $HTTP_MODULES $HTTP_FILTER_MODULES \
              $HTTP_HEADERS_FILTER_MODULE \
diff --git a/auto/options b/auto/options
index e8de4ff..2b04023 100644
--- a/auto/options
+++ b/auto/options
@@ -111,6 +111,8 @@
 USE_PCRE=NO
 PCRE=NONE
 PCRE_OPT=
+PCRE_CONF_OPT=
+PCRE_JIT=NO
 
 USE_OPENSSL=NO
 OPENSSL=NONE
@@ -274,6 +276,7 @@
         --with-pcre)                     USE_PCRE=YES               ;;
         --with-pcre=*)                   PCRE="$value"              ;;
         --with-pcre-opt=*)               PCRE_OPT="$value"          ;;
+        --with-pcre-jit)                 PCRE_JIT=YES               ;;
 
         --with-openssl=*)                OPENSSL="$value"           ;;
         --with-openssl-opt=*)            OPENSSL_OPT="$value"       ;;
@@ -421,6 +424,7 @@
   --with-pcre                        force PCRE library usage
   --with-pcre=DIR                    set path to PCRE library sources
   --with-pcre-opt=OPTIONS            set additional build options for PCRE
+  --with-pcre-jit                    build PCRE with JIT compilation support
 
   --with-md5=DIR                     set path to md5 library sources
   --with-md5-opt=OPTIONS             set additional build options for md5
diff --git a/auto/sources b/auto/sources
index 24fa3b8..38b3f40 100644
--- a/auto/sources
+++ b/auto/sources
@@ -69,6 +69,7 @@
            src/core/ngx_crypt.c"
 
 
+REGEX_MODULE=ngx_regex_module
 REGEX_DEPS=src/core/ngx_regex.h
 REGEX_SRCS=src/core/ngx_regex.c