Skip to content

Commit 15ed8d1

Browse files
authored
Merge pull request #7 from cdoco/develop
Modify the config.m4
2 parents d6a0f62 + c1ad138 commit 15ed8d1

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

config.m4

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
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+
if test -r $i/$SEARCH_FOR; then
17+
OPENSSL_DIR=$i
18+
AC_MSG_RESULT(found in $i)
19+
fi
20+
done
3421
fi
3522

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

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

0 commit comments

Comments
 (0)