commit 1086d6223ca6b400ca2f9313a71bea6e2d1d6b9e
parent e8836b6f131a72e7e7a17cd5a3a243b569dcd874
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 2 Mar 2025 01:55:49 +0100
add test for MHD2
Diffstat:
2 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -156,6 +156,23 @@ AS_IF([test $microhttpd = 0],
*** You need libmicrohttpd to build this program.
*** ]])])
+
+# check for libmicrohttpd2
+AC_MSG_CHECKING([for microhttpd2])
+AC_ARG_WITH([microhttpd2],
+ [AS_HELP_STRING([--with-microhttpd2=PFX], [base of libmicrohttpd2 installation])],
+ [AC_MSG_RESULT([given as $with_microhttpd2])],
+ [AC_MSG_RESULT([not given])
+ with_microhttpd2=yes])
+AS_CASE([$with_microhttpd2],
+ [yes],[],
+ [no],[],
+ [LDFLAGS="-L$with_microhttpd2/lib $LDFLAGS"
+ CPPFLAGS="-I$with_microhttpd2/include $CPPFLAGS"])
+MHD2_VERSION_AT_LEAST([1.99.0])
+
+
+
jansson=0
PKG_CHECK_MODULES([JANSSON], [jansson >= 2.3],
[LDFLAGS="$JANSSON_LIBS $LDFLAGS"
diff --git a/m4/mhd2.m4 b/m4/mhd2.m4
@@ -0,0 +1,50 @@
+# mhd2.m4
+
+# This file is part of GNU libmicrohttpd
+# Copyright (C) 2025 Taler Systems SA
+#
+# GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the
+# terms of the GNU Lesser General Public License as published by the Free Software
+# Foundation; either version 3, or (at your option) any later version.
+#
+# GNU libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License along with
+# GNU libmicrohttpd; see the file COPYING. If not, If not, see <http://www.gnu.org/license>
+
+# serial 1
+
+dnl MHD2_VERSION_AT_LEAST([VERSION])
+dnl
+dnl Check that microhttpd2.h can be used to build a program that prints out
+dnl the MHD_VERSION tuple in X.Y.Z format, and that X.Y.Z is greater or equal
+dnl to VERSION. If not, display message and cause the configure script to
+dnl exit failurefully.
+dnl
+dnl This uses AX_COMPARE_VERSION to do the job.
+dnl It sets shell var mhd_cv_version, as well.
+dnl
+AC_DEFUN([MHD2_VERSION_AT_LEAST],
+ [AC_CACHE_CHECK([libmicrohttpd2 version],[mhd2_cv_version],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ #include <stdio.h>
+ #include <microhttpd2.h>
+]],[[
+ int v = MHD_VERSION;
+ printf ("%x.%x.%x\n",
+ (v >> 24) & 0xff,
+ (v >> 16) & 0xff,
+ (v >> 8) & 0xff);
+]])],
+ [mhd2_cv_version=$(./conftest)],
+ [mhd2_cv_version=0])])
+AX_COMPARE_VERSION([$mhd2_cv_version],[ge],[$1],
+ [libmhd2=1],
+ [libmhd2=0])
+AM_CONDITIONAL([HAVE_MHD2], [test "x$libmhd2" = "x1"])
+AC_DEFINE_UNQUOTED([HAVE_MHD2], [$libmhd2],
+ [Defined to 1 if libmicrohttpd2 is available])
+])
+# mhd2.m4 ends here