changeset 2010:bd6cc5370fc1

simplify library autoconfigure
author Igor Sysoev <igor@sysoev.ru>
date Fri, 16 May 2008 14:32:58 +0000
parents df5ae577fab5
children b56d4b1ebac7
files auto/lib/conf auto/lib/md5/conf auto/lib/pcre/conf auto/lib/sha1/conf auto/summary
diffstat 5 files changed, 92 insertions(+), 174 deletions(-) [+]
line wrap: on
line diff
--- a/auto/lib/conf
+++ b/auto/lib/conf
@@ -16,6 +16,7 @@ if [ $USE_MD5 = YES ]; then
         have=NGX_HAVE_OPENSSL_MD5_H . auto/have
         have=NGX_OPENSSL_MD5 . auto/have
         MD5=YES
+        MD5_LIB=OpenSSL
 
     else
         . auto/lib/md5/conf
@@ -28,6 +29,7 @@ if [ $USE_SHA1 = YES ]; then
     if [ $OPENSSL != NONE -a $OPENSSL != NO ]; then
         have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
         SHA1=YES
+        SHA1_LIB=OpenSSL
 
     else
         . auto/lib/sha1/conf
--- a/auto/lib/md5/conf
+++ b/auto/lib/md5/conf
@@ -45,6 +45,7 @@ if [ $MD5 != NONE ]; then
 else
 
     if [ "$NGX_PLATFORM" != win32 ]; then
+
         MD5=NO
 
         # Solaris 8/9
@@ -58,55 +59,43 @@ else
         ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
         . auto/feature
 
-        if [ $ngx_found = yes ]; then
-            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
-            MD5=YES
-            MD5_LIB=md5
-            ngx_found=no
+        ngx_md5_lib="system md5"
 
-        else
+        if [ $ngx_found = no ]; then
+
             # FreeBSD
 
             ngx_feature="rsaref md library"
-            ngx_feature_name=
-            ngx_feature_run=no
-            ngx_feature_incs="#include <md5.h>"
-            ngx_feature_path=
             ngx_feature_libs="-lmd"
-            ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
             . auto/feature
+
+            ngx_md5_lib="system md"
         fi
 
+        if [ $ngx_found = no ]; then
+
+            # OpenSSL crypto library
+
+            ngx_feature="OpenSSL md5 crypto library"
+            ngx_feature_name="NGX_OPENSSL_MD5"
+            ngx_feature_incs="#include <openssl/md5.h>"
+            ngx_feature_libs="-lcrypto"
+            ngx_feature_test="MD5_CTX md5; MD5_Init(&md5)"
+            . auto/feature
+
+            ngx_md5_lib="system crypto"
+
+            if [ $ngx_found = yes ]; then
+                have=NGX_HAVE_OPENSSL_MD5_H . auto/have
+            fi
+        fi
 
         if [ $ngx_found = yes ]; then
             CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
             MD5=YES
-            MD5_LIB=md
-            ngx_found=no
-
-        else
-            if [ $MD5 = NO ]; then
-
-                # OpenSSL crypto library
-
-                ngx_feature="OpenSSL md5 crypto library"
-                ngx_feature_name="NGX_OPENSSL_MD5"
-                ngx_feature_run=no
-                ngx_feature_incs="#include <openssl/md5.h>"
-                ngx_feature_path=
-                ngx_feature_libs="-lcrypto"
-                ngx_feature_test="MD5_CTX md5; MD5_Init(&md5)"
-                . auto/feature
-            fi
+            MD5_LIB=$ngx_md5_lib
         fi
 
-
-        if [ $ngx_found = yes ]; then
-            have=NGX_HAVE_OPENSSL_MD5_H . auto/have
-            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
-            MD5=YES
-            MD5_LIB=crypto
-        fi
     fi
 
 fi
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -84,6 +84,7 @@ if [ $PCRE != NONE ]; then
 else
 
     if [ "$NGX_PLATFORM" != win32 ]; then
+
         PCRE=NO
 
         ngx_feature="PCRE library"
@@ -95,20 +96,11 @@ else
         ngx_feature_test="pcre *re; re = pcre_compile(NULL, 0, NULL, 0, NULL)"
         . auto/feature
 
-        if [ $ngx_found = yes ]; then
-            CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
-            CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
-            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
-            PCRE=YES
-            ngx_found=no
+        if [ $ngx_found = no ]; then
 
-        else
             # FreeBSD port
 
             ngx_feature="PCRE library in /usr/local/"
-            ngx_feature_name="NGX_PCRE"
-            ngx_feature_run=no
-            ngx_feature_incs="#include <pcre.h>"
             ngx_feature_path="/usr/local/include"
 
             if [ $NGX_RPATH = YES ]; then
@@ -117,8 +109,49 @@ else
                 ngx_feature_libs="-L/usr/local/lib -lpcre"
             fi
 
-            ngx_feature_test="pcre *re;
-                              re = pcre_compile(NULL, 0, NULL, 0, NULL)"
+            . auto/feature
+        fi
+
+        if [ $ngx_found = no ]; then
+
+            # Linux package
+
+            ngx_feature="PCRE library in /usr/include/pcre/"
+            ngx_feature_path="/usr/include/pcre"
+            ngx_feature_libs="-lpcre"
+
+            . auto/feature
+        fi
+
+        if [ $ngx_found = no ]; then
+
+            # NetBSD port
+
+            ngx_feature="PCRE library in /usr/pkg/"
+            ngx_feature_path="/usr/pkg/include"
+
+            if [ $NGX_RPATH = YES ]; then
+                ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lpcre"
+            else
+                ngx_feature_libs="-L/usr/pkg/lib -lpcre"
+            fi
+
+            . auto/feature
+        fi
+
+        if [ $ngx_found = no ]; then
+
+            # MacPorts
+
+            ngx_feature="PCRE 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 -lpcre"
+            else
+                ngx_feature_libs="-L/opt/local/lib -lpcre"
+            fi
+
             . auto/feature
         fi
 
