commit 5e715eabb211fc9310ae7ccf0419267699a3f5dc
parent 783ec338ad279acaa3ed0f9d8a537cfc40dd99f6
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 27 Feb 2025 00:28:12 +0100
mhd2 test
Diffstat:
3 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -142,6 +142,22 @@ AS_CASE([$with_microhttpd],
CPPFLAGS="-I$with_microhttpd/include $CPPFLAGS"])
MHD_VERSION_AT_LEAST([0.9.71])
+
+# check for libmicrohttpd
+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])
+
+
# check for libjansson (Jansson JSON library)
jansson=0
AC_MSG_CHECKING([for jansson])
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
diff --git a/src/mhd/Makefile.am b/src/mhd/Makefile.am
@@ -28,3 +28,28 @@ libtalermhd_la_LIBADD = \
-ljansson \
-lz \
$(XLIB)
+
+if HAVE_MHD2
+lib_LTLIBRARIES += \
+ libtalermhd2.la
+
+libtalermhd2_la_SOURCES = \
+ mhd2_config.c \
+ mhd2_legal.c \
+ mhd2_parsing.c \
+ mhd2_responses.c \
+ mhd2_run.c \
+ mhd2_spa.c
+libtalermhd2_la_LDFLAGS = \
+ -version-info 0:0:0 \
+ -no-undefined
+libtalermhd2_la_LIBADD = \
+ $(top_builddir)/src/json/libtalerjson.la \
+ $(top_builddir)/src/util/libtalerutil.la \
+ -lgnunetjson \
+ -lgnunetutil \
+ -lmicrohttpd2 \
+ -ljansson \
+ -lz \
+ $(XLIB)
+endif