Allow using things that were deprecated in gtk+-3.22.
[freeciv.git] / m4 / sqlite3.m4
blob38912a7bac2b9f9b17e8874ca18d76baeb3cd209
1 # Check for sqlite3
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=""])
14   sqlite3_cflags=""
15   sqlite3_ldflags=""
16   SQLITE3_VERSION=""
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"
27   fi
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"
38   else
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"
45         break;
46       fi
47     done
48   fi
50   ac_sqlite3_ldflags="$ac_sqlite3_ldflags -lsqlite3"
52   saved_CPPFLAGS="$CPPFLAGS"
53   CPPFLAGS="$CPPFLAGS $ac_sqlite3_cppflags"
55   AC_COMPILE_IFELSE(
56     [
57       AC_LANG_PROGRAM([[@%:@include <sqlite3.h>]],[[
58 #if (SQLITE_VERSION_NUMBER >= $sqlite3_version_req_number)
59 // Everything is okay
60 #else
61 #  error SQLite version is too old
62 #endif
63       ]])
64     ],
65     [
66       AC_MSG_RESULT([yes])
67       success="yes"
68     ],
69     [
70       AC_MSG_RESULT([not found])
71       success="no"
72     ]
73   )
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/.* "//' \
87                           | $SED -e 's/"//'`
88       if test $ac_sqlite3_version != ""; then
89         SQLITE3_VERSION=$ac_sqlite3_version
90       else
91         AC_MSG_WARN([Can not find SQLITE_VERSION macro in sqlite3.h header to retrieve SQLite version!])
92       fi
93     fi
95     AC_SUBST(sqlite3_cflags)
96     AC_SUBST(sqlite3_ldflags)
97     AC_SUBST(SQLITE3_VERSION)
99     ifelse([$1], , :, [$1])
100   else
101     ifelse([$2], , :, [$2])
102   fi