From 58aa0e8547a29e147f3d9d1792117d96bc00ffda Mon Sep 17 00:00:00 2001
From: Lars Wendler <polynomial-c@gentoo.org>
Date: Thu, 8 Apr 2021 11:05:36 +0200
Subject: [PATCH] gnupg: configure.ac: Fix sqlite3 detection

or else --disable-sqlite has no effect and linking later fails with:

  keyboxd-backend-sqlite.o: in function `show_sqlstmt.part.0':
  backend-sqlite.c:(.text+0x42): undefined reference to `sqlite3_expanded_sql'

Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
---
 configure.ac | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9cf0c6a7f..d46469cbb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -969,18 +969,20 @@ AC_ARG_ENABLE(sqlite,
                                [disable the use of SQLITE]),
               try_sqlite=$enableval, try_sqlite=yes)
 
-if test x"$use_tofu" = xyes ; then
-  if test x"$try_sqlite" = xyes ; then
+AS_IF([test x"$try_sqlite" = xyes], [
     PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= $NEED_SQLITE_VERSION],
                                  [have_sqlite=yes],
                                  [have_sqlite=no])
-  fi
-  if test "$have_sqlite" = "yes"; then
-    :
-    AC_SUBST([SQLITE3_CFLAGS])
-    AC_SUBST([SQLITE3_LIBS])
-  else
-    use_tofu=no
+    AS_IF([test "$have_sqlite" = "yes"], [
+        AC_SUBST([SQLITE3_CFLAGS])
+        AC_SUBST([SQLITE3_LIBS])
+    ])
+    ])
+
+AS_IF([test "$have_sqlite" != "yes"], [
+    AS_IF([test x"$use_tofu" = xyes], [
+	use_tofu=no
+    ])
     build_keyboxd=no
     tmp=$(echo "$SQLITE3_PKG_ERRORS" | tr '\n' '\v' | sed 's/\v/\n*** /g')
     AC_MSG_WARN([[
@@ -988,8 +990,7 @@ if test x"$use_tofu" = xyes ; then
 *** Building without SQLite support - TOFU and Keyboxd disabled
 ***
 *** $tmp]])
-  fi
-fi
+])
 
 AM_CONDITIONAL(SQLITE3, test "$have_sqlite" = "yes")
 
-- 
2.31.1

