Skip to content

Commit b6efc0b

Browse files
committed
sqlite3.m4: Fix cross compilation
sqlite3 version check uses AC_RUN_IFELSE without a cross compilation argument, which makes cross builds from source fail. Thanks to Helmut Grohne for the bug report on the Debian Bug Tracking System (bug 1119126). We now just use the upstream sqlite.m4 version from rra-c-util which calls pkg-config if available or the AC_SEARCH_LIBS macro if not.
1 parent ba39e0a commit b6efc0b

File tree

2 files changed

+20
-53
lines changed

2 files changed

+20
-53
lines changed

m4/sqlite3.m4

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,28 @@ dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values before
4646
dnl INN_LIB_SQLITE3_SWITCH was called.
4747
AC_DEFUN([INN_LIB_SQLITE3_RESTORE], [INN_LIB_HELPER_RESTORE([SQLITE3])])
4848

49-
dnl Ensures SQLite v3 meets our minimum version requirement.
50-
AC_DEFUN([_INN_LIB_SQLITE3_SOURCE], [[
51-
#include <sqlite3.h>
52-
53-
int main(void) {
54-
return sqlite3_libversion_number() < 3008002;
55-
}
56-
]])
57-
58-
dnl Checks if SQLite v3 is present. The single argument, if "true", says to
59-
dnl fail if the SQLite library could not be found.
49+
dnl Checks if SQLite v3 is present. The single argument, if "true", says to
50+
dnl fail if the SQLite library could not be found. Prefer probing with
51+
dnl pkg-config if available and the --with flags were not given.
6052
AC_DEFUN([_INN_LIB_SQLITE3_INTERNAL],
61-
[AC_CACHE_CHECK([for a sufficiently recent SQLite],
62-
[inn_cv_have_sqlite3],
63-
[INN_LIB_HELPER_PATHS([SQLITE3])
64-
INN_LIB_SQLITE3_SWITCH
65-
LIBS="-lsqlite3 $LIBS"
66-
AC_RUN_IFELSE([AC_LANG_SOURCE([_INN_LIB_SQLITE3_SOURCE])],
67-
[inn_cv_have_sqlite3=yes],
68-
[inn_cv_have_sqlite3=no])
53+
[INN_LIB_HELPER_PATHS([SQLITE3])
54+
AS_IF([test x"$SQLITE3_CPPFLAGS" = x && test x"$SQLITE3_LDFLAGS" = x],
55+
[PKG_PROG_PKG_CONFIG([], [PKG_CONFIG=false])
56+
AS_IF([test x"$PKG_CONFIG" = x], [PKG_CONFIG=false])
57+
PKG_CHECK_EXISTS([sqlite3],
58+
[PKG_CHECK_MODULES([SQLITE3], [sqlite3])
59+
SQLITE3_CPPFLAGS="$SQLITE3_CFLAGS"])])
60+
AS_IF([test x"$SQLITE3_LIBS" = x],
61+
[INN_LIB_SQLITE3_SWITCH
62+
LIBS=
63+
AC_SEARCH_LIBS([sqlite3_open_v2], [sqlite3],
64+
[SQLITE3_LIBS="$LIBS"],
65+
[AS_IF([test x"$1" = xtrue],
66+
[AC_MSG_ERROR([cannot find usable libsqlite3 library])])])
6967
INN_LIB_SQLITE3_RESTORE])
70-
AS_IF([test x"$inn_cv_have_sqlite3" = xyes],
71-
[SQLITE3_LIBS="-lsqlite3"],
72-
[AS_IF([test x"$1" = xtrue],
73-
[AC_MSG_ERROR([cannot find usable SQLite v3 library])])])])
68+
INN_LIB_SQLITE3_SWITCH
69+
AC_CHECK_HEADERS([sqlite3.h])
70+
INN_LIB_SQLITE3_RESTORE])
7471

7572
dnl The main macro for packages with mandatory SQLite v3 support.
7673
AC_DEFUN([INN_LIB_SQLITE3],

support/getrra-c-util

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -60,36 +60,6 @@ download() {
6060
-e '/test x"$CLANG" = xyes/,+1d' \
6161
${TEMP}
6262
sed -i -e '$d' ${TEMP}
63-
elif [ "$3" = "sqlite3.m4" ]; then
64-
sed -i -e '49 i \
65-
dnl Ensures SQLite v3 meets our minimum version requirement.\
66-
AC_DEFUN([_INN_LIB_SQLITE3_SOURCE], [[\
67-
#include <sqlite3.h>\
68-
\
69-
int main(void) {\
70-
return sqlite3_libversion_number() < 3008002;\
71-
}\
72-
]])\
73-
\
74-
dnl Checks if SQLite v3 is present. The single argument, if "true", says to\
75-
dnl fail if the SQLite library could not be found.\
76-
AC_DEFUN([_INN_LIB_SQLITE3_INTERNAL],\
77-
[AC_CACHE_CHECK([for a sufficiently recent SQLite],\
78-
[inn_cv_have_sqlite3],\
79-
[INN_LIB_HELPER_PATHS([SQLITE3])\
80-
INN_LIB_SQLITE3_SWITCH\
81-
LIBS="-lsqlite3 $LIBS"\
82-
AC_RUN_IFELSE([AC_LANG_SOURCE([_INN_LIB_SQLITE3_SOURCE])],\
83-
[inn_cv_have_sqlite3=yes],\
84-
[inn_cv_have_sqlite3=no])\
85-
INN_LIB_SQLITE3_RESTORE])\
86-
AS_IF([test x"$inn_cv_have_sqlite3" = xyes],\
87-
[SQLITE3_LIBS="-lsqlite3"],\
88-
[AS_IF([test x"$1" = xtrue],\
89-
[AC_MSG_ERROR([cannot find usable SQLite v3 library])])])])\
90-
' \
91-
-e '49,71d' \
92-
${TEMP}
9363
fi
9464
elif [ "$2" = "include/inn" ] || [ "$2" = "include/portable" ] \
9565
|| [ "$2" = "include" ] || [ "$2" = "lib" ] || [ "$2" = "tests/lib" ] \

0 commit comments

Comments
 (0)