3 # http://ac-archive.sourceforge.net/ac-archive/ax_lib_sqlite3.html
4 # Modified for freeciv use.
6 # FC_CHECK_SQLITE3([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND] [,VERSION]])
8 AC_DEFUN([FC_CHECK_SQLITE3],
10 AC_ARG_WITH([sqlite3-prefix],
11 AS_HELP_STRING([--with-sqlite3-prefix=PFX], [Prefix where SQLite3 is installed (optional)]),
12 [sqlite3_prefix="$withval"], [sqlite3_prefix=""])
18 ac_sqlite3_header="sqlite3.h"
20 sqlite3_version_req=ifelse([$3], [], [3.0.0], [$3])
21 sqlite3_version_req_shorten=`expr $sqlite3_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
22 sqlite3_version_req_major=`expr $sqlite3_version_req : '\([[0-9]]*\)'`
23 sqlite3_version_req_minor=`expr $sqlite3_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
24 sqlite3_version_req_micro=`expr $sqlite3_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
25 if test "x$sqlite3_version_req_micro" = "x" ; then
26 sqlite3_version_req_micro="0"
29 sqlite3_version_req_number=`expr $sqlite3_version_req_major \* 1000000 \
30 \+ $sqlite3_version_req_minor \* 1000 \
31 \+ $sqlite3_version_req_micro`
33 AC_MSG_CHECKING([for SQLite3 library >= $sqlite3_version_req])
35 if test "$sqlite3_prefix" != ""; then
36 ac_sqlite3_ldflags="-L$sqlite3_prefix/lib"
37 ac_sqlite3_cppflags="-I$sqlite3_prefix/include"
39 for sqlite3_prefix_tmp in /usr /usr/local /opt ; do
40 if test -f "$sqlite3_prefix_tmp/include/$ac_sqlite3_header" \
41 && test -r "$sqlite3_prefix_tmp/include/$ac_sqlite3_header"; then
42 sqlite3_prefix=$sqlite3_prefix_tmp
43 ac_sqlite3_cppflags="-I$sqlite3_prefix_tmp/include"
44 ac_sqlite3_ldflags="-L$sqlite3_prefix_tmp/lib"
50 ac_sqlite3_ldflags="$ac_sqlite3_ldflags -lsqlite3"
52 saved_CPPFLAGS="$CPPFLAGS"
53 CPPFLAGS="$CPPFLAGS $ac_sqlite3_cppflags"
57 AC_LANG_PROGRAM([[@%:@include <sqlite3.h>]],[[
58 #if (SQLITE_VERSION_NUMBER >= $sqlite3_version_req_number)
61 # error SQLite version is too old
70 AC_MSG_RESULT([not found])
75 CPPFLAGS="$saved_CPPFLAGS"
77 if test "$success" = "yes"; then
78 sqlite3_cflags="$ac_sqlite3_cppflags"
79 sqlite3_ldflags="$ac_sqlite3_ldflags"
81 ac_sqlite3_header_path="$sqlite3_prefix/include/$ac_sqlite3_header"
83 dnl Retrieve SQLite release version
84 if test "x$ac_sqlite3_header_path" != "x"; then
85 ac_sqlite3_version=`cat $ac_sqlite3_header_path \
86 | grep '#define.*SQLITE_VERSION.*\"' | $SED -e 's/.* "//' \
88 if test $ac_sqlite3_version != ""; then
89 SQLITE3_VERSION=$ac_sqlite3_version
91 AC_MSG_WARN([Can not find SQLITE_VERSION macro in sqlite3.h header to retrieve SQLite version!])
95 AC_SUBST(sqlite3_cflags)
96 AC_SUBST(sqlite3_ldflags)
97 AC_SUBST(SQLITE3_VERSION)
99 ifelse([$1], , :, [$1])
101 ifelse([$2], , :, [$2])