|
1 | 1 | dnl $Id$
|
2 | 2 | dnl config.m4 for extension jwt
|
3 | 3 |
|
4 |
| -PHP_ARG_ENABLE(jwt, whether to enable jwt support, |
5 |
| - [ --enable-jwt Enable jwt support]) |
6 |
| - |
7 | 4 | 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)]) |
9 | 6 |
|
10 | 7 | 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 |
31 | 8 |
|
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 |
34 | 21 | fi
|
35 | 22 |
|
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 | + ]) |
39 | 40 |
|
40 |
| -if test "$PHP_JWT" != "no"; then |
41 | 41 | PHP_SUBST(JWT_SHARED_LIBADD)
|
42 | 42 | PHP_ADD_EXTENSION_DEP(jwt, json)
|
43 | 43 | PHP_NEW_EXTENSION(jwt, jwt.c openssl.c, $ext_shared)
|
|
0 commit comments