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