|
1 | 1 | PHP_ARG_WITH([gmp],
|
2 | 2 | [for GNU MP support],
|
3 | 3 | [AS_HELP_STRING([[--with-gmp[=DIR]]],
|
4 |
| - [Include GNU MP support])]) |
| 4 | + [Include GNU MP support. Use PKG_CONFIG_PATH (or GMP_CFLAGS and GMP_LIBS) |
| 5 | + environment variables, or alternatively the optional DIR argument to |
| 6 | + customize where to look for the GNU MP library.])]) |
5 | 7 |
|
6 | 8 | if test "$PHP_GMP" != "no"; then
|
7 |
| - if test "$PHP_GMP" = "yes"; then |
8 |
| - PHP_CHECK_LIBRARY([gmp], [__gmpz_rootrem], |
9 |
| - [], |
10 |
| - [AC_MSG_FAILURE([GNU MP Library version 4.2 or greater required.])]) |
| 9 | + gmp_found=no |
| 10 | + AS_VAR_IF([PHP_GMP], [yes], |
| 11 | + [PKG_CHECK_MODULES([GMP], [gmp >= 4.2], [gmp_found=yes], [:])]) |
11 | 12 |
|
12 |
| - PHP_ADD_LIBRARY([gmp],, [GMP_SHARED_LIBADD]) |
13 |
| - else |
14 |
| - if test ! -f $PHP_GMP/include/gmp.h; then |
15 |
| - AC_MSG_ERROR([Unable to locate gmp.h]) |
16 |
| - fi |
| 13 | + AS_VAR_IF([gmp_found], [no], [AS_VAR_IF([PHP_GMP], [yes], [GMP_LIBS=-lgmp], [ |
| 14 | + GMP_LIBS="-L$PHP_GMP/$PHP_LIBDIR -lgmp" |
| 15 | + GMP_CFLAGS="-I$PHP_GMP/include" |
| 16 | + ])]) |
17 | 17 |
|
18 |
| - PHP_CHECK_LIBRARY([gmp], [__gmpz_rootrem], |
19 |
| - [], |
20 |
| - [AC_MSG_FAILURE([GNU MP Library version 4.2 or greater required.])], |
21 |
| - [-L$PHP_GMP/$PHP_LIBDIR]) |
| 18 | + dnl Sanity check. |
| 19 | + CFLAGS_SAVED=$CFLAGS |
| 20 | + LIBS_SAVED=$LIBS |
| 21 | + CFLAGS="$CFLAGS $GMP_CFLAGS" |
| 22 | + LIBS="$LIBS $GMP_LIBS" |
| 23 | + gmp_check=no |
| 24 | + AC_CHECK_HEADER([gmp.h], [AC_CHECK_FUNC([__gmpz_rootrem], [gmp_check=yes])]) |
| 25 | + CFLAGS=$CFLAGS_SAVED |
| 26 | + LIBS=$LIBS_SAVED |
22 | 27 |
|
23 |
| - PHP_ADD_LIBRARY_WITH_PATH([gmp], |
24 |
| - [$PHP_GMP/$PHP_LIBDIR], |
25 |
| - [GMP_SHARED_LIBADD]) |
26 |
| - PHP_ADD_INCLUDE([$PHP_GMP/include]) |
27 |
| - fi |
| 28 | + AS_VAR_IF([gmp_check], [no], [AC_MSG_FAILURE([ |
| 29 | + The required GNU MP library version 4.2 or greater not found. |
| 30 | + ])]) |
| 31 | + |
| 32 | + PHP_EVAL_LIBLINE([$GMP_LIBS], [GMP_SHARED_LIBADD]) |
| 33 | + PHP_EVAL_INCLINE([$GMP_CFLAGS]) |
28 | 34 |
|
29 | 35 | PHP_INSTALL_HEADERS([ext/gmp], [php_gmp_int.h])
|
30 | 36 |
|
|
0 commit comments