xref: /PHP-7.0/ext/sqlite3/config0.m4 (revision 3239f6d6)
1dnl $Id$
2dnl config.m4 for extension sqlite3
3dnl vim:et:ts=2:sw=2
4
5PHP_ARG_WITH(sqlite3, whether to enable the SQLite3 extension,
6[  --without-sqlite3[=DIR]   Do not include SQLite3 support. DIR is the prefix to
7                          SQLite3 installation directory.], yes)
8
9if test $PHP_SQLITE3 != "no"; then
10  sqlite3_extra_sources=""
11  PHP_SQLITE3_CFLAGS=" -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 "
12
13  dnl when running phpize enable_maintainer_zts is not available
14  if test -z "$enable_maintainer_zts"; then
15    if test -f "$phpincludedir/main/php_config.h"; then
16      ZTS=`grep '#define ZTS' $phpincludedir/main/php_config.h|$SED 's/#define ZTS//'`
17      if test "$ZTS" -eq "1"; then
18        enable_maintainer_zts="yes"
19      fi
20    fi
21  fi
22
23  if test $PHP_SQLITE3 != "yes"; then
24    AC_MSG_CHECKING([for sqlite3 files in default path])
25    for i in $PHP_SQLITE3 /usr/local /usr; do
26      if test -r $i/include/sqlite3.h; then
27        SQLITE3_DIR=$i
28        AC_MSG_RESULT(found in $i)
29        break
30      fi
31    done
32
33    if test -z "$SQLITE3_DIR"; then
34      AC_MSG_RESULT([not found])
35      AC_MSG_ERROR([Please reinstall the sqlite distribution from http://www.sqlite.org])
36    fi
37
38    AC_MSG_CHECKING([for SQLite 3.3.9+])
39    PHP_CHECK_LIBRARY(sqlite3, sqlite3_prepare_v2, [
40      AC_MSG_RESULT(found)
41      PHP_ADD_LIBRARY_WITH_PATH(sqlite3, $SQLITE3_DIR/$PHP_LIBDIR, SQLITE3_SHARED_LIBADD)
42      PHP_ADD_INCLUDE($SQLITE3_DIR/include)
43    ],[
44      AC_MSG_RESULT([not found])
45      AC_MSG_ERROR([Please install SQLite 3.3.9 first or check libsqlite3 is present])
46    ],[
47      -L$SQLITE3_DIR/$PHP_LIBDIR -lm
48    ])
49
50    PHP_CHECK_LIBRARY(sqlite3,sqlite3_key,[
51      AC_DEFINE(HAVE_SQLITE3_KEY, 1, [have commercial sqlite3 with crypto support])
52    ])
53    PHP_CHECK_LIBRARY(sqlite3,sqlite3_column_table_name,[
54      AC_DEFINE(SQLITE_ENABLE_COLUMN_METADATA, 1, [have sqlite3 with column metadata enabled])
55    ])
56    PHP_CHECK_LIBRARY(sqlite3,sqlite3_errstr,[
57      AC_DEFINE(HAVE_SQLITE3_ERRSTR, 1, [have sqlite3_errstr function])
58    ])
59
60    PHP_CHECK_LIBRARY(sqlite3,sqlite3_load_extension,
61    [],
62    [AC_DEFINE(SQLITE_OMIT_LOAD_EXTENSION, 1, [have sqlite3 with extension support])
63    ])
64
65  else
66    AC_MSG_CHECKING([bundled sqlite3 library])
67    AC_MSG_RESULT([yes])
68
69    sqlite3_extra_sources="libsqlite/sqlite3.c"
70
71    if test "$enable_maintainer_zts" = "yes"; then
72      threadsafe_flags="-DSQLITE_THREADSAFE=1"
73    else
74      threadsafe_flags="-DSQLITE_THREADSAFE=0"
75    fi
76
77    if test "$ZEND_DEBUG" = "yes"; then
78      debug_flags="-DSQLITE_DEBUG=1"
79    fi
80
81    other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_CORE=1 -DSQLITE_ENABLE_COLUMN_METADATA=1"
82
83	dnl As long as intl is not shared we can have ICU support
84    if test "$PHP_INTL" = "yes" && test "$PHP_INTL_SHARED" != "yes"; then
85      other_flags="$other_flags -DSQLITE_ENABLE_ICU=1"
86    fi
87
88    AC_DEFINE(HAVE_SQLITE3_ERRSTR, 1, [have sqlite3_errstr function])
89    PHP_SQLITE3_CFLAGS="-I@ext_srcdir@/libsqlite $other_flags $threadsafe_flags $debug_flags"
90    PHP_INSTALL_HEADERS([ext/sqlite3/libsqlite/sqlite3.h])
91  fi
92
93  AC_DEFINE(HAVE_SQLITE3,1,[ ])
94
95  sqlite3_sources="sqlite3.c $sqlite3_extra_sources"
96
97  PHP_NEW_EXTENSION(sqlite3, $sqlite3_sources, $ext_shared,,$PHP_SQLITE3_CFLAGS)
98  PHP_ADD_BUILD_DIR([$ext_builddir/libsqlite])
99  PHP_SUBST(SQLITE3_SHARED_LIBADD)
100fi
101