[nginx] Win32: checking for system PCRE, zlib, and OpenSSL libs.

Maxim Dounin mdounin at mdounin.ru
Mon Aug 12 03:37:05 UTC 2024


details:   http://freenginx.org/hg/nginx/rev/b40149d062cb
branches:  
changeset: 9316:b40149d062cb
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Wed Aug 07 03:58:50 2024 +0300
description:
Win32: checking for system PCRE, zlib, and OpenSSL libs.

Checking for system libs on Windows is beneficial when compiling in
MSYS2 environments with GCC or Clang, as most libraries are readily
available.

diffstat:

 auto/lib/openssl/conf |  153 ++++++++++++++++++++++++-------------------------
 auto/lib/pcre/conf    |    6 +-
 auto/lib/zlib/conf    |   30 ++++-----
 3 files changed, 91 insertions(+), 98 deletions(-)

diffs (245 lines):

diff --git a/auto/lib/openssl/conf b/auto/lib/openssl/conf
--- a/auto/lib/openssl/conf
+++ b/auto/lib/openssl/conf
@@ -55,96 +55,94 @@ if [ $OPENSSL != NONE ]; then
 
 else
 
-    if [ "$NGX_PLATFORM" != win32 ]; then
-
-        OPENSSL=NO
+    OPENSSL=NO
 
-        ngx_feature="OpenSSL library"
-        ngx_feature_name="NGX_OPENSSL"
-        ngx_feature_run=no
-        ngx_feature_incs="#include <openssl/ssl.h>"
-        ngx_feature_path=
-        ngx_feature_libs="-lssl -lcrypto $NGX_LIBDL $NGX_LIBPTHREAD"
-        ngx_feature_test="SSL_CTX_set_options(NULL, 0)"
-        . auto/feature
+    ngx_feature="OpenSSL library"
+    ngx_feature_name="NGX_OPENSSL"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <openssl/ssl.h>"
+    ngx_feature_path=
+    ngx_feature_libs="-lssl -lcrypto $NGX_LIBDL $NGX_LIBPTHREAD"
+    ngx_feature_test="SSL_CTX_set_options(NULL, 0)"
+    . auto/feature
 
-        if [ $ngx_found = no ]; then
+    if [ $ngx_found = no ]; then
+
+        # FreeBSD port
+
+        ngx_feature="OpenSSL library in /usr/local/"
+        ngx_feature_path="/usr/local/include"
 
-            # FreeBSD port
+        if [ $NGX_RPATH = YES ]; then
+            ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lssl -lcrypto"
+        else
+            ngx_feature_libs="-L/usr/local/lib -lssl -lcrypto"
+        fi
 
-            ngx_feature="OpenSSL library in /usr/local/"
-            ngx_feature_path="/usr/local/include"
+        ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD"
+
+        . auto/feature
+    fi
 
-            if [ $NGX_RPATH = YES ]; then
-                ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lssl -lcrypto"
-            else
-                ngx_feature_libs="-L/usr/local/lib -lssl -lcrypto"
-            fi
+    if [ $ngx_found = no ]; then
+
+        # NetBSD port
 
-            ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD"
+        ngx_feature="OpenSSL library in /usr/pkg/"
+        ngx_feature_path="/usr/pkg/include"
 
-            . auto/feature
+        if [ $NGX_RPATH = YES ]; then
+            ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lssl -lcrypto"
+        else
+            ngx_feature_libs="-L/usr/pkg/lib -lssl -lcrypto"
         fi
 
-        if [ $ngx_found = no ]; then
+        ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD"
+
+        . auto/feature
+    fi
+
+    if [ $ngx_found = no ]; then
+
+        # MacPorts
 
-            # NetBSD port
+        ngx_feature="OpenSSL library in /opt/local/"
+        ngx_feature_path="/opt/local/include"
+
+        if [ $NGX_RPATH = YES ]; then
+            ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lssl -lcrypto"
+        else
+            ngx_feature_libs="-L/opt/local/lib -lssl -lcrypto"
+        fi
+
+        ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD"
 
-            ngx_feature="OpenSSL library in /usr/pkg/"
-            ngx_feature_path="/usr/pkg/include"
+        . auto/feature
+    fi
+
+    if [ $ngx_found = yes ]; then
+        have=NGX_SSL . auto/have
+        CORE_INCS="$CORE_INCS $ngx_feature_path"
+        CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+        OPENSSL=YES
+
+        if [ $USE_OPENSSL_QUIC = YES ]; then
 
