Configure: allow to be run from outside of the source directory.

Note that when run from outside of the source directory, this script
won't generate Makefiles, since there are too many cases to support.

Change-Id: I5db7bde4998134bb98ff027201f45209ff8a2896
Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Reviewed-on: https://nginx-review.googlesource.com/1010
Reviewed-by: Martin Maly <mmaly@google.com>
diff --git a/auto/cc/clang b/auto/cc/clang
index 2b8d346..4395d87 100644
--- a/auto/cc/clang
+++ b/auto/cc/clang
@@ -10,7 +10,7 @@
 
 echo " + clang version: $NGX_CLANG_VER"
 
-have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . auto/define
+have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . $NGX_AUTO/define
 
 
 CC_TEST_FLAGS="$CC_TEST_FLAGS -pipe"
diff --git a/auto/cc/conf b/auto/cc/conf
index 58f54d4..0f9f5ec 100644
--- a/auto/cc/conf
+++ b/auto/cc/conf
@@ -31,7 +31,7 @@
 
 CC_TEST_FLAGS="$CFLAGS $NGX_CC_OPT"
 
-. auto/cc/name
+. $NGX_AUTO/cc/name
 
 if test -n "$CFLAGS"; then
 
@@ -76,55 +76,55 @@
             #     3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4.0, 3.4.2
             #     4.0.0, 4.0.1, 4.1.0
 
-            . auto/cc/gcc
+            . $NGX_AUTO/cc/gcc
         ;;
 
         clang)
             # Clang C compiler
 
-            . auto/cc/clang
+            . $NGX_AUTO/cc/clang
         ;;
 
         icc)
             # Intel C++ compiler 7.1, 8.0, 8.1
 
-            . auto/cc/icc
+            . $NGX_AUTO/cc/icc
         ;;
 
         sunc)
             # Sun C 5.7 Patch 117837-04 2005/05/11
 
-            . auto/cc/sunc
+            . $NGX_AUTO/cc/sunc
         ;;
 
         ccc)
             # Compaq C V6.5-207
 
-            . auto/cc/ccc
+            . $NGX_AUTO/cc/ccc
         ;;
 
         acc)
             # aCC: HP ANSI C++ B3910B A.03.55.02
 
-            . auto/cc/acc
+            . $NGX_AUTO/cc/acc
         ;;
 
         msvc*)
             # MSVC++ 6.0 SP2, MSVC++ Toolkit 2003
 
-            . auto/cc/msvc
+            . $NGX_AUTO/cc/msvc
         ;;
 
         owc)
             # Open Watcom C 1.0, 1.2
 
-            . auto/cc/owc
+            . $NGX_AUTO/cc/owc
         ;;
 
         bcc)
             # Borland C++ 5.5
 
-            . auto/cc/bcc
+            . $NGX_AUTO/cc/bcc
         ;;
 
     esac
@@ -144,7 +144,7 @@
         ngx_feature_path=
         ngx_feature_libs=
         ngx_feature_test=
-        . auto/feature
+        . $NGX_AUTO/feature
 
         if [ $ngx_found = no ]; then
             echo $0: error: the invalid value in --with-ld-opt=\"$NGX_LD_OPT\"
@@ -168,7 +168,7 @@
                       if (n != 2)
                           return 1;
                       __sync_synchronize();"
-    . auto/feature
+    . $NGX_AUTO/feature
 
 
     if [ "$NGX_CC_NAME" = "ccc" ]; then
@@ -184,7 +184,7 @@
         ngx_feature_test="char  buf[30]; buf[0] = '0';
                           var(0, buf, \"%d\", 1);
                           if (buf[0] != '1') return 1"
-        . auto/feature
+        . $NGX_AUTO/feature
      fi
 
 
@@ -198,7 +198,7 @@
     ngx_feature_test="char  buf[30]; buf[0] = '0';
                       var(0, buf, \"%d\", 1);
                       if (buf[0] != '1') return 1"
-    . auto/feature
+    . $NGX_AUTO/feature
 
 
 #    ngx_feature="inline"
@@ -208,7 +208,7 @@
 #    ngx_feature_path=
 #    ngx_feature_libs=
 #    ngx_feature_test=
-#    . auto/feature
+#    . $NGX_AUTO/feature
 #
 #    if [ $ngx_found = yes ]; then
 #    fi
diff --git a/auto/cc/gcc b/auto/cc/gcc
index 63df2f8..caa6302 100644
--- a/auto/cc/gcc
+++ b/auto/cc/gcc
@@ -13,7 +13,7 @@
 
 echo " + gcc version: $NGX_GCC_VER"
 
-have=NGX_COMPILER value="\"gcc $NGX_GCC_VER\"" . auto/define
+have=NGX_COMPILER value="\"gcc $NGX_GCC_VER\"" . $NGX_AUTO/define
 
 
 # Solaris 7's /usr/ccs/bin/as does not support "-pipe"
@@ -27,7 +27,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test=
-. auto/feature
+. $NGX_AUTO/feature
 
 if [ $ngx_found = yes ]; then
     PIPE="-pipe"
diff --git a/auto/cc/icc b/auto/cc/icc
index 1d83ed3..72db88c 100644
--- a/auto/cc/icc
+++ b/auto/cc/icc
@@ -10,7 +10,7 @@
 
 echo " + icc version: $NGX_ICC_VER"
 
-have=NGX_COMPILER value="\"Intel C Compiler $NGX_ICC_VER\"" . auto/define
+have=NGX_COMPILER value="\"Intel C Compiler $NGX_ICC_VER\"" . $NGX_AUTO/define
 
 
 # optimizations
diff --git a/auto/cc/msvc b/auto/cc/msvc
index 393ba32..7415a41 100644
--- a/auto/cc/msvc
+++ b/auto/cc/msvc
@@ -100,7 +100,7 @@
 
 # MSVC 2005 supports C99 variadic macros
 if [ $NGX_CC_NAME = msvc8 ]; then
-   have=NGX_HAVE_C99_VARIADIC_MACROS . auto/have
+   have=NGX_HAVE_C99_VARIADIC_MACROS . $NGX_AUTO/have
 fi
 
 
diff --git a/auto/cc/name b/auto/cc/name
index 51a7ed9..1264b82 100644
--- a/auto/cc/name
+++ b/auto/cc/name
@@ -12,7 +12,7 @@
     ngx_feature_path=
     ngx_feature_libs=
     ngx_feature_test=
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = no ]; then
         echo
diff --git a/auto/cc/owc b/auto/cc/owc
index a063aa3..ebb877d 100644
--- a/auto/cc/owc
+++ b/auto/cc/owc
@@ -61,7 +61,7 @@
 CFLAGS="$CFLAGS -zq"
 
 # Open Watcom C 1.2
-have=NGX_HAVE_C99_VARIADIC_MACROS . auto/have
+have=NGX_HAVE_C99_VARIADIC_MACROS . $NGX_AUTO/have
 
 
 # the precompiled headers
diff --git a/auto/cc/sunc b/auto/cc/sunc
index 8f12d7c..967f66f 100644
--- a/auto/cc/sunc
+++ b/auto/cc/sunc
@@ -15,7 +15,7 @@
 
 echo " + Sun C version: $NGX_SUNC_VER"
 
-have=NGX_COMPILER value="\"Sun C $NGX_SUNC_VER\"" . auto/define
+have=NGX_COMPILER value="\"Sun C $NGX_SUNC_VER\"" . $NGX_AUTO/define
 
 
 cat << END > $NGX_AUTOTEST.c
diff --git a/auto/configure b/auto/configure
index ceff15e..7625305 100755
--- a/auto/configure
+++ b/auto/configure
@@ -7,9 +7,12 @@
 LC_ALL=C
 export LC_ALL
 
-. auto/options
-. auto/init
-. auto/sources
+NGX_ROOT=`dirname $0 | sed -e "s/auto$//" -e "s/\/$//" -e "s/^$/\./"`
+NGX_AUTO=$NGX_ROOT/auto
+
+. $NGX_AUTO/options
+. $NGX_AUTO/init
+. $NGX_AUTO/sources
 
 test -d $NGX_OBJS || mkdir -p $NGX_OBJS
 
@@ -20,7 +23,7 @@
 
 
 if [ $NGX_DEBUG = YES ]; then
-    have=NGX_DEBUG . auto/have
+    have=NGX_DEBUG . $NGX_AUTO/have
 fi
 
 
@@ -46,26 +49,26 @@
     NGX_SYSTEM=$NGX_PLATFORM
 fi
 
-. auto/cc/conf
+. $NGX_AUTO/cc/conf
 
 if [ "$NGX_PLATFORM" != win32 ]; then
-    . auto/headers
+    . $NGX_AUTO/headers
 fi
 
-. auto/os/conf
+. $NGX_AUTO/os/conf
 
 if [ "$NGX_PLATFORM" != win32 ]; then
-    . auto/unix
+    . $NGX_AUTO/unix
 fi
 
-. auto/threads
-. auto/modules
-. auto/lib/conf
+. $NGX_AUTO/threads
+. $NGX_AUTO/modules
+. $NGX_AUTO/lib/conf
 
 case ".$NGX_PREFIX" in
     .)
         NGX_PREFIX=${NGX_PREFIX:-/usr/local/nginx}
-        have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
+        have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . $NGX_AUTO/define
     ;;
 
     .!)
@@ -73,44 +76,46 @@
     ;;
 
     *)
-        have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
+        have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . $NGX_AUTO/define
     ;;
 esac
 
 if [ ".$NGX_CONF_PREFIX" != "." ]; then
-    have=NGX_CONF_PREFIX value="\"$NGX_CONF_PREFIX/\"" . auto/define
+    have=NGX_CONF_PREFIX value="\"$NGX_CONF_PREFIX/\"" . $NGX_AUTO/define
 fi
 
