1##### http://autoconf-archive.cryp.to/ax_lib_sqlite3.html 2# 3# SYNOPSIS 4# 5# AX_LIB_SQLITE3([MINIMUM-VERSION],[DEFAULT]) 6# 7# DESCRIPTION 8# 9# Test for the SQLite 3 library of a particular version (or newer) 10# 11# This macro takes only one optional argument, required version of 12# SQLite 3 library. If required version is not passed, 3.0.0 is used 13# in the test of existence of SQLite 3. 14# 15# If no intallation prefix to the installed SQLite library is given 16# the macro searches under /usr, /usr/local, and /opt. 17# 18# This macro calls: 19# 20# AC_SUBST(SQLITE3_CPPFLAGS) 21# AC_SUBST(SQLITE3_LDFLAGS) 22# AC_SUBST(SQLITE3_LIBS) 23# AC_SUBST(SQLITE3_VERSION) 24# 25# And sets: 26# 27# HAVE_SQLITE3 28# 29# LAST MODIFICATION 30# 31# 2006-07-15 32# 33# COPYLEFT 34# 35# Copyright (c) 2006 Mateusz Loskot <mateusz@loskot.net> 36# 37# Copying and distribution of this file, with or without 38# modification, are permitted in any medium without royalty provided 39# the copyright notice and this notice are preserved. 40 41AC_DEFUN([AX_LIB_SQLITE3], 42[ 43 AC_ARG_WITH([sqlite3], 44 AC_HELP_STRING( 45 [--with-sqlite3@<:@=ARG@:>@], 46 [use SQLite 3 library @<:@default=no@:>@, optionally specify the prefix for sqlite3 library] 47 ), 48 [ 49 if test "$withval" = "no"; then 50 want_sqlite3="no" 51 elif test "$withval" = "yes"; then 52 want_sqlite3="yes" 53 ac_sqlite3_path="" 54 else 55 want_sqlite3="yes" 56 ac_sqlite3_path="$withval" 57 fi 58 ], 59 [want_sqlite3="no"] 60 ) 61 62 SQLITE3_CFLAGS="" 63 SQLITE3_LDFLAGS="" 64 SQLITE3_LIBS="" 65 SQLITE3_VERSION="" 66 67 if test "x$want_sqlite3" = "xyes"; then 68 69 ac_sqlite3_header="sqlite3.h" 70 71 sqlite3_version_req=ifelse([$1], [], [3.0.0], [$1]) 72 sqlite3_version_req_shorten=`expr $sqlite3_version_req : '\([[0-9]]*\.[[0-9]]*\)'` 73 sqlite3_version_req_major=`expr $sqlite3_version_req : '\([[0-9]]*\)'` 74 sqlite3_version_req_minor=`expr $sqlite3_version_req : '[[0-9]]*\.\([[0-9]]*\)'` 75 sqlite3_version_req_micro=`expr $sqlite3_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` 76 if test "x$sqlite3_version_req_micro" = "x" ; then 77 sqlite3_version_req_micro="0" 78 fi 79 80 sqlite3_version_req_number=`expr $sqlite3_version_req_major \* 1000000 \ 81 \+ $sqlite3_version_req_minor \* 1000 \ 82 \+ $sqlite3_version_req_micro` 83 84 AC_MSG_CHECKING([for SQLite3 library >= $sqlite3_version_req]) 85 86 if test "$ac_sqlite3_path" != ""; then 87 ac_sqlite3_cppflags="-I$ac_sqlite3_path/include" 88 ac_sqlite3_ldflags="-L$ac_sqlite3_path/lib" 89 else 90 for ac_sqlite3_path_tmp in /usr /usr/local /opt ; do 91 if test -f "$ac_sqlite3_path_tmp/include/$ac_sqlite3_header" \ 92 && test -r "$ac_sqlite3_path_tmp/include/$ac_sqlite3_header"; then 93 ac_sqlite3_path=$ac_sqlite3_path_tmp 94 ac_sqlite3_cppflags="-I$ac_sqlite3_path/include" 95 ac_sqlite3_ldflags="-L$ac_sqlite3_path/lib" 96 break; 97 fi 98 done 99 fi 100 101 saved_CPPFLAGS="$CPPFLAGS" 102 CPPFLAGS="$CPPFLAGS $ac_sqlite3_cppflags" 103 104dnl AC_LANG_PUSH([C++]) 105 AC_COMPILE_IFELSE( 106 [ 107 AC_LANG_PROGRAM([[@%:@include <sqlite3.h>]], 108 [[ 109#if (SQLITE_VERSION_NUMBER >= $sqlite3_version_req_number) 110// Everything is okay 111#else 112# error SQLite version is too old 113#endif 114 ]] 115 ) 116 ], 117 [ 118 found_sqlite3="yes" 119 AC_MSG_RESULT([yes]) 120 ], 121 [ 122 found_sqlite3="no" 123 AC_MSG_RESULT([no]) 124 ] 125 ) 126dnl AC_LANG_POP([C++]) 127 128 CPPFLAGS="$saved_CPPFLAGS" 129 130 if test "$found_sqlite3" = "yes"; then 131 132 SQLITE3_CPPFLAGS="$ac_sqlite3_cppflags" 133 SQLITE3_LDFLAGS="$ac_sqlite3_ldflags" 134 SQLITE3_LIBS="-lsqlite3" 135 136 ac_sqlite3_header_path="$ac_sqlite3_path/include/$ac_sqlite3_header" 137 138 dnl Retrieve SQLite release version 139 if test "x$ac_sqlite3_header_path" != "x"; then 140 ac_sqlite3_version=`cat $ac_sqlite3_header_path \ 141 | grep '#define.*SQLITE_VERSION.*\"' | sed -e 's/.* "//' \ 142 | sed -e 's/"//'` 143 if test $ac_sqlite3_version != ""; then 144 SQLITE3_VERSION=$ac_sqlite3_version 145 else 146 AC_MSG_WARN([Can not find SQLITE_VERSION macro in sqlite3.h header to retrieve SQLite version!]) 147 fi 148 fi 149 150 AC_SUBST(SQLITE3_CPPFLAGS) 151 AC_SUBST(SQLITE3_LDFLAGS) 152 AC_SUBST(SQLITE3_LIBS) 153 AC_SUBST(SQLITE3_VERSION) 154 AC_DEFINE(HAVE_SQLITE3, [1], [Define to 1 if SQLite libraries are available]) 155 fi 156 fi 157]) 158