-            if [ $NGX_RPATH = YES ]; then
-                ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lssl -lcrypto"
-            else
-                ngx_feature_libs="-L/usr/pkg/lib -lssl -lcrypto"
+            ngx_feature="OpenSSL QUIC support"
+            ngx_feature_name="NGX_QUIC"
+            ngx_feature_test="SSL_set_quic_method(NULL, NULL)"
+            . auto/feature
+
+            if [ $ngx_found = no ]; then
+                have=NGX_QUIC_OPENSSL_COMPAT . auto/have
+
+                ngx_feature="OpenSSL QUIC compatibility"
+                ngx_feature_test="SSL_CTX_add_custom_ext(NULL, 0, 0,
+                                             NULL, NULL, NULL, NULL, NULL)"
+                . auto/feature
             fi
 
-            ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD"
-
-            . auto/feature
-        fi
-
-        if [ $ngx_found = no ]; then
-
-            # MacPorts
-
-            ngx_feature="OpenSSL library in /opt/local/"
-            ngx_feature_path="/opt/local/include"
-
-            if [ $NGX_RPATH = YES ]; then
-                ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lssl -lcrypto"
-            else
-                ngx_feature_libs="-L/opt/local/lib -lssl -lcrypto"
-            fi
-
-            ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD"
-
-            . auto/feature
-        fi
-
-        if [ $ngx_found = yes ]; then
-            have=NGX_SSL . auto/have
-            CORE_INCS="$CORE_INCS $ngx_feature_path"
-            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
-            OPENSSL=YES
-
-            if [ $USE_OPENSSL_QUIC = YES ]; then
-
-                ngx_feature="OpenSSL QUIC support"
-                ngx_feature_name="NGX_QUIC"
-                ngx_feature_test="SSL_set_quic_method(NULL, NULL)"
-                . auto/feature
-
-                if [ $ngx_found = no ]; then
-                    have=NGX_QUIC_OPENSSL_COMPAT . auto/have
-
-                    ngx_feature="OpenSSL QUIC compatibility"
-                    ngx_feature_test="SSL_CTX_add_custom_ext(NULL, 0, 0,
-                                                 NULL, NULL, NULL, NULL, NULL)"
-                    . auto/feature
-                fi
-
-                if [ $ngx_found = no ]; then
+            if [ $ngx_found = no ]; then
 cat << END
 
 $0: error: certain modules require OpenSSL QUIC support.
@@ -153,8 +151,7 @@ QUIC support into the system, or build t
 statically from the source with nginx by using --with-openssl=<path> option.
 
 END
-                        exit 1
-                fi
+                exit 1
             fi
         fi
     fi
diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -68,11 +68,9 @@ if [ $PCRE != NONE ]; then
 
 else
 
-    if [ "$NGX_PLATFORM" != win32 ]; then
-        PCRE=NO
-    fi
+    PCRE=NO
 
-    if [ $PCRE = NO -a $PCRE2 != DISABLED ]; then
+    if [ $PCRE2 != DISABLED ]; then
 
         ngx_feature="PCRE2 library"
         ngx_feature_name="NGX_PCRE2"
diff --git a/auto/lib/zlib/conf b/auto/lib/zlib/conf
--- a/auto/lib/zlib/conf
+++ b/auto/lib/zlib/conf
@@ -42,26 +42,24 @@ if [ $ZLIB != NONE ]; then
 
 else
 
-    if [ "$NGX_PLATFORM" != win32 ]; then
-        ZLIB=NO
+    ZLIB=NO
 
-        # FreeBSD, Solaris, Linux
+    # FreeBSD, Solaris, Linux
 
-        ngx_feature="zlib library"
-        ngx_feature_name="NGX_ZLIB"
-        ngx_feature_run=no
-        ngx_feature_incs="#include <zlib.h>"
-        ngx_feature_path=
-        ngx_feature_libs="-lz"
-        ngx_feature_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
-        . auto/feature
+    ngx_feature="zlib library"
+    ngx_feature_name="NGX_ZLIB"
+    ngx_feature_run=no
+    ngx_feature_incs="#include <zlib.h>"
+    ngx_feature_path=
+    ngx_feature_libs="-lz"
+    ngx_feature_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
+    . auto/feature
 
 
-        if [ $ngx_found = yes ]; then
-            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
-            ZLIB=YES
-            ngx_found=no
-        fi
+    if [ $ngx_found = yes ]; then
+        CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+        ZLIB=YES
+        ngx_found=no
     fi
 
     if [ $ZLIB != YES ]; then


More information about the nginx-devel mailing list