-have=NGX_SBIN_PATH value="\"$NGX_SBIN_PATH\"" . auto/define
-have=NGX_CONF_PATH value="\"$NGX_CONF_PATH\"" . auto/define
-have=NGX_PID_PATH value="\"$NGX_PID_PATH\"" . auto/define
-have=NGX_LOCK_PATH value="\"$NGX_LOCK_PATH\"" . auto/define
-have=NGX_ERROR_LOG_PATH value="\"$NGX_ERROR_LOG_PATH\"" . auto/define
+have=NGX_SBIN_PATH value="\"$NGX_SBIN_PATH\"" . $NGX_AUTO/define
+have=NGX_CONF_PATH value="\"$NGX_CONF_PATH\"" . $NGX_AUTO/define
+have=NGX_PID_PATH value="\"$NGX_PID_PATH\"" . $NGX_AUTO/define
+have=NGX_LOCK_PATH value="\"$NGX_LOCK_PATH\"" . $NGX_AUTO/define
+have=NGX_ERROR_LOG_PATH value="\"$NGX_ERROR_LOG_PATH\"" . $NGX_AUTO/define
 
-have=NGX_HTTP_LOG_PATH value="\"$NGX_HTTP_LOG_PATH\"" . auto/define
+have=NGX_HTTP_LOG_PATH value="\"$NGX_HTTP_LOG_PATH\"" . $NGX_AUTO/define
 have=NGX_HTTP_CLIENT_TEMP_PATH value="\"$NGX_HTTP_CLIENT_TEMP_PATH\""
-. auto/define
+. $NGX_AUTO/define
 have=NGX_HTTP_PROXY_TEMP_PATH value="\"$NGX_HTTP_PROXY_TEMP_PATH\""
-. auto/define
+. $NGX_AUTO/define
 have=NGX_HTTP_FASTCGI_TEMP_PATH value="\"$NGX_HTTP_FASTCGI_TEMP_PATH\""
-. auto/define
+. $NGX_AUTO/define
 have=NGX_HTTP_UWSGI_TEMP_PATH value="\"$NGX_HTTP_UWSGI_TEMP_PATH\""
-. auto/define
+. $NGX_AUTO/define
 have=NGX_HTTP_SCGI_TEMP_PATH value="\"$NGX_HTTP_SCGI_TEMP_PATH\""
-. auto/define
+. $NGX_AUTO/define
 
-. auto/make
-. auto/lib/make
-. auto/install
+if [ "$NGX_ROOT" = "." ]; then
+    . $NGX_AUTO/make
+    . $NGX_AUTO/lib/make
+    . $NGX_AUTO/install
+fi
 
 # STUB
-. auto/stubs
+. $NGX_AUTO/stubs
 
-have=NGX_USER value="\"$NGX_USER\"" . auto/define
-have=NGX_GROUP value="\"$NGX_GROUP\"" . auto/define
+have=NGX_USER value="\"$NGX_USER\"" . $NGX_AUTO/define
+have=NGX_GROUP value="\"$NGX_GROUP\"" . $NGX_AUTO/define
 
 if [ ".$NGX_BUILD" != "." ]; then
-    have=NGX_BUILD value="\"$NGX_BUILD\"" . auto/define
+    have=NGX_BUILD value="\"$NGX_BUILD\"" . $NGX_AUTO/define
 fi
 
-. auto/summary
+. $NGX_AUTO/summary
diff --git a/auto/endianness b/auto/endianness
index 70b0a10..f3c6efd 100644
--- a/auto/endianness
+++ b/auto/endianness
@@ -34,7 +34,7 @@
 if [ -x $NGX_AUTOTEST ]; then
     if $NGX_AUTOTEST >/dev/null 2>&1; then
         echo " little endian"
-        have=NGX_HAVE_LITTLE_ENDIAN . auto/have
+        have=NGX_HAVE_LITTLE_ENDIAN . $NGX_AUTO/have
     else
         echo " big endian"
     fi
diff --git a/auto/feature b/auto/feature
index 1145f28..54a3c45 100644
--- a/auto/feature
+++ b/auto/feature
@@ -58,7 +58,7 @@
                 ngx_found=yes
 
                 if test -n "$ngx_feature_name"; then
-                    have=$ngx_have_feature . auto/have
+                    have=$ngx_have_feature . $NGX_AUTO/have
                 fi
 
             else
@@ -94,7 +94,7 @@
                 ngx_found=yes
 
                 if test -n "$ngx_feature_name"; then
-                    have=$ngx_have_feature . auto/have
+                    have=$ngx_have_feature . $NGX_AUTO/have
                 fi
             fi
         ;;
@@ -104,7 +104,7 @@
             ngx_found=yes
 
             if test -n "$ngx_feature_name"; then
-                have=$ngx_have_feature . auto/have
+                have=$ngx_have_feature . $NGX_AUTO/have
             fi
         ;;
 
diff --git a/auto/headers b/auto/headers
index 5a2e6b9..6caee39 100644
--- a/auto/headers
+++ b/auto/headers
@@ -3,11 +3,11 @@
 # Copyright (C) Nginx, Inc.
 
 
