4 [AS_HELP_STRING([--with-ion],
8 AC_ARG_VAR([GIT], [git executable])
9 AC_PATH_PROG([GIT], [git])
12 AC_ARG_VAR([CMAKE], [cmake executable])
13 AC_PATH_PROG([CMAKE], [cmake])
16 use_bundled_ionc=false
17 AC_DEFUN([ION_BUNDLE], [dnl
19 AC_MSG_CHECKING([for bundled ion-c])
20 if test -f PHP_EXT_SRCDIR([ion])/ion-c/CMakeLists.txt; then
21 AC_MSG_RESULT([ion-c])
22 elif test -d PHP_EXT_SRCDIR([ion])/.git; then
23 AC_MSG_RESULT([git submodule])
24 if ! GIT_DIR=PHP_EXT_SRCDIR([ion])/.git GIT_WORK_TREE=PHP_EXT_SRCDIR([ion])/ \
25 "$GIT" submodule update --init --depth 1 --recursive ion-c; then
26 AC_MSG_ERROR([giving up])
28 elif "$GIT" clone -q --depth 1 --recursive https://github.com/amzn/ion-c PHP_EXT_SRCDIR([ion])/ion-c; then
29 AC_MSG_RESULT([git clone])
31 AC_MSG_RESULT([not found])
32 AC_MSG_ERROR([invalid bundle: PHP_EXT_SRCDIR([ion])/ion-c])
35 PHP_ADD_INCLUDE(PHP_EXT_SRCDIR([ion])/ion-c/ionc/include)
36 PHP_ADD_INCLUDE(PHP_EXT_SRCDIR([ion])/ion-c/decNumber/include)
38 PHP_EXPAND_PATH(PHP_EXT_BUILDDIR([ion]), builddir)
39 builddir="$builddir/ion-c/build"
40 if test "$ext_shared" = yes; then
41 ION_SHARED_LIBADD="-lionc_static -ldecNumber_static -L$builddir/ionc -L$builddir/decNumber"
43 DLIBS="$DLIBS -lionc_static -ldecNumber_static"
44 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$builddir/ionc -L$builddir/decNumber"
45 EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM -L$builddir/ionc -L$builddir/decNumber"
48 if test "$PHP_DEBUG" = 1; then
51 LIB_IONC_BUILD=Release
53 PHP_SUBST(LIB_IONC_BUILD)
54 PHP_ADD_MAKEFILE_FRAGMENT()
56 AC_DEFUN([ION_CHECK_LIB], [dnl
59 PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL,
61 [have_]AS_TR_SH($LIBNAME)[_]AS_TR_SH($LIBSYMBOL)=true
62 AC_DEFINE([HAVE_]AS_TR_CPP($LIBNAME)[_]AS_TR_CPP($LIBSYMBOL), 1, [ ])
63 PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $ION_DIR/$PHP_LIBDIR, ION_SHARED_LIBADD)
65 [have_]AS_TR_SH($LIBNAME)[_]AS_TR_SH($LIBSYMBOL)=true
66 AC_MSG_WARN([could not link with $LIBNAME library or find $LIBSYMBOL.])
68 -L$ION_DIR/$PHP_LIBDIR -lm
71 AC_DEFUN([ION_SYSTEM], [dnl
72 SEARCH_PATH="/usr/local /usr"
73 SEARCH_FOR="/include/ionc/ion.h"
74 if test -r $PHP_ION/$SEARCH_FOR; then
77 AC_MSG_CHECKING([for ion-c files in default path])
78 for i in $SEARCH_PATH ; do
79 if test -r $i/$SEARCH_FOR; then
86 if test -n "$ION_DIR"; then
87 AC_MSG_RESULT(found in $ION_DIR)
88 PHP_ADD_INCLUDE([$ION_DIR/include])
89 ION_CHECK_LIB(ionc, ion_error_to_str)
90 ION_CHECK_LIB(decNumber, decQuadFromInt32)
91 if ! $have_ionc_ion_error_to_str || ! $have_decNumber_decQuadFromInt32; then
95 AC_MSG_RESULT([not found])
101 if test "$PHP_ION" != "no"; then
102 PHP_NEW_EXTENSION(ion, ion.c, $ext_shared)
105 ion-c|b|bundle*) ION_BUNDLE ;;
109 PHP_SUBST(ION_SHARED_LIBADD)
110 AC_DEFINE(HAVE_ION, 1, [ Have ion support ])