@@ -128,94 +161,6 @@ else
             CORE_INCS="$CORE_INCS $ngx_feature_path"
             CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
             PCRE=YES
-            ngx_found=no
-
-        else
-            # Linux package
-
-            if [ $PCRE = NO ]; then
-
-                ngx_feature="PCRE library in /usr/include/pcre/"
-                ngx_feature_name="NGX_PCRE"
-                ngx_feature_run=no
-                ngx_feature_incs="#include <pcre.h>"
-                ngx_feature_path="/usr/include/pcre"
-                ngx_feature_libs="-lpcre"
-                ngx_feature_test="pcre *re;
-                                  re = pcre_compile(NULL, 0, NULL, 0, NULL)"
-                . auto/feature
-            fi
-        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
-            ngx_found=no
-
-        else
-            # NetBSD port
-
-            if [ $PCRE = NO ]; then
-
-                ngx_feature="PCRE library in /usr/pkg/"
-                ngx_feature_name="NGX_PCRE"
-                ngx_feature_run=no
-                ngx_feature_incs="#include <pcre.h>"
-                ngx_feature_path="/usr/pkg/include"
-
-                if [ $NGX_RPATH = YES ]; then
-                    ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lpcre"
-                else
-                    ngx_feature_libs="-L/usr/pkg/lib -lpcre"
-                fi
-
-                ngx_feature_test="pcre *re;
-                                  re = pcre_compile(NULL, 0, NULL, 0, NULL)"
-                . auto/feature
-            fi
-        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
-            ngx_found=no
-
-        else
-            # MacPorts
-
-            if [ $PCRE = NO ]; then
-
-                ngx_feature="PCRE library in /opt/local/"
-                ngx_feature_name="NGX_PCRE"
-                ngx_feature_run=no
-                ngx_feature_incs="#include <pcre.h>"
-                ngx_feature_path="/opt/local/include"
-
-                if [ $NGX_RPATH = YES ]; then
-                    ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lpcre"
-                else
-                    ngx_feature_libs="-L/opt/local/lib -lpcre"
-                fi
-
-                ngx_feature_test="pcre *re;
-                                  re = pcre_compile(NULL, 0, NULL, 0, NULL)"
-                . auto/feature
-            fi
-        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
-            ngx_found=no
         fi
 
     fi
--- a/auto/lib/sha1/conf
+++ b/auto/lib/sha1/conf
@@ -35,6 +35,7 @@ if [ $SHA1 != NONE ]; then
 else
 
     if [ "$NGX_PLATFORM" != win32 ]; then
+
         SHA1=NO
 
         # FreeBSD
@@ -48,35 +49,28 @@ else
         ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
         . auto/feature
 
+        ngx_sha1_lib="system md"
+
+        if [ $ngx_found = no ]; then
+
+            # OpenSSL crypto library
+
+            ngx_feature="OpenSSL sha1 crypto library"
+            ngx_feature_incs="#include <openssl/sha.h>"
+            ngx_feature_libs="-lcrypto"
+            . auto/feature
+
+            ngx_sha1_lib="system crypto"
+
+            if [ $ngx_found = yes ]; then
+                have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
+            fi
+        fi
 
         if [ $ngx_found = yes ]; then
             CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
             SHA1=YES
-            SHA1_LIB=md
-            ngx_found=no
-
-        else
-            if [ $SHA1 = NO ]; then
-
-                # OpenSSL crypto library
-
-                ngx_feature="OpenSSL sha1 crypto library"
-                ngx_feature_name=
-                ngx_feature_run=no
-                ngx_feature_incs="#include <openssl/sha.h>"
-                ngx_feature_path=
-                ngx_feature_libs="-lcrypto"
-                ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)"
-                . auto/feature
-            fi
-        fi
-
-
-        if [ $ngx_found = yes ]; then
-            have=NGX_HAVE_OPENSSL_SHA1_H . auto/have
-            CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
-            SHA1=YES
-            SHA1_LIB=crypto
+            SHA1_LIB=$ngx_sha1_lib
         fi
     fi
 
--- a/auto/summary
+++ b/auto/summary
@@ -51,26 +51,14 @@ case $OPENSSL in
 esac
 
 case $MD5 in
-    YES)
-        case $OPENSSL in
-            NONE|NO)  echo "  + md5: using system $MD5_LIB library" ;;
-            *)        echo "  + md5: using OpenSSL library" ;;
-        esac
-        ;;
-
+    YES)   echo "  + md5: using $MD5_LIB library" ;;
     NONE)  echo "  + md5 library is not used" ;;
     NO)    echo "  + md5 library is not found" ;;
     *)     echo "  + using md5 library: $MD5" ;;
 esac
 
 case $SHA1 in
-    YES)
-        case $OPENSSL in
-            NONE|NO)  echo "  + sha1: using system $SHA1_LIB library" ;;
-            *)        echo "  + sha1: using OpenSSL library" ;;
-        esac
-        ;;
-
+    YES)   echo "  + sha1: using $SHA1_LIB library" ;;
     NONE)  echo "  + sha1 library is not used" ;;
     NO)    echo "  + sha1 library is not found" ;;
     *)     echo "  + using sha1 library: $SHA1" ;;