[nginx] Configure: fixed static nginx build with OpenSSL (ticket #903).

Ruslan Ermilov ru at nginx.com
Thu Feb 18 14:43:54 UTC 2016


details:   http://hg.nginx.org/nginx/rev/e59e617f8fcb
branches:  
changeset: 6403:e59e617f8fcb
user:      Ruslan Ermilov <ru at nginx.com>
date:      Thu Feb 18 11:39:57 2016 +0300
description:
Configure: fixed static nginx build with OpenSSL (ticket #903).

Before 7142b04337d6, it was possible to build the OpenSSL library
along with nginx, and link nginx statically with this library
(--with-openssl=DIR --with-ld-opt=-static --with-http_ssl_module).
This was broken on Linux by not adding -ldl after -lcrypto.

The fix also makes it possible to link nginx statically on Linux
with the system OpenSSL library, which never worked before.

diffstat:

 auto/lib/openssl/conf |  15 ++++++++-------
 auto/unix             |   1 +
 2 files changed, 9 insertions(+), 7 deletions(-)

diffs (67 lines):

diff -r 7296b38f6416 -r e59e617f8fcb auto/lib/openssl/conf
--- a/auto/lib/openssl/conf	Thu Feb 18 13:58:49 2016 +0300
+++ b/auto/lib/openssl/conf	Thu Feb 18 11:39:57 2016 +0300
@@ -32,6 +32,7 @@ if [ $OPENSSL != NONE ]; then
             CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
             CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
             CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"
+            CORE_LIBS="$CORE_LIBS $NGX_LIBDL"
 
             if [ "$NGX_PLATFORM" = win32 ]; then
                 CORE_LIBS="$CORE_LIBS -lgdi32 -lcrypt32 -lws2_32"
@@ -50,7 +51,7 @@ else
         ngx_feature_run=no
         ngx_feature_incs="#include <openssl/ssl.h>"
         ngx_feature_path=
-        ngx_feature_libs="-lssl -lcrypto"
+        ngx_feature_libs="-lssl -lcrypto $NGX_LIBDL"
         ngx_feature_test="SSL_library_init()"
         . auto/feature
 
@@ -62,9 +63,9 @@ else
             ngx_feature_path="/usr/local/include"
 
             if [ $NGX_RPATH = YES ]; then
-                ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lssl -lcrypto"
+                ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lssl -lcrypto $NGX_LIBDL"
             else
-                ngx_feature_libs="-L/usr/local/lib -lssl -lcrypto"
+                ngx_feature_libs="-L/usr/local/lib -lssl -lcrypto $NGX_LIBDL"
             fi
 
             . auto/feature
@@ -78,9 +79,9 @@ else
             ngx_feature_path="/usr/pkg/include"
 
             if [ $NGX_RPATH = YES ]; then
-                ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lssl -lcrypto"
+                ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lssl -lcrypto $NGX_LIBDL"
             else
-                ngx_feature_libs="-L/usr/pkg/lib -lssl -lcrypto"
+                ngx_feature_libs="-L/usr/pkg/lib -lssl -lcrypto $NGX_LIBDL"
             fi
 
             . auto/feature
@@ -94,9 +95,9 @@ else
             ngx_feature_path="/opt/local/include"
 
             if [ $NGX_RPATH = YES ]; then
-                ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lssl -lcrypto"
+                ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lssl -lcrypto $NGX_LIBDL"
             else
-                ngx_feature_libs="-L/opt/local/lib -lssl -lcrypto"
+                ngx_feature_libs="-L/opt/local/lib -lssl -lcrypto $NGX_LIBDL"
             fi
 
             . auto/feature
diff -r 7296b38f6416 -r e59e617f8fcb auto/unix
--- a/auto/unix	Thu Feb 18 13:58:49 2016 +0300
+++ b/auto/unix	Thu Feb 18 11:39:57 2016 +0300
@@ -272,6 +272,7 @@ if [ $ngx_found != yes ]; then
 
     if [ $ngx_found = yes ]; then
         CORE_LIBS="$CORE_LIBS -ldl"
+        NGX_LIBDL="-ldl"
     fi
 fi
 



More information about the nginx-devel mailing list