-ngx_include="unistd.h";      . auto/include
-ngx_include="inttypes.h";    . auto/include
-ngx_include="limits.h";      . auto/include
-ngx_include="sys/filio.h";   . auto/include
-ngx_include="sys/param.h";   . auto/include
-ngx_include="sys/mount.h";   . auto/include
-ngx_include="sys/statvfs.h"; . auto/include
-ngx_include="crypt.h";       . auto/include
+ngx_include="unistd.h";      . $NGX_AUTO/include
+ngx_include="inttypes.h";    . $NGX_AUTO/include
+ngx_include="limits.h";      . $NGX_AUTO/include
+ngx_include="sys/filio.h";   . $NGX_AUTO/include
+ngx_include="sys/param.h";   . $NGX_AUTO/include
+ngx_include="sys/mount.h";   . $NGX_AUTO/include
+ngx_include="sys/statvfs.h"; . $NGX_AUTO/include
+ngx_include="crypt.h";       . $NGX_AUTO/include
diff --git a/auto/include b/auto/include
index 6a17191..ca85545 100644
--- a/auto/include
+++ b/auto/include
@@ -42,7 +42,7 @@
               | tr abcdefghijklmnopqrstuvwxyz/. ABCDEFGHIJKLMNOPQRSTUVWXYZ__`
 
 
-    have=NGX_HAVE_$ngx_name . auto/have_headers
+    have=NGX_HAVE_$ngx_name . $NGX_AUTO/have_headers
 
     eval "NGX_INCLUDE_$ngx_name='#include <$ngx_include>'"
 
diff --git a/auto/init b/auto/init
index 910f529..4e02ba6 100644
--- a/auto/init
+++ b/auto/init
@@ -42,10 +42,14 @@
 
 # create Makefile
 
-cat << END > Makefile
+if [ "$NGX_ROOT" = "." ]; then
+
+    cat << END > $NGX_ROOT/Makefile
 
 default:	build
 
 clean:
 	rm -rf Makefile $NGX_OBJS
 END
+
+fi
diff --git a/auto/install b/auto/install
index f7f686c..93682b3 100644
--- a/auto/install
+++ b/auto/install
@@ -160,7 +160,7 @@
 
 # create Makefile
 
-cat << END >> Makefile
+cat << END >> $NGX_ROOT/Makefile
 
 build:
 	\$(MAKE) -f $NGX_MAKEFILE
diff --git a/auto/lib/conf b/auto/lib/conf
index e1e4475..0a0d3dc 100644
--- a/auto/lib/conf
+++ b/auto/lib/conf
@@ -4,7 +4,7 @@
 
 
 if [ $USE_PCRE = YES -o $PCRE != NONE ]; then
-    . auto/lib/pcre/conf
+    . $NGX_AUTO/lib/pcre/conf
 
 else
     if [ $USE_PCRE = DISABLED -a $HTTP_REWRITE = YES ]; then
@@ -22,20 +22,20 @@
 
 
 if [ $USE_OPENSSL = YES ]; then
-    . auto/lib/openssl/conf
+    . $NGX_AUTO/lib/openssl/conf
 fi
 
 if [ $USE_MD5 = YES ]; then
 
     if [ $USE_OPENSSL = YES ]; then
-        have=NGX_HAVE_OPENSSL_MD5_H . auto/have
-        have=NGX_OPENSSL_MD5 . auto/have
-        have=NGX_HAVE_MD5 . auto/have
+        have=NGX_HAVE_OPENSSL_MD5_H . $NGX_AUTO/have
+        have=NGX_OPENSSL_MD5 . $NGX_AUTO/have
+        have=NGX_HAVE_MD5 . $NGX_AUTO/have
         MD5=YES
         MD5_LIB=OpenSSL
 
     else
-        . auto/lib/md5/conf
+        . $NGX_AUTO/lib/md5/conf
     fi
 
 fi
@@ -43,41 +43,41 @@
 if [ $USE_SHA1 = YES ]; then
 
     if [ $USE_OPENSSL = YES ]; then
-        have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
-        have=NGX_HAVE_SHA1 . auto/have
+        have=NGX_HAVE_OPENSSL_SHA1_H . $NGX_AUTO/have
+        have=NGX_HAVE_SHA1 . $NGX_AUTO/have
         SHA1=YES
         SHA1_LIB=OpenSSL
 
     else
-        . auto/lib/sha1/conf
+        . $NGX_AUTO/lib/sha1/conf
     fi
 
 fi
 
 if [ $USE_ZLIB = YES ]; then
-    . auto/lib/zlib/conf
+    . $NGX_AUTO/lib/zlib/conf
 fi
 
 if [ $USE_LIBXSLT = YES ]; then
-    . auto/lib/libxslt/conf
+    . $NGX_AUTO/lib/libxslt/conf
 fi
 
 if [ $USE_LIBGD = YES ]; then
-    . auto/lib/libgd/conf
+    . $NGX_AUTO/lib/libgd/conf
 fi
 
 if [ $USE_PERL = YES ]; then
-    . auto/lib/perl/conf
+    . $NGX_AUTO/lib/perl/conf
 fi
 
 if [ $HTTP_GEOIP = YES ]; then
-    . auto/lib/geoip/conf
+    . $NGX_AUTO/lib/geoip/conf
 fi
 
 if [ $NGX_GOOGLE_PERFTOOLS = YES ]; then
-    . auto/lib/google-perftools/conf
+    . $NGX_AUTO/lib/google-perftools/conf
 fi
 
 if [ $NGX_LIBATOMIC != NO ]; then
-    . auto/lib/libatomic/conf
+    . $NGX_AUTO/lib/libatomic/conf
 fi
diff --git a/auto/lib/geoip/conf b/auto/lib/geoip/conf
index 53c274d..7c8e324 100644
--- a/auto/lib/geoip/conf
+++ b/auto/lib/geoip/conf
@@ -10,7 +10,7 @@
     ngx_feature_path=
     ngx_feature_libs="-lGeoIP"
     ngx_feature_test="GeoIP_open(NULL, 0)"
-    . auto/feature
+    . $NGX_AUTO/feature
 
 
 if [ $ngx_found = no ]; then
@@ -26,7 +26,7 @@
         ngx_feature_libs="-L/usr/local/lib -lGeoIP"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -43,7 +43,7 @@
         ngx_feature_libs="-L/usr/pkg/lib -lGeoIP"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -60,7 +60,7 @@
         ngx_feature_libs="-L/opt/local/lib -lGeoIP"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -78,7 +78,7 @@
         #ngx_feature_path=
         #ngx_feature_libs=
         ngx_feature_test="printf(\"%d\", GEOIP_CITY_EDITION_REV0_V6);"
-        . auto/feature
+        . $NGX_AUTO/feature
     fi
 
 else
diff --git a/auto/lib/google-perftools/conf b/auto/lib/google-perftools/conf
index 5d5ddae..7c350dc 100644
--- a/auto/lib/google-perftools/conf
+++ b/auto/lib/google-perftools/conf
@@ -10,7 +10,7 @@
     ngx_feature_path=
     ngx_feature_libs="-lprofiler"
     ngx_feature_test="ProfilerStop()"
-    . auto/feature
+    . $NGX_AUTO/feature
 
 
 if [ $ngx_found = no ]; then
@@ -25,7 +25,7 @@
         ngx_feature_libs="-L/usr/local/lib -lprofiler"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -41,7 +41,7 @@
         ngx_feature_libs="-L/opt/local/lib -lprofiler"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
diff --git a/auto/lib/libatomic/conf b/auto/lib/libatomic/conf
index d1e484a..28a7a22 100644
--- a/auto/lib/libatomic/conf
+++ b/auto/lib/libatomic/conf
@@ -5,7 +5,7 @@
 
 if [ $NGX_LIBATOMIC != YES ]; then
 
-    have=NGX_HAVE_LIBATOMIC . auto/have
+    have=NGX_HAVE_LIBATOMIC . $NGX_AUTO/have
     CORE_INCS="$CORE_INCS $NGX_LIBATOMIC/src"
     LINK_DEPS="$LINK_DEPS $NGX_LIBATOMIC/src/libatomic_ops.a"
     CORE_LIBS="$CORE_LIBS $NGX_LIBATOMIC/src/libatomic_ops.a"
@@ -27,7 +27,7 @@
                       if (n != 2)
                           return 1;
                       AO_nop();"
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = yes ]; then
         CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
diff --git a/auto/lib/libgd/conf b/auto/lib/libgd/conf
index ff99054..f16d81d 100644
--- a/auto/lib/libgd/conf
+++ b/auto/lib/libgd/conf
@@ -10,7 +10,7 @@
     ngx_feature_path=
     ngx_feature_libs="-lgd"
     ngx_feature_test="gdImagePtr img = gdImageCreateFromGifPtr(1, NULL);"
-    . auto/feature
+    . $NGX_AUTO/feature
 
 
 if [ $ngx_found = no ]; then
@@ -26,7 +26,7 @@
         ngx_feature_libs="-L/usr/local/lib -lgd"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -43,7 +43,7 @@
         ngx_feature_libs="-L/usr/pkg/lib -lgd"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -60,7 +60,7 @@
         ngx_feature_libs="-L/opt/local/lib -lgd"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
diff --git a/auto/lib/libxslt/conf b/auto/lib/libxslt/conf
index bc19d83..e3eb46f 100644
--- a/auto/lib/libxslt/conf
+++ b/auto/lib/libxslt/conf
@@ -19,7 +19,7 @@
                       xmlDocPtr           doc;
                       doc = xmlParseChunk(ctxt, NULL, 0, 0);
                       xsltApplyStylesheet(sheet, doc, NULL);"
-    . auto/feature
+    . $NGX_AUTO/feature
 
 
 if [ $ngx_found = no ]; then
@@ -35,7 +35,7 @@
         ngx_feature_libs="-L/usr/local/lib -lxml2 -lxslt"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -52,7 +52,7 @@
         ngx_feature_libs="-L/usr/pkg/lib -lxml2 -lxslt"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -69,7 +69,7 @@
         ngx_feature_libs="-L/opt/local/lib -lxml2 -lxslt"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -98,7 +98,7 @@
     ngx_feature_path="/usr/include/libxml2"
     ngx_feature_libs="-lexslt"
     ngx_feature_test="exsltRegisterAll();"
-    . auto/feature
+    . $NGX_AUTO/feature
 
 if [ $ngx_found = no ]; then
 
@@ -113,7 +113,7 @@
         ngx_feature_libs="-L/usr/local/lib -lexslt"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -130,7 +130,7 @@
         ngx_feature_libs="-L/usr/pkg/lib -lexslt"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -147,7 +147,7 @@
         ngx_feature_libs="-L/opt/local/lib -lexslt"
     fi
 
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
diff --git a/auto/lib/make b/auto/lib/make
index 58a84a3..20da2c9 100644
--- a/auto/lib/make
+++ b/auto/lib/make
@@ -4,29 +4,29 @@
 
 
 if [ $PCRE != NONE -a $PCRE != NO -a $PCRE != YES ]; then
-    . auto/lib/pcre/make
+    . $NGX_AUTO/lib/pcre/make
 fi
 
 if [ $MD5 != NONE -a $MD5 != NO -a $MD5 != YES ]; then
-    . auto/lib/md5/make
+    . $NGX_AUTO/lib/md5/make
 fi
 
 if [ $SHA1 != NONE -a $SHA1 != NO -a $SHA1 != YES ]; then
-    . auto/lib/sha1/make
+    . $NGX_AUTO/lib/sha1/make
 fi
 
 if [ $OPENSSL != NONE -a $OPENSSL != NO -a $OPENSSL != YES ]; then
-    . auto/lib/openssl/make
+    . $NGX_AUTO/lib/openssl/make
 fi
 
 if [ $ZLIB != NONE -a $ZLIB != NO -a $ZLIB != YES ]; then
-    . auto/lib/zlib/make
+    . $NGX_AUTO/lib/zlib/make
 fi
 
 if [ $NGX_LIBATOMIC != NO -a $NGX_LIBATOMIC != YES ]; then
-    . auto/lib/libatomic/make
+    . $NGX_AUTO/lib/libatomic/make
 fi
 
 if [ $USE_PERL = YES ]; then
-    . auto/lib/perl/make
+    . $NGX_AUTO/lib/perl/make
 fi
diff --git a/auto/lib/md5/conf b/auto/lib/md5/conf
index eb5dfd1..bb5480d 100644
--- a/auto/lib/md5/conf
+++ b/auto/lib/md5/conf
@@ -8,14 +8,14 @@
     if grep MD5_Init $MD5/md5.h 2>&1 >/dev/null; then
         # OpenSSL md5
         OPENSSL_MD5=YES
-        have=NGX_HAVE_OPENSSL_MD5 . auto/have
-        have=NGX_OPENSSL_MD5 . auto/have
+        have=NGX_HAVE_OPENSSL_MD5 . $NGX_AUTO/have
+        have=NGX_OPENSSL_MD5 . $NGX_AUTO/have
     else
         # rsaref md5
         OPENSSL_MD5=NO
     fi
 
-    have=NGX_HAVE_MD5 . auto/have
+    have=NGX_HAVE_MD5 . $NGX_AUTO/have
     CORE_INCS="$CORE_INCS $MD5"
 
     case "$NGX_CC_NAME" in
@@ -59,7 +59,7 @@
             ngx_feature_path=
             ngx_feature_libs="-lmd"
             ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
-            . auto/feature
+            . $NGX_AUTO/feature
 
             ngx_md5_lib="system md"
 
@@ -69,7 +69,7 @@
 
             ngx_feature="md5 in system md5 library"
             ngx_feature_libs="-lmd5"
-            . auto/feature
+            . $NGX_AUTO/feature
 
             ngx_md5_lib="system md5"
         fi
@@ -83,13 +83,13 @@
             ngx_feature_incs="#include <openssl/md5.h>"
             ngx_feature_libs="-lcrypto"
             ngx_feature_test="MD5_CTX md5; MD5_Init(&md5)"
-            . auto/feature
+            . $NGX_AUTO/feature
 
             ngx_md5_lib="system crypto"
 
             if [ $ngx_found = yes ]; then
-                have=NGX_HAVE_OPENSSL_MD5_H . auto/have
-                have=NGX_HAVE_MD5 . auto/have
+                have=NGX_HAVE_OPENSSL_MD5_H . $NGX_AUTO/have
+                have=NGX_HAVE_MD5 . $NGX_AUTO/have
             fi
         fi
 
diff --git a/auto/lib/openssl/conf b/auto/lib/openssl/conf
index bca2050..3b3be49 100644
--- a/auto/lib/openssl/conf
+++ b/auto/lib/openssl/conf
@@ -8,8 +8,8 @@
     case "$CC" in
 
         cl | bcc32)
-            have=NGX_OPENSSL . auto/have
-            have=NGX_SSL . auto/have
+            have=NGX_OPENSSL . $NGX_AUTO/have
+            have=NGX_SSL . $NGX_AUTO/have
 
             CFLAGS="$CFLAGS -DNO_SYS_TYPES_H"
 
@@ -25,8 +25,8 @@
         ;;
 
         *)
-            have=NGX_OPENSSL . auto/have
-            have=NGX_SSL . auto/have
+            have=NGX_OPENSSL . $NGX_AUTO/have
+            have=NGX_SSL . $NGX_AUTO/have
 
             CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
             CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
@@ -53,7 +53,7 @@
         ngx_feature_path=
         ngx_feature_libs="-lssl -lcrypto"
         ngx_feature_test="SSL_library_init()"
-        . auto/feature
+        . $NGX_AUTO/feature
 
         if [ $ngx_found = no ]; then
 
@@ -68,7 +68,7 @@
                 ngx_feature_libs="-L/usr/local/lib -lssl -lcrypto"
             fi
 
-            . auto/feature
+            . $NGX_AUTO/feature
         fi
 
         if [ $ngx_found = no ]; then
@@ -84,7 +84,7 @@
                 ngx_feature_libs="-L/usr/pkg/lib -lssl -lcrypto"
             fi
 
-            . auto/feature
+            . $NGX_AUTO/feature
         fi
 
         if [ $ngx_found = no ]; then
@@ -100,11 +100,11 @@
                 ngx_feature_libs="-L/opt/local/lib -lssl -lcrypto"
             fi
 
-            . auto/feature
+            . $NGX_AUTO/feature
         fi
 
         if [ $ngx_found = yes ]; then
-            have=NGX_SSL . auto/have
+            have=NGX_SSL . $NGX_AUTO/have
             CORE_LIBS="$CORE_LIBS $ngx_feature_libs $NGX_LIBDL"
             OPENSSL=YES
         fi
diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf
index 939f01b..6665897 100644
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -9,15 +9,15 @@
     case "$NGX_CC_NAME" in
 
         msvc* | owc* | bcc)
-            have=NGX_PCRE . auto/have
-            have=PCRE_STATIC . auto/have
+            have=NGX_PCRE . $NGX_AUTO/have
+            have=PCRE_STATIC . $NGX_AUTO/have
             CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
             LINK_DEPS="$LINK_DEPS $PCRE/pcre.lib"
             CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib"
         ;;
 
         icc* )
-            have=NGX_PCRE . auto/have
+            have=NGX_PCRE . $NGX_AUTO/have
             CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
 
             LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
@@ -72,10 +72,10 @@
         ;;
 
         *)
-            have=NGX_PCRE . auto/have
+            have=NGX_PCRE . $NGX_AUTO/have
 
             if [ "$NGX_PLATFORM" = win32 ]; then
-                have=PCRE_STATIC . auto/have
+                have=PCRE_STATIC . $NGX_AUTO/have
             fi
 
             CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
@@ -87,7 +87,7 @@
 
 
     if [ $PCRE_JIT = YES ]; then
-        have=NGX_HAVE_PCRE_JIT . auto/have
+        have=NGX_HAVE_PCRE_JIT . $NGX_AUTO/have
         PCRE_CONF_OPT="$PCRE_CONF_OPT --enable-jit"
     fi
 
@@ -106,7 +106,7 @@
         ngx_feature_test="pcre *re;
                           re = pcre_compile(NULL, 0, NULL, 0, NULL);
                           if (re == NULL) return 1"
-        . auto/feature
+        . $NGX_AUTO/feature
 
         if [ $ngx_found = no ]; then
 
@@ -121,7 +121,7 @@
                 ngx_feature_libs="-L/usr/local/lib -lpcre"
             fi
 
-            . auto/feature
+            . $NGX_AUTO/feature
         fi
 
         if [ $ngx_found = no ]; then
@@ -132,7 +132,7 @@
             ngx_feature_path="/usr/include/pcre"
             ngx_feature_libs="-lpcre"
 
-            . auto/feature
+            . $NGX_AUTO/feature
         fi
 
         if [ $ngx_found = no ]; then
@@ -148,7 +148,7 @@
                 ngx_feature_libs="-L/usr/pkg/lib -lpcre"
             fi
 
-            . auto/feature
+            . $NGX_AUTO/feature
         fi
 
         if [ $ngx_found = no ]; then
@@ -164,7 +164,7 @@
                 ngx_feature_libs="-L/opt/local/lib -lpcre"
             fi
 
-            . auto/feature
+            . $NGX_AUTO/feature
         fi
 
         if [ $ngx_found = yes ]; then
@@ -180,7 +180,7 @@
                               pcre_free_study(NULL);
                               pcre_config(PCRE_CONFIG_JIT, &jit);
                               if (jit != 1) return 1;"
-            . auto/feature
+            . $NGX_AUTO/feature
 
             if [ $ngx_found = yes ]; then
                 PCRE_JIT=YES
diff --git a/auto/lib/perl/conf b/auto/lib/perl/conf
index 2a1a3fe..5be94c8 100644
--- a/auto/lib/perl/conf
+++ b/auto/lib/perl/conf
@@ -45,7 +45,7 @@
     ngx_perl_module="$ngx_perl_libdir/nginx/nginx.$ngx_perl_dlext"
 
     if $NGX_PERL -V:usemultiplicity | grep define > /dev/null; then
-        have=NGX_HAVE_PERL_MULTIPLICITY . auto/have
+        have=NGX_HAVE_PERL_MULTIPLICITY . $NGX_AUTO/have
         echo " + perl interpreter multiplicity found"
     fi
 
@@ -65,7 +65,7 @@
 
     if test -n "$NGX_PERL_MODULES"; then
         have=NGX_PERL_MODULES value="(u_char *) \"$NGX_PERL_MODULES\""
-        . auto/define
+        . $NGX_AUTO/define
         NGX_PERL_MODULES_MAN=$NGX_PERL_MODULES/man3
     fi
 
diff --git a/auto/lib/sha1/conf b/auto/lib/sha1/conf
index fd69afd..ccc672a 100644
--- a/auto/lib/sha1/conf
+++ b/auto/lib/sha1/conf
@@ -5,7 +5,7 @@
 
 if [ $SHA1 != NONE ]; then
 
-    have=NGX_HAVE_SHA1 . auto/have
+    have=NGX_HAVE_SHA1 . $NGX_AUTO/have
     CORE_INCS="$CORE_INCS $SHA1"
 
     case "$NGX_CC_NAME" in
@@ -49,7 +49,7 @@
         ngx_feature_path=
         ngx_feature_libs="-lmd"
         ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
-        . auto/feature
+        . $NGX_AUTO/feature
 
         ngx_sha1_lib="system md"
 
@@ -60,12 +60,12 @@
             ngx_feature="sha1 in system OpenSSL crypto library"
             ngx_feature_incs="#include <openssl/sha.h>"
             ngx_feature_libs="-lcrypto"
-            . auto/feature
+            . $NGX_AUTO/feature
 
             ngx_sha1_lib="system crypto"
 
             if [ $ngx_found = yes ]; then
-                have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
+                have=NGX_HAVE_OPENSSL_SHA1_H . $NGX_AUTO/have
             fi
         fi
 
diff --git a/auto/lib/zlib/conf b/auto/lib/zlib/conf
index 26db642..b9011a3 100644
--- a/auto/lib/zlib/conf
+++ b/auto/lib/zlib/conf
@@ -9,13 +9,13 @@
     case "$NGX_CC_NAME" in
 
         msvc* | owc* | bcc)
-            have=NGX_ZLIB . auto/have
+            have=NGX_ZLIB . $NGX_AUTO/have
             LINK_DEPS="$LINK_DEPS $ZLIB/zlib.lib"
             CORE_LIBS="$CORE_LIBS $ZLIB/zlib.lib"
         ;;
 
         icc*)
-            have=NGX_ZLIB . auto/have
+            have=NGX_ZLIB . $NGX_AUTO/have
             LINK_DEPS="$LINK_DEPS $ZLIB/libz.a"
 
             # to allow -ipo optimization we link with the *.o but not library
@@ -32,7 +32,7 @@
         ;;
 
         *)
-            have=NGX_ZLIB . auto/have
+            have=NGX_ZLIB . $NGX_AUTO/have
             LINK_DEPS="$LINK_DEPS $ZLIB/libz.a"
             CORE_LIBS="$CORE_LIBS $ZLIB/libz.a"
             #CORE_LIBS="$CORE_LIBS -L $ZLIB -lz"
@@ -54,7 +54,7 @@
         ngx_feature_path=
         ngx_feature_libs="-lz"
         ngx_feature_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
-        . auto/feature
+        . $NGX_AUTO/feature
 
 
         if [ $ngx_found = yes ]; then
diff --git a/auto/modules b/auto/modules
index 5c734e1..001e23a 100644
--- a/auto/modules
+++ b/auto/modules
@@ -8,7 +8,7 @@
 fi
 
 if [ $EVENT_SELECT = YES ]; then
-    have=NGX_HAVE_SELECT . auto/have
+    have=NGX_HAVE_SELECT . $NGX_AUTO/have
     CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
     EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
 fi
@@ -19,51 +19,51 @@
 fi
 
 if [ $EVENT_POLL = YES ]; then
-    have=NGX_HAVE_POLL . auto/have
+    have=NGX_HAVE_POLL . $NGX_AUTO/have
     CORE_SRCS="$CORE_SRCS $POLL_SRCS"
     EVENT_MODULES="$EVENT_MODULES $POLL_MODULE"
 fi
 
 
 if [ $NGX_TEST_BUILD_DEVPOLL = YES ]; then
-    have=NGX_HAVE_DEVPOLL . auto/have
-    have=NGX_TEST_BUILD_DEVPOLL . auto/have
+    have=NGX_HAVE_DEVPOLL . $NGX_AUTO/have
+    have=NGX_TEST_BUILD_DEVPOLL . $NGX_AUTO/have
     EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
     CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
 fi
 
 
 if [ $NGX_TEST_BUILD_EVENTPORT = YES ]; then
-    have=NGX_HAVE_EVENTPORT . auto/have
-    have=NGX_TEST_BUILD_EVENTPORT . auto/have
+    have=NGX_HAVE_EVENTPORT . $NGX_AUTO/have
+    have=NGX_TEST_BUILD_EVENTPORT . $NGX_AUTO/have
     EVENT_MODULES="$EVENT_MODULES $EVENTPORT_MODULE"
     CORE_SRCS="$CORE_SRCS $EVENTPORT_SRCS"
 fi
 
 if [ $NGX_TEST_BUILD_EPOLL = YES ]; then
-    have=NGX_HAVE_EPOLL . auto/have
-    have=NGX_HAVE_EPOLLRDHUP . auto/have
-    have=NGX_HAVE_EVENTFD . auto/have
-    have=NGX_TEST_BUILD_EPOLL . auto/have
+    have=NGX_HAVE_EPOLL . $NGX_AUTO/have
+    have=NGX_HAVE_EPOLLRDHUP . $NGX_AUTO/have
+    have=NGX_HAVE_EVENTFD . $NGX_AUTO/have
+    have=NGX_TEST_BUILD_EPOLL . $NGX_AUTO/have
     EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
     CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
 fi
 
 if [ $NGX_TEST_BUILD_SOLARIS_SENDFILEV = YES ]; then
-    have=NGX_TEST_BUILD_SOLARIS_SENDFILEV . auto/have
+    have=NGX_TEST_BUILD_SOLARIS_SENDFILEV . $NGX_AUTO/have
     CORE_SRCS="$CORE_SRCS $SOLARIS_SENDFILEV_SRCS"
 fi
 
 
 if [ $HTTP != YES ]; then
-    have=NGX_CRYPT . auto/nohave
+    have=NGX_CRYPT . $NGX_AUTO/nohave
     CRYPT_LIB=
 fi
 
 
 if [ $HTTP_CACHE = YES ]; then
     USE_MD5=YES
-    have=NGX_HTTP_CACHE . auto/have
+    have=NGX_HTTP_CACHE . $NGX_AUTO/have
     HTTP_SRCS="$HTTP_SRCS $HTTP_FILE_CACHE_SRCS"
 fi
 
@@ -122,7 +122,7 @@
 HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_RANGE_HEADER_FILTER_MODULE"
 
 if [ $HTTP_GZIP = YES ]; then
-    have=NGX_HTTP_GZIP . auto/have
+    have=NGX_HTTP_GZIP . $NGX_AUTO/have
     USE_ZLIB=YES
     HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_GZIP_FILTER_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_GZIP_SRCS"
@@ -134,7 +134,7 @@
 fi
 
 if [ $HTTP_SSI = YES ]; then
-    have=NGX_HTTP_SSI . auto/have
+    have=NGX_HTTP_SSI . $NGX_AUTO/have
     HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_SSI_FILTER_MODULE"
     HTTP_DEPS="$HTTP_DEPS $HTTP_SSI_DEPS"
     HTTP_SRCS="$HTTP_SRCS $HTTP_SSI_SRCS"
@@ -168,7 +168,7 @@
 fi
 
 if [ $HTTP_GUNZIP = YES ]; then
-    have=NGX_HTTP_GZIP . auto/have
+    have=NGX_HTTP_GZIP . $NGX_AUTO/have
     USE_ZLIB=YES
     HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES $HTTP_GUNZIP_FILTER_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_GUNZIP_SRCS"
@@ -181,7 +181,7 @@
 
 
 if [ $HTTP_V2 = YES ]; then
-    have=NGX_HTTP_V2 . auto/have
+    have=NGX_HTTP_V2 . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_V2_MODULE"
     HTTP_INCS="$HTTP_INCS $HTTP_V2_INCS"
     HTTP_DEPS="$HTTP_DEPS $HTTP_V2_DEPS"
@@ -191,13 +191,13 @@
 HTTP_MODULES="$HTTP_MODULES $HTTP_STATIC_MODULE"
 
 if [ $HTTP_GZIP_STATIC = YES ]; then
-    have=NGX_HTTP_GZIP . auto/have
+    have=NGX_HTTP_GZIP . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_GZIP_STATIC_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_GZIP_STATIC_SRCS"
 fi
 
 if [ $HTTP_DAV = YES ]; then
-    have=NGX_HTTP_DAV . auto/have
+    have=NGX_HTTP_DAV . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_DAV_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_DAV_SRCS"
 fi
@@ -222,7 +222,7 @@
 if [ $HTTP_AUTH_BASIC = YES ]; then
     USE_MD5=YES
     USE_SHA1=YES
-    have=NGX_CRYPT . auto/have
+    have=NGX_CRYPT . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_AUTH_BASIC_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_AUTH_BASIC_SRCS"
     CORE_LIBS="$CORE_LIBS $CRYPT_LIB"
@@ -244,8 +244,8 @@
 fi
 
 if [ $HTTP_REALIP = YES ]; then
-    have=NGX_HTTP_REALIP . auto/have
-    have=NGX_HTTP_X_FORWARDED_FOR . auto/have
+    have=NGX_HTTP_REALIP . $NGX_AUTO/have
+    have=NGX_HTTP_X_FORWARDED_FOR . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_REALIP_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_REALIP_SRCS"
 fi
@@ -256,13 +256,13 @@
 fi
 
 if [ $HTTP_GEO = YES ]; then
-    have=NGX_HTTP_X_FORWARDED_FOR . auto/have
+    have=NGX_HTTP_X_FORWARDED_FOR . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_GEO_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_GEO_SRCS"
 fi
 
 if [ $HTTP_GEOIP = YES ]; then
-    have=NGX_HTTP_X_FORWARDED_FOR . auto/have
+    have=NGX_HTTP_X_FORWARDED_FOR . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_GEOIP_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_GEOIP_SRCS"
 fi
@@ -290,14 +290,14 @@
 
 if [ $HTTP_SSL = YES ]; then
     USE_OPENSSL=YES
-    have=NGX_HTTP_SSL . auto/have
+    have=NGX_HTTP_SSL . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_SSL_MODULE"
     HTTP_DEPS="$HTTP_DEPS $HTTP_SSL_DEPS"
     HTTP_SRCS="$HTTP_SRCS $HTTP_SSL_SRCS"
 fi
 
 if [ $HTTP_PROXY = YES ]; then
-    have=NGX_HTTP_X_FORWARDED_FOR . auto/have
+    have=NGX_HTTP_X_FORWARDED_FOR . $NGX_AUTO/have
     #USE_MD5=YES
     HTTP_MODULES="$HTTP_MODULES $HTTP_PROXY_MODULE"
     HTTP_DEPS="$HTTP_DEPS $HTTP_PROXY_DEPS"
@@ -349,7 +349,7 @@
 fi
 
 if [ $HTTP_DEGRADATION = YES ]; then
-    have=NGX_HTTP_DEGRADATION . auto/have
+    have=NGX_HTTP_DEGRADATION . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_DEGRADATION_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_DEGRADATION_SRCS"
 fi
@@ -385,13 +385,13 @@
 fi
 
 if [ $HTTP_UPSTREAM_ZONE = YES ]; then
-    have=NGX_HTTP_UPSTREAM_ZONE . auto/have
+    have=NGX_HTTP_UPSTREAM_ZONE . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_UPSTREAM_ZONE_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_UPSTREAM_ZONE_SRCS"
 fi
 
 if [ $HTTP_STUB_STATUS = YES ]; then
-    have=NGX_STAT_STUB . auto/have
+    have=NGX_STAT_STUB . $NGX_AUTO/have
     HTTP_MODULES="$HTTP_MODULES ngx_http_stub_status_module"
     HTTP_SRCS="$HTTP_SRCS src/http/modules/ngx_http_stub_status_module.c"
 fi
@@ -423,13 +423,13 @@
 
 
 if [ $MAIL_SSL = YES ]; then
-    have=NGX_MAIL_SSL . auto/have
+    have=NGX_MAIL_SSL . $NGX_AUTO/have
     USE_OPENSSL=YES
 fi
 
 
 if [ $STREAM_SSL = YES ]; then
-    have=NGX_STREAM_SSL . auto/have
+    have=NGX_STREAM_SSL . $NGX_AUTO/have
     USE_OPENSSL=YES
 fi
 
@@ -505,7 +505,7 @@
 
 
 if [ $STREAM = YES ]; then
-    have=NGX_STREAM . auto/have
+    have=NGX_STREAM . $NGX_AUTO/have
     modules="$modules $STREAM_MODULES"
 
     if [ $STREAM_SSL = YES ]; then
@@ -535,7 +535,7 @@
     fi
 
     if [ $STREAM_UPSTREAM_ZONE = YES ]; then
-        have=NGX_STREAM_UPSTREAM_ZONE . auto/have
+        have=NGX_STREAM_UPSTREAM_ZONE . $NGX_AUTO/have
         modules="$modules $STREAM_UPSTREAM_ZONE_MODULE"
         STREAM_SRCS="$STREAM_SRCS $STREAM_UPSTREAM_ZONE_SRCS"
     fi
diff --git a/auto/options b/auto/options
index efc8943..bc88835 100644
--- a/auto/options
+++ b/auto/options
@@ -18,7 +18,7 @@
 
 CC=${CC:-cc}
 CPP=
-NGX_OBJS=objs
+NGX_OBJS=$NGX_ROOT/objs
 
 NGX_DEBUG=NO
 NGX_CC_OPT=
diff --git a/auto/os/conf b/auto/os/conf
index 6ad0e74..b17a8ff 100644
--- a/auto/os/conf
+++ b/auto/os/conf
@@ -8,33 +8,33 @@
 case "$NGX_PLATFORM" in
 
     FreeBSD:*)
-        . auto/os/freebsd
+        . $NGX_AUTO/os/freebsd
     ;;
 
     Linux:*)
-        . auto/os/linux
+        . $NGX_AUTO/os/linux
     ;;
 
     SunOS:*)
-        . auto/os/solaris
+        . $NGX_AUTO/os/solaris
     ;;
 
     Darwin:*)
-        . auto/os/darwin
+        . $NGX_AUTO/os/darwin
     ;;
 
     win32)
-        . auto/os/win32
+        . $NGX_AUTO/os/win32
     ;;
 
     DragonFly:*)
-        have=NGX_FREEBSD . auto/have_headers
+        have=NGX_FREEBSD . $NGX_AUTO/have_headers
         CORE_INCS="$UNIX_INCS"
         CORE_DEPS="$UNIX_DEPS $FREEBSD_DEPS"
         CORE_SRCS="$UNIX_SRCS $FREEBSD_SRCS"
 
         echo " + sendfile() found"
-        have=NGX_HAVE_SENDFILE . auto/have
+        have=NGX_HAVE_SENDFILE . $NGX_AUTO/have
         CORE_SRCS="$CORE_SRCS $FREEBSD_SENDFILE_SRCS"
 
         ngx_spacer='
@@ -43,7 +43,7 @@
 
     HP-UX:*)
         # HP/UX
-        have=NGX_HPUX . auto/have_headers
+        have=NGX_HPUX . $NGX_AUTO/have_headers
         CORE_INCS="$UNIX_INCS"
         CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
         CORE_SRCS="$UNIX_SRCS"
@@ -53,8 +53,8 @@
 
     OSF1:*)
         # Tru64 UNIX
-        have=NGX_TRU64 . auto/have_headers
-        have=NGX_HAVE_STRERROR_R . auto/nohave
+        have=NGX_TRU64 . $NGX_AUTO/have_headers
+        have=NGX_HAVE_STRERROR_R . $NGX_AUTO/nohave
         CORE_INCS="$UNIX_INCS"
         CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
         CORE_SRCS="$UNIX_SRCS"
@@ -62,7 +62,7 @@
 
     GNU:*)
         # GNU Hurd
-        have=NGX_GNU_HURD . auto/have_headers
+        have=NGX_GNU_HURD . $NGX_AUTO/have_headers
         CORE_INCS="$UNIX_INCS"
         CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
         CORE_SRCS="$UNIX_SRCS"
@@ -81,29 +81,29 @@
 case "$NGX_MACHINE" in
 
     i386 | i686 | i86pc)
-        have=NGX_HAVE_NONALIGNED . auto/have
+        have=NGX_HAVE_NONALIGNED . $NGX_AUTO/have
         NGX_MACH_CACHE_LINE=32
     ;;
 
     amd64 | x86_64)
-        have=NGX_HAVE_NONALIGNED . auto/have
+        have=NGX_HAVE_NONALIGNED . $NGX_AUTO/have
         NGX_MACH_CACHE_LINE=64
     ;;
 
     sun4u | sun4v | sparc | sparc64)
-        have=NGX_ALIGNMENT value=16 . auto/define
+        have=NGX_ALIGNMENT value=16 . $NGX_AUTO/define
         # TODO
         NGX_MACH_CACHE_LINE=64
     ;;
 
     ia64 )
-        have=NGX_ALIGNMENT value=16 . auto/define
+        have=NGX_ALIGNMENT value=16 . $NGX_AUTO/define
         # TODO
         NGX_MACH_CACHE_LINE=64
     ;;
 
     *)
-        have=NGX_ALIGNMENT value=16 . auto/define
+        have=NGX_ALIGNMENT value=16 . $NGX_AUTO/define
         NGX_MACH_CACHE_LINE=32
     ;;
 
@@ -113,4 +113,4 @@
     NGX_CPU_CACHE_LINE=$NGX_MACH_CACHE_LINE
 fi
 
-have=NGX_CPU_CACHE_LINE value=$NGX_CPU_CACHE_LINE . auto/define
+have=NGX_CPU_CACHE_LINE value=$NGX_CPU_CACHE_LINE . $NGX_AUTO/define
diff --git a/auto/os/darwin b/auto/os/darwin
index 1d3e3d3..4b010d5 100644
--- a/auto/os/darwin
+++ b/auto/os/darwin
@@ -3,7 +3,7 @@
 # Copyright (C) Nginx, Inc.
 
 
-have=NGX_DARWIN . auto/have_headers
+have=NGX_DARWIN . $NGX_AUTO/have_headers
 
 CORE_INCS="$UNIX_INCS"
 CORE_DEPS="$UNIX_DEPS $DARWIN_DEPS"
@@ -17,8 +17,8 @@
 # kqueue
 
 echo " + kqueue found"
-have=NGX_HAVE_KQUEUE . auto/have
-have=NGX_HAVE_CLEAR_EVENT . auto/have
+have=NGX_HAVE_KQUEUE . $NGX_AUTO/have
+have=NGX_HAVE_CLEAR_EVENT . $NGX_AUTO/have
 EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
 CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
 EVENT_FOUND=YES
@@ -51,7 +51,7 @@
 
                   if (kev.flags & EV_ERROR) return 1;"
 
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="Darwin 64-bit kqueue millisecond timeout bug"
@@ -78,7 +78,7 @@
 
                   if (tv.tv_sec * 1000000 + tv.tv_usec < 900000) return 1;"
 
-. auto/feature
+. $NGX_AUTO/feature
 
 
 # sendfile()
@@ -97,7 +97,7 @@
                   off_t n; off_t off = 0;
                   n = sendfile(s, fd, off, &n, NULL, 0);
                   if (n == -1 && errno == ENOSYS) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 if [ $ngx_found = yes ]; then
     CORE_SRCS="$CORE_SRCS $DARWIN_SENDFILE_SRCS"
@@ -112,4 +112,4 @@
 ngx_feature_libs=
 ngx_feature_test="int32_t  lock, n;
                   n = OSAtomicCompareAndSwap32Barrier(0, 1, &lock)"
-. auto/feature
+. $NGX_AUTO/feature
diff --git a/auto/os/freebsd b/auto/os/freebsd
index 937ca20..50902dd 100644
--- a/auto/os/freebsd
+++ b/auto/os/freebsd
@@ -3,7 +3,7 @@
 # Copyright (C) Nginx, Inc.
 
 
-have=NGX_FREEBSD . auto/have_headers
+have=NGX_FREEBSD . $NGX_AUTO/have_headers
 
 CORE_INCS="$UNIX_INCS"
 CORE_DEPS="$UNIX_DEPS $FREEBSD_DEPS"
@@ -40,7 +40,7 @@
 if [ $osreldate -gt 300007 ]; then
     echo " + sendfile() found"
 
-    have=NGX_HAVE_SENDFILE . auto/have
+    have=NGX_HAVE_SENDFILE . $NGX_AUTO/have
     CORE_SRCS="$CORE_SRCS $FREEBSD_SENDFILE_SRCS"
 fi
 
@@ -48,7 +48,7 @@
     if [ $osreldate -gt 502103 ]; then
         echo " + sendfile()'s SF_NODISKIO found"
 
-        have=NGX_HAVE_AIO_SENDFILE . auto/have
+        have=NGX_HAVE_AIO_SENDFILE . $NGX_AUTO/have
     fi
 fi
 
@@ -58,7 +58,7 @@
 if [ $osreldate -ge 701106 ]; then
     echo " + POSIX semaphores should work"
 else
-    have=NGX_HAVE_POSIX_SEM . auto/nohave
+    have=NGX_HAVE_POSIX_SEM . $NGX_AUTO/nohave
 fi
 
 
@@ -69,8 +69,8 @@
 then
     echo " + kqueue found"
 
-    have=NGX_HAVE_KQUEUE . auto/have
-    have=NGX_HAVE_CLEAR_EVENT . auto/have
+    have=NGX_HAVE_KQUEUE . $NGX_AUTO/have
+    have=NGX_HAVE_CLEAR_EVENT . $NGX_AUTO/have
     EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
     CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
     EVENT_FOUND=YES
@@ -86,7 +86,7 @@
      -o $version -ge 500018 ]
 then
     echo " + kqueue's NOTE_LOWAT found"
-    have=NGX_HAVE_LOWAT_EVENT . auto/have
+    have=NGX_HAVE_LOWAT_EVENT . $NGX_AUTO/have
 fi
 
 # kqueue's EVFILT_TIMER
@@ -95,7 +95,7 @@
      -o $version -ge 500023 ]
 then
     echo " + kqueue's EVFILT_TIMER found"
-    have=NGX_HAVE_TIMER_EVENT . auto/have
+    have=NGX_HAVE_TIMER_EVENT . $NGX_AUTO/have
 fi
 
 
@@ -103,5 +103,5 @@
 
 if [ $version -ge 701000 ]; then
     echo " + cpuset_setaffinity() found"
-    have=NGX_HAVE_CPUSET_SETAFFINITY . auto/have
+    have=NGX_HAVE_CPUSET_SETAFFINITY . $NGX_AUTO/have
 fi
diff --git a/auto/os/linux b/auto/os/linux
index c932267..bff234f 100644
--- a/auto/os/linux
+++ b/auto/os/linux
@@ -3,7 +3,7 @@
 # Copyright (C) Nginx, Inc.
 
 
-have=NGX_LINUX . auto/have_headers
+have=NGX_LINUX . $NGX_AUTO/have_headers
 
 CORE_INCS="$UNIX_INCS"
 CORE_DEPS="$UNIX_DEPS $LINUX_DEPS"
@@ -29,7 +29,7 @@
 # posix_fadvise64() had been implemented in 2.5.60
 
 if [ $version -lt 132412 ]; then
-    have=NGX_HAVE_POSIX_FADVISE . auto/nohave
+    have=NGX_HAVE_POSIX_FADVISE . $NGX_AUTO/nohave
 fi
 
 # epoll, EPOLLET version
@@ -46,10 +46,10 @@
                   ee.data.ptr = NULL;
                   efd = epoll_create(100);
                   if (efd == -1) return 1;"
-. auto/feature
+. $NGX_AUTO/feature
 
 if [ $ngx_found = yes ]; then
-    have=NGX_HAVE_CLEAR_EVENT . auto/have
+    have=NGX_HAVE_CLEAR_EVENT . $NGX_AUTO/have
     CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
     EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
     EVENT_FOUND=YES
@@ -68,7 +68,7 @@
                       ee.events = EPOLLIN|EPOLLRDHUP|EPOLLET;
                       ee.data.ptr = NULL;
                       epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)"
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -85,7 +85,7 @@
 ngx_feature_test="int fd; struct stat sb;
                   fd = openat(AT_FDCWD, \".\", O_PATH|O_DIRECTORY|O_NOFOLLOW);
                   if (fstatat(fd, \"\", &sb, AT_EMPTY_PATH) != 0) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 # sendfile()
@@ -102,7 +102,7 @@
                   ssize_t n; off_t off = 0;
                   n = sendfile(s, fd, &off, 1);
                   if (n == -1 && errno == ENOSYS) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 if [ $ngx_found = yes ]; then
     CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS"
@@ -123,10 +123,10 @@
                   ssize_t n; off_t off = 0;
                   n = sendfile(s, fd, &off, 1);
                   if (n == -1 && errno == ENOSYS) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 
-ngx_include="sys/prctl.h"; . auto/include
+ngx_include="sys/prctl.h"; . $NGX_AUTO/include
 
 # prctl(PR_SET_DUMPABLE)
 
@@ -137,7 +137,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 # sched_setaffinity()
@@ -151,7 +151,7 @@
 ngx_feature_test="cpu_set_t mask;
                   CPU_ZERO(&mask);
                   sched_setaffinity(0, sizeof(cpu_set_t), &mask)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 # crypt_r()
@@ -164,10 +164,10 @@
 ngx_feature_libs=-lcrypt
 ngx_feature_test="struct crypt_data  cd;
                   crypt_r(\"key\", \"salt\", &cd);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
-ngx_include="sys/vfs.h";     . auto/include
+ngx_include="sys/vfs.h";     . $NGX_AUTO/include
 
 
 CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
diff --git a/auto/os/solaris b/auto/os/solaris
index d39df0b..9475b1a 100644
--- a/auto/os/solaris
+++ b/auto/os/solaris
@@ -3,7 +3,7 @@
 # Copyright (C) Nginx, Inc.
 
 
-have=NGX_SOLARIS . auto/have_headers
+have=NGX_SOLARIS . $NGX_AUTO/have_headers
 
 CORE_INCS="$UNIX_INCS"
 CORE_DEPS="$UNIX_DEPS $SOLARIS_DEPS"
@@ -37,7 +37,7 @@
                   size_t sent; ssize_t n;
                   n = sendfilev(fd, vec, 1, &sent);
                   if (n == -1) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 if [ $ngx_found = yes ]; then
@@ -53,7 +53,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="int n = port_create()"
-. auto/feature
+. $NGX_AUTO/feature
 
 if [ $ngx_found = yes ]; then
     CORE_SRCS="$CORE_SRCS $EVENTPORT_SRCS"
diff --git a/auto/os/win32 b/auto/os/win32
index 82fc212..30f23b1 100644
--- a/auto/os/win32
+++ b/auto/os/win32
@@ -3,7 +3,7 @@
 # Copyright (C) Nginx, Inc.
 
 
-have=NGX_WIN32 . auto/have_headers
+have=NGX_WIN32 . $NGX_AUTO/have_headers
 
 CORE_INCS="$WIN32_INCS"
 CORE_DEPS="$WIN32_DEPS"
@@ -33,7 +33,7 @@
 fi
 
 if [ $NGX_IPV6 = YES ]; then
-    have=NGX_HAVE_INET6 . auto/have
+    have=NGX_HAVE_INET6 . $NGX_AUTO/have
 fi
 
-have=NGX_HAVE_IOCP . auto/have
+have=NGX_HAVE_IOCP . $NGX_AUTO/have
diff --git a/auto/stubs b/auto/stubs
index d8bc1f0..29247cb 100644
--- a/auto/stubs
+++ b/auto/stubs
@@ -3,6 +3,6 @@
 # Copyright (C) Nginx, Inc.
 
 
-have=NGX_SUPPRESS_WARN . auto/have
+have=NGX_SUPPRESS_WARN . $NGX_AUTO/have
 
-have=NGX_SMP . auto/have
+have=NGX_SMP . $NGX_AUTO/have
diff --git a/auto/threads b/auto/threads
index 381f07a..5ba2a0a 100644
--- a/auto/threads
+++ b/auto/threads
@@ -13,7 +13,7 @@
         exit 1
     fi
 
-    have=NGX_THREADS . auto/have
+    have=NGX_THREADS . $NGX_AUTO/have
     CORE_DEPS="$CORE_DEPS $THREAD_POOL_DEPS"
     CORE_SRCS="$CORE_SRCS $THREAD_POOL_SRCS"
     CORE_LIBS="$CORE_LIBS -lpthread"
diff --git a/auto/unix b/auto/unix
index b7b7a25..4054d16 100755
--- a/auto/unix
+++ b/auto/unix
@@ -39,7 +39,7 @@
                   pl.revents = 0;
                   n = poll(&pl, 1, 0);
                   if (n == -1) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 if [ $ngx_found = no ]; then
     EVENT_POLL=NONE
@@ -59,7 +59,7 @@
                   dvp.dp_timeout = 0;
                   n = ioctl(dp, DP_POLL, &dvp);
                   if (n == -1) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 if [ $ngx_found = yes ]; then
     CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
@@ -76,11 +76,11 @@
     ngx_feature_path=
     ngx_feature_libs=
     ngx_feature_test="int kq; kq = kqueue()"
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = yes ]; then
 
-        have=NGX_HAVE_CLEAR_EVENT . auto/have
+        have=NGX_HAVE_CLEAR_EVENT . $NGX_AUTO/have
         EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
         CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
         EVENT_FOUND=YES
@@ -93,7 +93,7 @@
         ngx_feature_libs=
         ngx_feature_test="struct kevent  kev;
                           kev.fflags = NOTE_LOWAT;"
-        . auto/feature
+        . $NGX_AUTO/feature
 
 
         ngx_feature="kqueue's EVFILT_TIMER"
@@ -123,7 +123,7 @@
 
                   if (kev.flags & EV_ERROR) return 1;"
 
-        . auto/feature
+        . $NGX_AUTO/feature
     fi
 fi
 
@@ -155,7 +155,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="crypt(\"test\", \"salt\");"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 if [ $ngx_found = no ]; then
@@ -166,7 +166,7 @@
     ngx_feature_incs=
     ngx_feature_path=
     ngx_feature_libs=-lcrypt
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = yes ]; then
         CRYPT_LIB="-lcrypt"
@@ -181,7 +181,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="fcntl(0, F_READAHEAD, 1);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="posix_fadvise()"
@@ -191,7 +191,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="posix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="O_DIRECT"
@@ -201,11 +201,11 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="fcntl(0, F_SETFL, O_DIRECT);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 if [ $ngx_found = yes -a "$NGX_SYSTEM" = "Linux" ]; then
-    have=NGX_HAVE_ALIGNED_DIRECTIO . auto/have
+    have=NGX_HAVE_ALIGNED_DIRECTIO . $NGX_AUTO/have
 fi
 
 ngx_feature="F_NOCACHE"
@@ -215,7 +215,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="fcntl(0, F_NOCACHE, 1);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="directio()"
@@ -226,7 +226,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="directio(0, DIRECTIO_ON);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="statfs()"
@@ -239,7 +239,7 @@
 ngx_feature_libs=
 ngx_feature_test="struct statfs  fs;
                   statfs(\".\", &fs);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="statvfs()"
@@ -251,7 +251,7 @@
 ngx_feature_libs=
 ngx_feature_test="struct statvfs  fs;
                   statvfs(\".\", &fs);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="dlopen()"
@@ -261,14 +261,14 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="dlopen(NULL, 0)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 if [ $ngx_found != yes ]; then
 
     ngx_feature="dlopen() in libdl"
     ngx_feature_libs="-ldl"
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = yes ]; then
         NGX_LIBDL="-ldl"
@@ -283,14 +283,14 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="sched_yield()"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 if [ $ngx_found != yes ]; then
 
     ngx_feature="sched_yield() in librt"
     ngx_feature_libs="-lrt"
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = yes ]; then
         CORE_LIBS="$CORE_LIBS -lrt"
@@ -305,7 +305,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_SETFIB, NULL, 0)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="SO_REUSEPORT"
@@ -315,7 +315,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_REUSEPORT, NULL, 0)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="SO_ACCEPTFILTER"
@@ -325,7 +325,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_ACCEPTFILTER, NULL, 0)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="TCP_DEFER_ACCEPT"
@@ -337,7 +337,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_DEFER_ACCEPT, NULL, 0)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="TCP_KEEPIDLE"
@@ -351,7 +351,7 @@
 ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_KEEPIDLE, NULL, 0);
                   setsockopt(0, IPPROTO_TCP, TCP_KEEPINTVL, NULL, 0);
                   setsockopt(0, IPPROTO_TCP, TCP_KEEPCNT, NULL, 0)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="TCP_FASTOPEN"
@@ -363,7 +363,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_FASTOPEN, NULL, 0)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="TCP_INFO"
@@ -381,7 +381,7 @@
                   ti.tcpi_snd_cwnd = 0;
                   ti.tcpi_rcv_space = 0;
                   getsockopt(0, IPPROTO_TCP, TCP_INFO, &ti, &optlen)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="accept4()"
@@ -391,7 +391,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="accept4(0, NULL, NULL, SOCK_NONBLOCK)"
-. auto/feature
+. $NGX_AUTO/feature
 
 if [ $NGX_FILE_AIO = YES ]; then
 
@@ -404,7 +404,7 @@
     ngx_feature_test="int  n; struct aiocb  iocb;
                       iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
                       n = aio_read(&iocb)"
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = yes ]; then
         CORE_SRCS="$CORE_SRCS $FILE_AIO_SRCS"
@@ -424,11 +424,11 @@
                           iocb.aio_flags = IOCB_FLAG_RESFD;
                           iocb.aio_resfd = -1;
                           (void) eventfd(0, 0)"
-        . auto/feature
+        . $NGX_AUTO/feature
 
         if [ $ngx_found = yes ]; then
-            have=NGX_HAVE_EVENTFD . auto/have
-            have=NGX_HAVE_SYS_EVENTFD_H . auto/have
+            have=NGX_HAVE_EVENTFD . $NGX_AUTO/have
+            have=NGX_HAVE_SYS_EVENTFD_H . $NGX_AUTO/have
             CORE_SRCS="$CORE_SRCS $LINUX_AIO_SRCS"
         fi
     fi
@@ -443,10 +443,10 @@
                           iocb.aio_lio_opcode = IOCB_CMD_PREAD;
                           iocb.aio_flags = IOCB_FLAG_RESFD;
                           iocb.aio_resfd = -1;"
-        . auto/feature
+        . $NGX_AUTO/feature
 
         if [ $ngx_found = yes ]; then
-            have=NGX_HAVE_EVENTFD . auto/have
+            have=NGX_HAVE_EVENTFD . $NGX_AUTO/have
             CORE_SRCS="$CORE_SRCS $LINUX_AIO_SRCS"
         fi
     fi
@@ -470,10 +470,10 @@
     ngx_feature_path=
     ngx_feature_libs=
     ngx_feature_test="(void) eventfd(0, 0)"
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = yes ]; then
-        have=NGX_HAVE_SYS_EVENTFD_H . auto/have
+        have=NGX_HAVE_SYS_EVENTFD_H . $NGX_AUTO/have
     fi
 
     if [ $ngx_found = no ]; then
@@ -481,62 +481,62 @@
         ngx_feature="eventfd() (SYS_eventfd)"
         ngx_feature_incs="#include <sys/syscall.h>"
         ngx_feature_test="int n = SYS_eventfd"
-        . auto/feature
+        . $NGX_AUTO/feature
     fi
 fi
 
 
-have=NGX_HAVE_UNIX_DOMAIN . auto/have
+have=NGX_HAVE_UNIX_DOMAIN . $NGX_AUTO/have
 
 ngx_feature_libs=
 
 
 # C types
 
-ngx_type="int"; . auto/types/sizeof
+ngx_type="int"; . $NGX_AUTO/types/sizeof
 
-ngx_type="long"; . auto/types/sizeof
+ngx_type="long"; . $NGX_AUTO/types/sizeof
 
-ngx_type="long long"; . auto/types/sizeof
+ngx_type="long long"; . $NGX_AUTO/types/sizeof
 
-ngx_type="void *"; . auto/types/sizeof; ngx_ptr_size=$ngx_size
-ngx_param=NGX_PTR_SIZE; ngx_value=$ngx_size; . auto/types/value
+ngx_type="void *"; . $NGX_AUTO/types/sizeof; ngx_ptr_size=$ngx_size
+ngx_param=NGX_PTR_SIZE; ngx_value=$ngx_size; . $NGX_AUTO/types/value
 
 
 # POSIX types
 
 NGX_INCLUDE_AUTO_CONFIG_H="#include \"ngx_auto_config.h\""
 
-ngx_type="uint64_t"; ngx_types="u_int64_t"; . auto/types/typedef
+ngx_type="uint64_t"; ngx_types="u_int64_t"; . $NGX_AUTO/types/typedef
 
-ngx_type="sig_atomic_t"; ngx_types="int"; . auto/types/typedef
-. auto/types/sizeof
-ngx_param=NGX_SIG_ATOMIC_T_SIZE; ngx_value=$ngx_size; . auto/types/value
+ngx_type="sig_atomic_t"; ngx_types="int"; . $NGX_AUTO/types/typedef
+. $NGX_AUTO/types/sizeof
+ngx_param=NGX_SIG_ATOMIC_T_SIZE; ngx_value=$ngx_size; . $NGX_AUTO/types/value
 
-ngx_type="socklen_t"; ngx_types="int"; . auto/types/typedef
+ngx_type="socklen_t"; ngx_types="int"; . $NGX_AUTO/types/typedef
 
-ngx_type="in_addr_t"; ngx_types="uint32_t"; . auto/types/typedef
+ngx_type="in_addr_t"; ngx_types="uint32_t"; . $NGX_AUTO/types/typedef
 
-ngx_type="in_port_t"; ngx_types="u_short"; . auto/types/typedef
+ngx_type="in_port_t"; ngx_types="u_short"; . $NGX_AUTO/types/typedef
 
-ngx_type="rlim_t"; ngx_types="int"; . auto/types/typedef
+ngx_type="rlim_t"; ngx_types="int"; . $NGX_AUTO/types/typedef
 
-. auto/types/uintptr_t
+. $NGX_AUTO/types/uintptr_t
 
-. auto/endianness
+. $NGX_AUTO/endianness
 
-ngx_type="size_t"; . auto/types/sizeof
-ngx_param=NGX_MAX_SIZE_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
-ngx_param=NGX_SIZE_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
+ngx_type="size_t"; . $NGX_AUTO/types/sizeof
+ngx_param=NGX_MAX_SIZE_T_VALUE; ngx_value=$ngx_max_value; . $NGX_AUTO/types/value
+ngx_param=NGX_SIZE_T_LEN; ngx_value=$ngx_max_len; . $NGX_AUTO/types/value
 
-ngx_type="off_t"; . auto/types/sizeof
-ngx_param=NGX_MAX_OFF_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
-ngx_param=NGX_OFF_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
+ngx_type="off_t"; . $NGX_AUTO/types/sizeof
+ngx_param=NGX_MAX_OFF_T_VALUE; ngx_value=$ngx_max_value; . $NGX_AUTO/types/value
+ngx_param=NGX_OFF_T_LEN; ngx_value=$ngx_max_len; . $NGX_AUTO/types/value
 
-ngx_type="time_t"; . auto/types/sizeof
-ngx_param=NGX_TIME_T_SIZE; ngx_value=$ngx_size; . auto/types/value
-ngx_param=NGX_TIME_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
-ngx_param=NGX_MAX_TIME_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
+ngx_type="time_t"; . $NGX_AUTO/types/sizeof
+ngx_param=NGX_TIME_T_SIZE; ngx_value=$ngx_size; . $NGX_AUTO/types/value
+ngx_param=NGX_TIME_T_LEN; ngx_value=$ngx_max_len; . $NGX_AUTO/types/value
+ngx_param=NGX_MAX_TIME_T_VALUE; ngx_value=$ngx_max_value; . $NGX_AUTO/types/value
 
 
 # syscalls, libc calls and some features
@@ -553,7 +553,7 @@
     ngx_feature_libs=
     ngx_feature_test="struct sockaddr_in6  sin6;
                       sin6.sin6_family = AF_INET6;"
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -564,7 +564,7 @@
 ngx_feature_path=
 ngx_feature_libs=$NGX_SETPROCTITLE_LIB
 ngx_feature_test="setproctitle(\"test\");"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="pread()"
@@ -575,7 +575,7 @@
 ngx_feature_libs=
 ngx_feature_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0);
                   if (n == -1) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="pwrite()"
@@ -586,7 +586,7 @@
 ngx_feature_libs=
 ngx_feature_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0);
                   if (n == -1) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="sys_nerr"
@@ -597,7 +597,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test='printf("%d", sys_nerr);'
-. auto/feature
+. $NGX_AUTO/feature
 
 
 if [ $ngx_found = no ]; then
@@ -611,7 +611,7 @@
     ngx_feature_path=
     ngx_feature_libs=
     ngx_feature_test='printf("%d", _sys_nerr);'
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -639,7 +639,7 @@
                           }
                       }
                       printf("%d", n);'
-    . auto/feature
+    . $NGX_AUTO/feature
 fi
 
 
@@ -650,7 +650,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="posix_memalign()"
@@ -661,7 +661,7 @@
 ngx_feature_libs=
 ngx_feature_test="void *p; int n; n = posix_memalign(&p, 4096, 4096);
                   if (n != 0) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="memalign()"
@@ -673,7 +673,7 @@
 ngx_feature_libs=
 ngx_feature_test="void *p; p = memalign(4096, 4096);
                   if (p == NULL) return 1"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
@@ -686,7 +686,7 @@
                   p = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
                            MAP_ANON|MAP_SHARED, -1, 0);
                   if (p == MAP_FAILED) return 1;"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature='mmap("/dev/zero", MAP_SHARED)'
@@ -701,7 +701,7 @@
                   fd = open("/dev/zero", O_RDWR);
                   p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
                   if (p == MAP_FAILED) return 1;'
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="System V shared memory"
@@ -715,7 +715,7 @@
                   id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
                   if (id == -1) return 1;
                   shmctl(id, IPC_RMID, NULL);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="POSIX semaphores"
@@ -727,7 +727,7 @@
 ngx_feature_test="sem_t  sem;
                   if (sem_init(&sem, 1, 0) == -1) return 1;
                   sem_destroy(&sem);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 if [ $ngx_found = no ]; then
@@ -735,7 +735,7 @@
     # Linux has POSIX semaphores in libpthread
     ngx_feature="POSIX semaphores in libpthread"
     ngx_feature_libs=-lpthread
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = yes ]; then
         CORE_LIBS="$CORE_LIBS -lpthread"
@@ -748,7 +748,7 @@
     # Solaris has POSIX semaphores in librt
     ngx_feature="POSIX semaphores in librt"
     ngx_feature_libs=-lrt
-    . auto/feature
+    . $NGX_AUTO/feature
 
     if [ $ngx_found = yes ]; then
         CORE_LIBS="$CORE_LIBS -lrt"
@@ -765,7 +765,7 @@
 ngx_feature_libs=
 ngx_feature_test="struct msghdr  msg;
                   printf(\"%d\", (int) sizeof(msg.msg_control))"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="ioctl(FIONBIO)"
@@ -777,7 +777,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="int i = FIONBIO; printf(\"%d\", i)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="struct tm.tm_gmtoff"
@@ -789,7 +789,7 @@
 ngx_feature_libs=
 ngx_feature_test="struct tm  tm; tm.tm_gmtoff = 0;
                   printf(\"%d\", (int) tm.tm_gmtoff)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="struct dirent.d_namlen"
@@ -801,7 +801,7 @@
 ngx_feature_libs=
 ngx_feature_test="struct dirent  dir; dir.d_namlen = 0;
                   printf(\"%d\", (int) dir.d_namlen)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="struct dirent.d_type"
@@ -813,7 +813,7 @@
 ngx_feature_libs=
 ngx_feature_test="struct dirent  dir; dir.d_type = DT_REG;
                   printf(\"%d\", (int) dir.d_type)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="sysconf(_SC_NPROCESSORS_ONLN)"
@@ -823,7 +823,7 @@
 ngx_feature_path=
 ngx_feature_libs=
 ngx_feature_test="sysconf(_SC_NPROCESSORS_ONLN)"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="openat(), fstatat()"
@@ -837,7 +837,7 @@
 ngx_feature_test="struct stat sb;
                   openat(AT_FDCWD, \".\", O_RDONLY|O_NOFOLLOW);
                   fstatat(AT_FDCWD, \".\", &sb, AT_SYMLINK_NOFOLLOW);"
-. auto/feature
+. $NGX_AUTO/feature
 
 
 ngx_feature="getaddrinfo()"
@@ -851,4 +851,4 @@
 ngx_feature_test='struct addrinfo *res;
                   if (getaddrinfo("localhost", NULL, NULL, &res) != 0) return 1;
                   freeaddrinfo(res)'
-. auto/feature
+. $NGX_AUTO/feature