xref: /PHP-7.3/ext/pdo_sqlite/config.m4 (revision 8d3f8ca1)
1dnl config.m4 for extension pdo_sqlite
2dnl vim:et:sw=2:ts=2:
3
4PHP_ARG_WITH(pdo-sqlite, for sqlite 3 support for PDO,
5[  --without-pdo-sqlite[=DIR]
6                          PDO: sqlite 3 support.  DIR is the sqlite base
7                          install directory [BUNDLED]], $PHP_PDO)
8
9if test "$PHP_PDO_SQLITE" != "no"; then
10
11  if test "$PHP_PDO" = "no" && test "$ext_shared" = "no"; then
12    AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
13  fi
14
15  ifdef([PHP_CHECK_PDO_INCLUDES],
16  [
17    PHP_CHECK_PDO_INCLUDES
18  ],[
19    AC_MSG_CHECKING([for PDO includes])
20    if test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
21      pdo_cv_inc_path=$abs_srcdir/ext
22    elif test -f $abs_srcdir/ext/pdo/php_pdo_driver.h; then
23      pdo_cv_inc_path=$abs_srcdir/ext
24    elif test -f $phpincludedir/ext/pdo/php_pdo_driver.h; then
25      pdo_cv_inc_path=$phpincludedir/ext
26    else
27      AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
28    fi
29    AC_MSG_RESULT($pdo_cv_inc_path)
30  ])
31
32  php_pdo_sqlite_sources_core="pdo_sqlite.c sqlite_driver.c sqlite_statement.c"
33
34  if test "$PHP_PDO_SQLITE" != "yes"; then
35    SEARCH_PATH="$PHP_PDO_SQLITE /usr/local /usr"     # you might want to change this
36    SEARCH_FOR="/include/sqlite3.h"  # you most likely want to change this
37    if test -r $PHP_PDO_SQLITE/$SEARCH_FOR; then # path given as parameter
38      PDO_SQLITE_DIR=$PHP_PDO_SQLITE
39    else # search default path list
40      AC_MSG_CHECKING([for sqlite3 files in default path])
41      for i in $SEARCH_PATH ; do
42        if test -r $i/$SEARCH_FOR; then
43          PDO_SQLITE_DIR=$i
44          AC_MSG_RESULT(found in $i)
45        fi
46      done
47    fi
48    if test -z "$PDO_SQLITE_DIR"; then
49      AC_MSG_RESULT([not found])
50      AC_MSG_ERROR([Please reinstall the sqlite3 distribution])
51    fi
52
53    PHP_ADD_INCLUDE($PDO_SQLITE_DIR/include)
54
55    LIBNAME=sqlite3
56    LIBSYMBOL=sqlite3_open
57
58    PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
59    [
60      PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PDO_SQLITE_DIR/$PHP_LIBDIR, PDO_SQLITE_SHARED_LIBADD)
61      AC_DEFINE(HAVE_PDO_SQLITELIB,1,[ ])
62    ],[
63      AC_MSG_ERROR([wrong sqlite lib version or lib not found])
64    ],[
65      -L$PDO_SQLITE_DIR/$PHP_LIBDIR -lm
66    ])
67    PHP_CHECK_LIBRARY(sqlite3,sqlite3_key,[
68      AC_DEFINE(HAVE_SQLITE3_KEY,1, [have commercial sqlite3 with crypto support])
69    ])
70    PHP_CHECK_LIBRARY(sqlite3,sqlite3_close_v2,[
71      AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
72    ])
73
74    PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
75    PHP_NEW_EXTENSION(pdo_sqlite, $php_pdo_sqlite_sources_core, $ext_shared,,-I$pdo_cv_inc_path)
76  else
77      # use bundled libs
78      if test "$enable_maintainer_zts" = "yes"; then
79        threadsafe_flags="-DSQLITE_THREADSAFE=1"
80      else
81        threadsafe_flags="-DSQLITE_THREADSAFE=0"
82      fi
83
84      AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
85      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"
86
87	  dnl As long as intl is not shared we can have ICU support
88      if test "$PHP_INTL" = "yes" && test "$PHP_INTL_SHARED" != "yes"; then
89        other_flags="$other_flags -DSQLITE_ENABLE_ICU=1"
90      fi
91
92      if test "$PHP_SQLITE3" != "yes"; then
93        PHP_ADD_SOURCES(PHP_EXT_DIR(sqlite3), libsqlite/sqlite3.c)
94      fi
95
96      PHP_NEW_EXTENSION(pdo_sqlite,
97        $php_pdo_sqlite_sources_core,
98        $ext_shared,,-DPDO_SQLITE_BUNDLED=1 $other_flags $threadsafe_flags -I$pdo_cv_inc_path)
99
100      PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
101      PHP_ADD_EXTENSION_DEP(pdo_sqlite, sqlite3)
102      PHP_ADD_INCLUDE($abs_srcdir/ext/sqlite3/libsqlite)
103
104      AC_CHECK_FUNCS(usleep nanosleep)
105      AC_CHECK_HEADERS(time.h)
106  fi
107
108  dnl Solaris fix
109  PHP_CHECK_LIBRARY(rt, fdatasync, [PHP_ADD_LIBRARY(rt,, PDO_SQLITE_SHARED_LIBADD)])
110
111  ifdef([PHP_ADD_EXTENSION_DEP],
112  [
113    PHP_ADD_EXTENSION_DEP(pdo_sqlite, pdo)
114  ])
115fi
116