xref: /PHP-8.4/ext/gmp/config.m4 (revision 0c3b7677)
1PHP_ARG_WITH([gmp],
2  [for GNU MP support],
3  [AS_HELP_STRING([[--with-gmp[=DIR]]],
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.])])
7
8if test "$PHP_GMP" != "no"; then
9  gmp_found=no
10  AS_VAR_IF([PHP_GMP], [yes],
11    [PKG_CHECK_MODULES([GMP], [gmp >= 4.2], [gmp_found=yes], [:])])
12
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
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
27
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])
34
35  PHP_INSTALL_HEADERS([ext/gmp], [php_gmp_int.h])
36
37  PHP_NEW_EXTENSION([gmp],
38    [gmp.c],
39    [$ext_shared],,
40    [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
41  PHP_SUBST([GMP_SHARED_LIBADD])
42  AC_DEFINE([HAVE_GMP], [1],
43    [Define to 1 if the PHP extension 'gmp' is available.])
44fi
45