[PATCH] Configure: don't test alternatives if preferred feature is found

Piotr Sikora piotrsikora at google.com
Thu Jun 30 19:52:11 UTC 2016


# HG changeset patch
# User Piotr Sikora <piotrsikora at google.com>
# Date 1467064812 25200
#      Mon Jun 27 15:00:12 2016 -0700
# Node ID 33d0b463aa3484428a30d838f6c58d8fe717746b
# Parent  d452cb27639f714bc43b7f3ede417e3e7f8efdd6
Configure: don't test alternatives if preferred feature is found.

Signed-off-by: Piotr Sikora <piotrsikora at google.com>

diff -r d452cb27639f -r 33d0b463aa34 auto/cc/conf
--- a/auto/cc/conf
+++ b/auto/cc/conf
@@ -197,6 +197,7 @@ if [ "$NGX_PLATFORM" != win32 ]; then
 
     if [ "$NGX_CC_NAME" = "ccc" ]; then
         echo "checking for C99 variadic macros ... disabled"
+        ngx_found=no
     else
         ngx_feature="C99 variadic macros"
         ngx_feature_name="NGX_HAVE_C99_VARIADIC_MACROS"
@@ -209,20 +210,24 @@ if [ "$NGX_PLATFORM" != win32 ]; then
                           var(0, buf, \"%d\", 1);
                           if (buf[0] != '1') return 1"
         . auto/feature
-     fi
+    fi
 
 
-    ngx_feature="gcc variadic macros"
-    ngx_feature_name="NGX_HAVE_GCC_VARIADIC_MACROS"
-    ngx_feature_run=yes
-    ngx_feature_incs="#include <stdio.h>
+    if [ $ngx_found = no ]; then
+
+        ngx_feature="gcc variadic macros"
+        ngx_feature_name="NGX_HAVE_GCC_VARIADIC_MACROS"
+        ngx_feature_run=yes
+        ngx_feature_incs="#include <stdio.h>
 #define var(dummy, args...)  sprintf(args)"
-    ngx_feature_path=
-    ngx_feature_libs=
-    ngx_feature_test="char  buf[30]; buf[0] = '0';
-                      var(0, buf, \"%d\", 1);
-                      if (buf[0] != '1') return 1"
-    . auto/feature
+        ngx_feature_path=
+        ngx_feature_libs=
+        ngx_feature_test="char  buf[30]; buf[0] = '0';
+                          var(0, buf, \"%d\", 1);
+                          if (buf[0] != '1') return 1"
+        . auto/feature
+
+    fi
 
 
     ngx_feature="gcc builtin 64 bit byteswap"
diff -r d452cb27639f -r 33d0b463aa34 auto/unix
--- a/auto/unix
+++ b/auto/unix
@@ -184,14 +184,18 @@ ngx_feature_test="fcntl(0, F_READAHEAD, 
 . auto/feature
 
 
-ngx_feature="posix_fadvise()"
-ngx_feature_name="NGX_HAVE_POSIX_FADVISE"
-ngx_feature_run=no
-ngx_feature_incs="#include <fcntl.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test="posix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL);"
-. auto/feature
+if [ $ngx_found = no ]; then
+
+    ngx_feature="posix_fadvise()"
+    ngx_feature_name="NGX_HAVE_POSIX_FADVISE"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <fcntl.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test="posix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL);"
+    . auto/feature
+
+fi
 
 
 ngx_feature="O_DIRECT"
@@ -208,25 +212,34 @@ if [ $ngx_found = yes -a "$NGX_SYSTEM" =
     have=NGX_HAVE_ALIGNED_DIRECTIO . auto/have
 fi
 
-ngx_feature="F_NOCACHE"
-ngx_feature_name="NGX_HAVE_F_NOCACHE"
-ngx_feature_run=no
-ngx_feature_incs="#include <fcntl.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test="fcntl(0, F_NOCACHE, 1);"
-. auto/feature
 
+if [ $ngx_found = no ]; then
 
-ngx_feature="directio()"
-ngx_feature_name="NGX_HAVE_DIRECTIO"
-ngx_feature_run=no
-ngx_feature_incs="#include <sys/types.h>
-                  #include <sys/fcntl.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test="directio(0, DIRECTIO_ON);"
-. auto/feature
+    ngx_feature="F_NOCACHE"
+    ngx_feature_name="NGX_HAVE_F_NOCACHE"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <fcntl.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test="fcntl(0, F_NOCACHE, 1);"
+    . auto/feature
+
+fi
+
+
+if [ $ngx_found = no ]; then
+
+    ngx_feature="directio()"
+    ngx_feature_name="NGX_HAVE_DIRECTIO"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <sys/types.h>
+                      #include <sys/fcntl.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test="directio(0, DIRECTIO_ON);"
+    . auto/feature
+
+fi
 
 
 ngx_feature="statfs()"
@@ -242,16 +255,20 @@ ngx_feature_test="struct statfs  fs;
 . auto/feature
 
 
-ngx_feature="statvfs()"
-ngx_feature_name="NGX_HAVE_STATVFS"
-ngx_feature_run=no
-ngx_feature_incs="#include <sys/types.h>
-                  #include <sys/statvfs.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test="struct statvfs  fs;
-                  statvfs(\".\", &fs);"
-. auto/feature
+if [ $ngx_found = no ]; then
+
+    ngx_feature="statvfs()"
+    ngx_feature_name="NGX_HAVE_STATVFS"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <sys/types.h>
+                      #include <sys/statvfs.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test="struct statvfs  fs;
+                      statvfs(\".\", &fs);"
+    . auto/feature
+
+fi
 
 
 ngx_feature="dlopen()"
@@ -341,6 +358,40 @@ ngx_feature_test="setsockopt(0, SOL_SOCK
 . auto/feature
 
 
+# Linux transparent proxying
+
+if [ $ngx_found = no ]; then
+
+    ngx_feature="IP_TRANSPARENT"
+    ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <sys/socket.h>
+                      #include <netinet/in.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_TRANSPARENT, NULL, 0)"
+    . auto/feature
+
+fi
+
+
+# FreeBSD bind to any address for transparent proxying
+
+if [ $ngx_found = no ]; then
+
+    ngx_feature="IP_BINDANY"
+    ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <sys/socket.h>
+                      #include <netinet/in.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_BINDANY, NULL, 0)"
+    . auto/feature
+
+fi
+
+
 # Linux IP_BIND_ADDRESS_NO_PORT
 
 ngx_feature="IP_BIND_ADDRESS_NO_PORT"
@@ -354,32 +405,6 @@ ngx_feature_test="setsockopt(0, IPPROTO_
 . auto/feature
 
 
-# Linux transparent proxying
-
-ngx_feature="IP_TRANSPARENT"
-ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
-ngx_feature_run=no
-ngx_feature_incs="#include <sys/socket.h>
-                  #include <netinet/in.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_TRANSPARENT, NULL, 0)"
-. auto/feature
-
-
-# FreeBSD bind to any address for transparent proxying
-
-ngx_feature="IP_BINDANY"
-ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
-ngx_feature_run=no
-ngx_feature_incs="#include <sys/socket.h>
-                  #include <netinet/in.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_BINDANY, NULL, 0)"
-. auto/feature
-
-
 # BSD way to get IPv4 datagram destination address
 
 ngx_feature="IP_RECVDSTADDR"
@@ -395,15 +420,19 @@ ngx_feature_test="setsockopt(0, IPPROTO_
 
 # Linux way to get IPv4 datagram destination address
 
-ngx_feature="IP_PKTINFO"
-ngx_feature_name="NGX_HAVE_IP_PKTINFO"
-ngx_feature_run=no
-ngx_feature_incs="#include <sys/socket.h>
-                  #include <netinet/in.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_PKTINFO, NULL, 0)"
-. auto/feature
+if [ $ngx_found = no ]; then
+
+    ngx_feature="IP_PKTINFO"
+    ngx_feature_name="NGX_HAVE_IP_PKTINFO"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <sys/socket.h>
+                      #include <netinet/in.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_PKTINFO, NULL, 0)"
+    . auto/feature
+
+fi
 
 
 # RFC 3542 way to get IPv6 datagram destination address
@@ -772,16 +801,20 @@ ngx_feature_test="void *p; int n; n = po
 . auto/feature
 
 
-ngx_feature="memalign()"
-ngx_feature_name="NGX_HAVE_MEMALIGN"
-ngx_feature_run=no
-ngx_feature_incs="#include <stdlib.h>
-                  #include <malloc.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test="void *p; p = memalign(4096, 4096);
-                  if (p == NULL) return 1"
-. auto/feature
+if [ $ngx_found = no ]; then
+
+    ngx_feature="memalign()"
+    ngx_feature_name="NGX_HAVE_MEMALIGN"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <stdlib.h>
+                      #include <malloc.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test="void *p; p = memalign(4096, 4096);
+                      if (p == NULL) return 1"
+    . auto/feature
+
+fi
 
 
 ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
@@ -797,33 +830,42 @@ ngx_feature_test="void *p;
 . auto/feature
 
 
-ngx_feature='mmap("/dev/zero", MAP_SHARED)'
-ngx_feature_name="NGX_HAVE_MAP_DEVZERO"
-ngx_feature_run=yes
-ngx_feature_incs="#include <sys/mman.h>
-                  #include <sys/stat.h>
-                  #include <fcntl.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test='void *p; int  fd;
-                  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
+if [ $ngx_found = no ]; then
 
+    ngx_feature='mmap("/dev/zero", MAP_SHARED)'
+    ngx_feature_name="NGX_HAVE_MAP_DEVZERO"
+    ngx_feature_run=yes
+    ngx_feature_incs="#include <sys/mman.h>
+                      #include <sys/stat.h>
+                      #include <fcntl.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test='void *p; int  fd;
+                      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_feature="System V shared memory"
-ngx_feature_name="NGX_HAVE_SYSVSHM"
-ngx_feature_run=yes
-ngx_feature_incs="#include <sys/ipc.h>
-                  #include <sys/shm.h>"
-ngx_feature_path=
-ngx_feature_libs=
-ngx_feature_test="int  id;
-                  id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
-                  if (id == -1) return 1;
-                  shmctl(id, IPC_RMID, NULL);"
-. auto/feature
+fi
+
+
+if [ $ngx_found = no ]; then
+
+    ngx_feature="System V shared memory"
+    ngx_feature_name="NGX_HAVE_SYSVSHM"
+    ngx_feature_run=yes
+    ngx_feature_incs="#include <sys/ipc.h>
+                      #include <sys/shm.h>"
+    ngx_feature_path=
+    ngx_feature_libs=
+    ngx_feature_test="int  id;
+                      id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
+                      if (id == -1) return 1;
+                      shmctl(id, IPC_RMID, NULL);"
+    . auto/feature
+
+fi
 
 
 ngx_feature="POSIX semaphores"
diff -r d452cb27639f -r 33d0b463aa34 src/os/unix/ngx_files.c
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -805,7 +805,7 @@ ngx_unlock_fd(ngx_fd_t fd)
 }
 
 
-#if (NGX_HAVE_POSIX_FADVISE) && !(NGX_HAVE_F_READAHEAD)
+#if (NGX_HAVE_POSIX_FADVISE)
 
 ngx_int_t
 ngx_read_ahead(ngx_fd_t fd, size_t n)



More information about the nginx-devel mailing list