]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
m4: Rewrite want_sqlite.m4 to use pkg_config
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Wed, 8 Jun 2022 09:06:14 +0000 (11:06 +0200)
committerKarl Fleischmann <karl.fleischmann@open-xchange.com>
Mon, 4 Jul 2022 09:43:26 +0000 (11:43 +0200)
Manually checking for headers/libraries requires the user to know and
pass non-default library-paths when configuring the project. Using
pkg_config simplifies the macro and automatically sets the
compiler/linker flags accordingly.

configure.ac
m4/want_sqlite.m4

index 6b5df34a61069031e27b07dfd0164fd2f3af0974..991807631a8497147a15ebf444ef77bf9cecb707 100644 (file)
@@ -559,8 +559,6 @@ AC_SUBST(MYSQL_CFLAGS)
 AC_SUBST(MYSQL_LIBS)
 AC_SUBST(PGSQL_CFLAGS)
 AC_SUBST(PGSQL_LIBS)
-AC_SUBST(SQLITE_CFLAGS)
-AC_SUBST(SQLITE_LIBS)
 
 AC_SUBST(DICT_LIBS)
 AC_SUBST(CDB_LIBS)
index 33652ccb5564012825e50cea154d9031f10b4c64..13815747cd3ae180ee9250370b59b38c2186ffa3 100644 (file)
@@ -1,20 +1,18 @@
 AC_DEFUN([DOVECOT_WANT_SQLITE], [
-  if test $want_sqlite != no; then
-          AC_CHECK_LIB(sqlite3, sqlite3_open, [
-                  AC_CHECK_HEADER(sqlite3.h, [
-                          SQLITE_LIBS="$SQLITE_LIBS -lsqlite3"
-  
-                          AC_DEFINE(HAVE_SQLITE,, [Build with SQLite3 support])
-                          found_sql_drivers="$found_sql_drivers sqlite"
-                  ], [
-                    if test $want_sqlite = yes; then
-                      AC_MSG_ERROR(cannot build with SQLite support: sqlite3.h not found)
-                    fi
-                  ])
-          ], [
-            if test $want_sqlite = yes; then
-              AC_MSG_ERROR(cannot build with SQLite support: libsqlite3 not found)
-            fi
-          ])
-  fi
+  have_sqlite=no
+
+  AS_IF([test "$want_sqlite" != "no"], [
+    PKG_CHECK_MODULES([SQLITE], [sqlite3], [have_sqlite=yes], [
+      have_sqlite=no
+
+      AS_IF([test "$want_sqlite" = "yes"], [
+        AC_MSG_ERROR([cannot build with SQLite support: sqlite3 library not found])
+      ])
+    ])
+  ])
+
+  AS_IF([test "$have_sqlite" != "no"], [
+    found_sql_drivers="$found_sql_drivers sqlite"
+    AC_DEFINE(HAVE_SQLITE,, [Build with SQLite3 support])
+  ])
 ])