1From 4ba4b1e0bd1b69e124eb34c95ae9e7c087370efa Mon Sep 17 00:00:00 2001 2From: Martin Bark <martin@barkynet.com> 3Date: Fri, 6 May 2016 14:48:31 +0100 4Subject: [PATCH] auto/lib/openssl/conf: use pkg-config 5 6Change to using pkg-config to find the path to openssl and its 7dependencies. 8 9Signed-off-by: Martin Bark <martin@barkynet.com> 10--- 11 auto/lib/openssl/conf | 187 +++++++++++++++++++++--------------------- 12 1 file changed, 94 insertions(+), 93 deletions(-) 13 14diff --git a/auto/lib/openssl/conf b/auto/lib/openssl/conf 15index 4fb52df7..9f30490d 100644 16--- a/auto/lib/openssl/conf 17+++ b/auto/lib/openssl/conf 18@@ -1,4 +1,3 @@ 19- 20 # Copyright (C) Igor Sysoev 21 # Copyright (C) Nginx, Inc. 22 23@@ -7,123 +6,125 @@ if [ $OPENSSL != NONE ]; then 24 25 case "$CC" in 26 27- cl | bcc32) 28- have=NGX_OPENSSL . auto/have 29- have=NGX_SSL . auto/have 30- 31- CFLAGS="$CFLAGS -DNO_SYS_TYPES_H" 32- 33- CORE_INCS="$CORE_INCS $OPENSSL/openssl/include" 34- CORE_DEPS="$CORE_DEPS $OPENSSL/openssl/include/openssl/ssl.h" 35- 36- if [ -f $OPENSSL/ms/do_ms.bat ]; then 37- # before OpenSSL 1.1.0 38- CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/ssleay32.lib" 39- CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libeay32.lib" 40- else 41- # OpenSSL 1.1.0+ 42- CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libssl.lib" 43- CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libcrypto.lib" 44- fi 45- 46- # libeay32.lib requires gdi32.lib 47- CORE_LIBS="$CORE_LIBS gdi32.lib" 48- # OpenSSL 1.0.0 requires crypt32.lib 49- CORE_LIBS="$CORE_LIBS crypt32.lib" 50- ;; 51- 52- *) 53- have=NGX_OPENSSL . auto/have 54- have=NGX_SSL . auto/have 55- 56- CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include" 57- CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h" 58- CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a" 59- CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a" 60- CORE_LIBS="$CORE_LIBS $NGX_LIBDL" 61- CORE_LIBS="$CORE_LIBS $NGX_LIBPTHREAD" 62- 63- if [ "$NGX_PLATFORM" = win32 ]; then 64- CORE_LIBS="$CORE_LIBS -lgdi32 -lcrypt32 -lws2_32" 65- fi 66- ;; 67+ cl | bcc32) 68+ have=NGX_OPENSSL . auto/have 69+ have=NGX_SSL . auto/have 70+ 71+ CFLAGS="$CFLAGS -DNO_SYS_TYPES_H" 72+ 73+ CORE_INCS="$CORE_INCS $OPENSSL/openssl/include" 74+ CORE_DEPS="$CORE_DEPS $OPENSSL/openssl/include/openssl/ssl.h" 75+ 76+ if [ -f $OPENSSL/ms/do_ms.bat ]; then 77+ # before OpenSSL 1.1.0 78+ CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/ssleay32.lib" 79+ CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libeay32.lib" 80+ else 81+ # OpenSSL 1.1.0+ 82+ CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libssl.lib" 83+ CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libcrypto.lib" 84+ fi 85+ 86+ # libeay32.lib requires gdi32.lib 87+ CORE_LIBS="$CORE_LIBS gdi32.lib" 88+ # OpenSSL 1.0.0 requires crypt32.lib 89+ CORE_LIBS="$CORE_LIBS crypt32.lib" 90+ ;; 91+ 92+ *) 93+ have=NGX_OPENSSL . auto/have 94+ have=NGX_SSL . auto/have 95+ 96+ CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include" 97+ CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h" 98+ CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a" 99+ CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a" 100+ CORE_LIBS="$CORE_LIBS $NGX_LIBDL" 101+ CORE_LIBS="$CORE_LIBS $NGX_LIBPTHREAD" 102+ 103+ if [ "$NGX_PLATFORM" = win32 ]; then 104+ CORE_LIBS="$CORE_LIBS -lgdi32 -lcrypt32 -lws2_32" 105+ fi 106+ ;; 107 esac 108 109 else 110 111 if [ "$NGX_PLATFORM" != win32 ]; then 112 113- OPENSSL=NO 114+ OPENSSL=NO 115 116- ngx_feature="OpenSSL library" 117- ngx_feature_name="NGX_OPENSSL" 118- ngx_feature_run=no 119- ngx_feature_incs="#include <openssl/ssl.h>" 120- ngx_feature_path= 121- ngx_feature_libs="-lssl -lcrypto $NGX_LIBDL $NGX_LIBPTHREAD" 122- ngx_feature_test="SSL_CTX_set_options(NULL, 0)" 123- . auto/feature 124+ ngx_feature="OpenSSL library" 125+ ngx_feature_name="NGX_OPENSSL" 126+ ngx_feature_run=no 127+ ngx_feature_incs="#include <openssl/ssl.h>" 128+ ngx_feature_path= 129+ ngx_feature_path="$(${PKG_CONFIG:=pkg-config} --cflags-only-I openssl| 130+ sed -re 's/(^|\s)-I\s*(\S+)/\1\2/g')" 131+ ngx_feature_libs="$(${PKG_CONFIG:=pkg-config} --libs openssl)" 132+ ngx_feature_test="SSL_CTX_set_options(NULL, 0)" 133+ . auto/feature 134 135- if [ $ngx_found = no ]; then 136+ if [ $ngx_found = no ]; then 137 138- # FreeBSD port 139+ # FreeBSD port 140 141- ngx_feature="OpenSSL library in /usr/local/" 142- ngx_feature_path="/usr/local/include" 143+ ngx_feature="OpenSSL library in /usr/local/" 144+ ngx_feature_path="/usr/local/include" 145 146- if [ $NGX_RPATH = YES ]; then 147- ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lssl -lcrypto" 148- else 149- ngx_feature_libs="-L/usr/local/lib -lssl -lcrypto" 150- fi 151+ if [ $NGX_RPATH = YES ]; then 152+ ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lssl -lcrypto" 153+ else 154+ ngx_feature_libs="-L/usr/local/lib -lssl -lcrypto" 155+ fi 156 157- ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD" 158+ ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD" 159 160- . auto/feature 161- fi 162+ . auto/feature 163+ fi 164 165- if [ $ngx_found = no ]; then 166+ if [ $ngx_found = no ]; then 167 168- # NetBSD port 169+ # NetBSD port 170 171- ngx_feature="OpenSSL library in /usr/pkg/" 172- ngx_feature_path="/usr/pkg/include" 173+ ngx_feature="OpenSSL library in /usr/pkg/" 174+ ngx_feature_path="/usr/pkg/include" 175 176- if [ $NGX_RPATH = YES ]; then 177- ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lssl -lcrypto" 178- else 179- ngx_feature_libs="-L/usr/pkg/lib -lssl -lcrypto" 180- fi 181+ if [ $NGX_RPATH = YES ]; then 182+ ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lssl -lcrypto" 183+ else 184+ ngx_feature_libs="-L/usr/pkg/lib -lssl -lcrypto" 185+ fi 186 187- ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD" 188+ ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD" 189 190- . auto/feature 191- fi 192+ . auto/feature 193+ fi 194 195- if [ $ngx_found = no ]; then 196+ if [ $ngx_found = no ]; then 197 198- # MacPorts 199+ # MacPorts 200 201- ngx_feature="OpenSSL library in /opt/local/" 202- ngx_feature_path="/opt/local/include" 203+ ngx_feature="OpenSSL library in /opt/local/" 204+ ngx_feature_path="/opt/local/include" 205 206- if [ $NGX_RPATH = YES ]; then 207- ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lssl -lcrypto" 208- else 209- ngx_feature_libs="-L/opt/local/lib -lssl -lcrypto" 210- fi 211+ if [ $NGX_RPATH = YES ]; then 212+ ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lssl -lcrypto" 213+ else 214+ ngx_feature_libs="-L/opt/local/lib -lssl -lcrypto" 215+ fi 216 217- ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD" 218+ ngx_feature_libs="$ngx_feature_libs $NGX_LIBDL $NGX_LIBPTHREAD" 219 220- . auto/feature 221- fi 222+ . auto/feature 223+ fi 224 225- if [ $ngx_found = yes ]; then 226- have=NGX_SSL . auto/have 227- CORE_INCS="$CORE_INCS $ngx_feature_path" 228- CORE_LIBS="$CORE_LIBS $ngx_feature_libs" 229- OPENSSL=YES 230- fi 231+ if [ $ngx_found = yes ]; then 232+ have=NGX_SSL . auto/have 233+ CORE_INCS="$CORE_INCS $ngx_feature_path" 234+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs" 235+ OPENSSL=YES 236+ fi 237 fi 238 239 if [ $OPENSSL != YES ]; then 240@@ -136,7 +137,7 @@ into the system, or build the OpenSSL library statically from the source 241 with nginx by using --with-openssl=<path> option. 242 243 END 244- exit 1 245+ exit 1 246 fi 247 248 fi 249-- 2502.17.1 251 252