libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit 0ae2861a8775dbb53b279e40122b8830dd458ff4
parent 4e6aa42c6986cd7f7b89c54e4886f558b44944e7
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Sun,  4 May 2025 18:25:34 +0200

Improved portability of the package (examples and tests)

Diffstat:
Mconfigure.ac | 2--
Mcontrib/Makefile.am | 2+-
Mcontrib/xcc | 0
Msrc/examples2/Makefile.am | 8+++++++-
Msrc/tests/Makefile.am | 3++-
Msrc/tests/client_server/Makefile.am | 40+++++-----------------------------------
Msrc/tests/client_server/libtest_convenience.c | 10++++++++--
Msrc/tests/client_server/test_client_server.c | 4+++-
8 files changed, 26 insertions(+), 43 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -148,8 +148,6 @@ AC_PROG_CC_STDC ] ) -# Workaround for libgcrypt -AS_IF([[test "x$lt_sysroot" != "x" && test "x$SYSROOT" = "x"]], [[SYSROOT="$lt_sysroot"]]) user_CFLAGS="$CFLAGS" user_LDFLAGS="$LDFLAGS" user_CPPFLAGS="$CPPFLAGS" diff --git a/contrib/Makefile.am b/contrib/Makefile.am @@ -1,2 +1,2 @@ # This Makefile.am is in the public domain -EXTRA_DIST = xcc ascebc mhd.png mhd.svg mhd_logo.png +EXTRA_DIST = xcc ascebc mhd.png mhd.svg mhd_logo.png update_vs_files.sh diff --git a/contrib/xcc b/contrib/xcc diff --git a/src/examples2/Makefile.am b/src/examples2/Makefile.am @@ -26,9 +26,12 @@ $(top_builddir)/src/mhd2/libmicrohttpd2.la: $(top_builddir)/src/mhd2/Makefile # example programs noinst_PROGRAMS = \ - demo \ minimal_example2 +if HAVE_POSIX_THREADS + noinst_PROGRAMS += demo +endif + if MHD_SUPPORT_AUTH_BASIC noinst_PROGRAMS += minimal_auth_basic endif @@ -36,3 +39,6 @@ endif if MHD_SUPPORT_AUTH_DIGEST noinst_PROGRAMS += minimal_auth_digest endif + +demo_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) +demo_LDADD = $(LDADD) $(PTHREAD_LIBS) diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am @@ -2,14 +2,15 @@ SUBDIRS = basic +if HAVE_POSIX_THREADS if MHD_SUPPORT_UPGRADE SUBDIRS += upgrade endif - if RUN_LIBCURL_TESTS if MHD_SOCKETS_KIND_POSIX SUBDIRS += client_server endif endif +endif .NOTPARALLEL: diff --git a/src/tests/client_server/Makefile.am b/src/tests/client_server/Makefile.am @@ -6,9 +6,9 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/mhd2 \ -DMHD_CPU_COUNT=$(CPU_COUNT) \ - $(CPPFLAGS_ac) + $(CPPFLAGS_ac) $(LIBCURL_CPPFLAGS) -AM_CFLAGS = $(CFLAGS_ac) +AM_CFLAGS = $(CFLAGS_ac) $(PTHREAD_CFLAGS) AM_LDFLAGS = $(LDFLAGS_ac) @@ -18,8 +18,9 @@ if USE_COVERAGE AM_CFLAGS += -fprofile-arcs -ftest-coverage endif -LDADD = $(top_builddir)/src/mhd2/libmicrohttpd2.la -LIBADD = $(top_builddir)/src/mhd2/libmicrohttpd2.la +LIBADD = \ + $(top_builddir)/src/mhd2/libmicrohttpd2.la $(LIBCURL) $(PTHREAD_LIBS) +LDADD = libmhdt.la $(LIBADD) $(top_builddir)/src/mhd2/libmicrohttpd2.la: $(top_builddir)/src/mhd2/Makefile @echo ' cd $(top_builddir)/src/mhd2 && $(MAKE) $(AM_MAKEFLAGS) libmicrohttpd2.la'; \ @@ -38,7 +39,6 @@ endif TESTS = $(check_PROGRAMS) - noinst_LTLIBRARIES = \ libmhdt.la @@ -47,36 +47,6 @@ libmhdt_la_SOURCES = \ libtest_convenience.c \ libtest_convenience_client_request.c \ libtest_convenience_server_reply.c -# TODO: fix flags, use configure-detected -libmhdt_la_LIBADD = \ - -lpthread \ - -lcurl \ - $(LIBADD) - -test_client_server_SOURCES = \ - test_client_server.c -test_client_server_LDADD = \ - libmhdt.la - -test_authentication_SOURCES = \ - test_authentication.c -test_authentication_LDADD = \ - libmhdt.la - -test_tls_SOURCES = \ - test_tls.c -test_tls_LDADD = \ - libmhdt.la - -test_cert_tls_SOURCES = \ - test_cert_tls.c -test_cert_tls_LDADD = \ - libmhdt.la - -test_postprocessor_SOURCES = \ - test_postprocessor.c -test_postprocessor_LDADD = \ - libmhdt.la # TODO: fix out-of-tree 'make check' EXTRA_DIST = \ diff --git a/src/tests/client_server/libtest_convenience.c b/src/tests/client_server/libtest_convenience.c @@ -1,6 +1,7 @@ /* This file is part of GNU libmicrohttpd Copyright (C) 2024 Christian Grothoff + Copyright (C) 2025 Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -25,12 +26,13 @@ */ #include "libtest.h" #include <pthread.h> -#include <stdbool.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> +#ifdef MHD_SUPPORT_EPOLL +# include <sys/epoll.h> +#endif #include <curl/curl.h> -#include <sys/epoll.h> const char * @@ -293,6 +295,7 @@ MHDT_server_run_blocking (void *cls, } +#ifdef MHD_SUPPORT_EPOLL static int my_epoll_fd = -1; @@ -480,3 +483,6 @@ MHDT_server_run_external (void *cls, close (my_epoll_fd); my_epoll_fd = -1; } + + +#endif /* MHD_SUPPORT_EPOLL */ diff --git a/src/tests/client_server/test_client_server.c b/src/tests/client_server/test_client_server.c @@ -1,6 +1,6 @@ /* This file is part of GNU libmicrohttpd - Copyright (C) 2016, 2024 Christian Grothoff & Evgeny Grin (Karlson2k) + Copyright (C) 2016, 2024, 2025 Christian Grothoff & Evgeny Grin (Karlson2k) GNU libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -125,12 +125,14 @@ main (int argc, char *argv[]) .server_setup_cls = thread1auto, .server_runner = &MHDT_server_run_minimal, }, +#ifdef MHD_SUPPORT_EPOLL { .label = "external events loop mode, no internal threads", .server_setup = &MHDT_server_setup_external, .server_setup_cls = NULL, .server_runner = &MHDT_server_run_external, }, +#endif /* MHD_SUPPORT_EPOLL */ #if 1 /* FIXME: remove once MHD_daemon_process_blocking has been implemented */