Skip to content

Commit 40a75dd

Browse files
committed
Modify the config.m4
1 parent ea7412d commit 40a75dd

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

config.m4

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
11
dnl $Id$
22
dnl config.m4 for extension jwt
33

4-
PHP_ARG_ENABLE(jwt, whether to enable jwt support,
5-
[ --enable-jwt Enable jwt support])
6-
74
PHP_ARG_WITH(openssl, whether to use OpenSSL library,
8-
[ --with-openssl[=DIR] Ignore presence of OpenSSL library (requires OpenSSL >= 0.9.8)], no, no)
5+
[ --with-openssl[=DIR] Ignore presence of OpenSSL library (requires OpenSSL >= 0.9.8)])
96

107
if test "$PHP_OPENSSL" != "no"; then
11-
AC_CHECK_HEADERS([openssl/hmac.h openssl/evp.h])
12-
PHP_CHECK_LIBRARY(crypto, EVP_sha512,
13-
[
14-
PHP_ADD_INCLUDE($PHP_OPENSSL/include)
15-
PHP_ADD_LIBRARY_WITH_PATH(crypto, $PHP_OPENSSL/lib, JWT_SHARED_LIBADD)
16-
],
17-
[AC_MSG_ERROR(OpenSSL library not found)])
18-
else
19-
for i in /usr/local /usr/local/opt /usr; do
20-
if test -f $i/openssl/include/openssl/hmac.h; then
21-
OPENSSL_LIB=$i/openssl/lib
22-
OPENSSL_INC=$i/openssl/include
23-
elif test -f $i/ssl/include/openssl/hmac.h; then
24-
OPENSSL_LIB=$i/ssl/lib
25-
OPENSSL_INC=$i/ssl/include
26-
elif test -f $i/include/openssl/hmac.h; then
27-
OPENSSL_LIB=$i/lib64
28-
OPENSSL_INC=$i/include
29-
fi
30-
done
318

32-
if test -z "$OPENSSL_INC"; then
33-
AC_MSG_ERROR(OpenSSL library not found)
9+
SEARCH_PATH="/usr/local /usr /usr/local/opt"
10+
SEARCH_FOR="/include/openssl/hmac.h"
11+
if test -r $PHP_OPENSSL/$SEARCH_FOR; then
12+
OPENSSL_DIR=$PHP_OPENSSL
13+
else
14+
AC_MSG_CHECKING([for OpenSSL library in default path])
15+
for i in $SEARCH_PATH ; do
16+
for p in /openssl /ssl /; do
17+
if test -r $i$p/$SEARCH_FOR; then
18+
OPENSSL_DIR=$i$p
19+
AC_MSG_RESULT(found in $i$p)
20+
fi
21+
done
22+
done
3423
fi
3524

36-
PHP_ADD_INCLUDE($OPENSSL_INC)
37-
PHP_ADD_LIBRARY_WITH_PATH(crypto, $OPENSSL_LIB, JWT_SHARED_LIBADD)
38-
fi
25+
if test -z "$OPENSSL_DIR"; then
26+
AC_MSG_RESULT([OpenSSL library not found])
27+
AC_MSG_ERROR([Please reinstall the OpenSSL library])
28+
fi
29+
30+
PHP_ADD_INCLUDE($OPENSSL_DIR/include)
31+
32+
AC_CHECK_HEADERS([openssl/hmac.h openssl/evp.h])
33+
PHP_CHECK_LIBRARY(crypto, EVP_sha512,
34+
[
35+
PHP_ADD_INCLUDE($OPENSSL_DIR/include)
36+
PHP_ADD_LIBRARY_WITH_PATH(crypto, $OPENSSL_DIR/lib, JWT_SHARED_LIBADD)
37+
],[
38+
AC_MSG_ERROR(wrong OpenSSL library version)
39+
],[
40+
-L$OPENSSL_DIR/lib -lcrypto
41+
])
3942

40-
if test "$PHP_JWT" != "no"; then
4143
PHP_SUBST(JWT_SHARED_LIBADD)
4244
PHP_ADD_EXTENSION_DEP(jwt, json)
4345
PHP_NEW_EXTENSION(jwt, jwt.c openssl.c, $ext_shared)

0 commit comments

Comments
 (0)