[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 04/12: configure: improved portability when cross-compil
From: |
gnunet |
Subject: |
[libmicrohttpd] 04/12: configure: improved portability when cross-compiling |
Date: |
Sun, 28 Apr 2024 20:55:23 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit f7560cd8288ea4e9577fedf6141c25877fc1405a
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Apr 21 19:06:36 2024 +0200
configure: improved portability when cross-compiling
Added final warnings when some potentially wrong assumption are made
---
configure.ac | 160 +++++++++++++++++++++++++++++++---------------------
m4/ax_have_epoll.m4 | 104 ----------------------------------
2 files changed, 97 insertions(+), 167 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7f8933bb..8c901f66 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,6 +48,8 @@ AC_SUBST([PACKAGE_VERSION_SUBMINOR])
AC_SUBST([MHD_W32_DLL_SUFF])
AC_CONFIG_FILES([src/microhttpd/microhttpd_dll_res.rc])
+CONF_FINAL_WARNS=""
+
MHD_LIB_CPPFLAGS=""
MHD_LIB_CFLAGS=""
MHD_LIB_LDFLAGS=""
@@ -1281,24 +1283,21 @@ AX_PTHREAD(
[
mhd_have_posix_threads='yes'
AC_DEFINE([[HAVE_PTHREAD_H]],[[1]],[Define to 1 if you have the
<pthread.h> header file.])
- AC_CACHE_CHECK([[whether pthread_sigmask(3) is available]],
- [[mhd_cv_func_pthread_sigmask]], [dnl
- save_LIBS="$LIBS"
- LIBS="$PTHREAD_LIBS $LIBS"
- CFLAGS="${CFLAGS_ac} ${PTHREAD_CFLAGS} ${user_CFLAGS}"
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]],
- [[
- sigset_t nset, oset;
- sigemptyset (&nset);
- sigaddset (&nset, SIGPIPE);
- if (0 != pthread_sigmask(SIG_BLOCK, &nset, &oset)) return 1;
- ]])],
-
[[mhd_cv_func_pthread_sigmask="yes"]],[[mhd_cv_func_pthread_sigmask="no"]])
- LIBS="${save_LIBS}"
- CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
- ])
- AS_VAR_IF([mhd_cv_func_pthread_sigmask],["yes"],
- [AC_DEFINE([[HAVE_PTHREAD_SIGMASK]],[[1]],[Define to 1 if you have
the pthread_sigmask(3) function.])])
+ CFLAGS="${CFLAGS_ac} ${PTHREAD_CFLAGS} ${user_CFLAGS}"
+ MHD_CHECK_FUNC([pthread_sigmask],
+ [[
+#include <pthread.h>
+#include <signal.h>
+ ]],
+ [[
+ sigset_t nset, oset;
+ sigemptyset (&nset);
+ sigaddset (&nset, SIGPIPE);
+ i][f (0 != pthread_sigmask(SIG_BLOCK, &nset, &oset)) return 1;
+ ]],
+ [AC_DEFINE([[HAVE_PTHREAD_SIGMASK]],[[1]],[Define to 1 if you have the
pthread_sigmask(3) function.])]
+ )
+ CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
],[[mhd_have_posix_threads='no']])
AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$mhd_have_posix_threads" = "xyes"])
@@ -2405,8 +2404,18 @@ AC_ARG_ENABLE([[epoll]],
AS_IF([test "$enable_epoll" != "no"],
[
- AX_HAVE_EPOLL
- AS_IF([test "${ax_cv_have_epoll}" = "yes"],
+ MHD_CHECK_FUNC_RUN([epoll_create],
+ [[
+#include <sys/epoll.h>
+#include <unistd.h>
+ ]],
+ [[
+ int epfd = epoll_create(64);
+ i][f (0 > epfd) return -epfd;
+ (void) close(epfd);
+ return 0;
+ ]],
+ [cacheVar="assuming yes"],
[
AC_DEFINE([[EPOLL_SUPPORT]],[[1]],[Define to 1 to enable epoll
support])
enable_epoll='yes'
@@ -2418,6 +2427,23 @@ AS_IF([test "$enable_epoll" != "no"],
enable_epoll='no'
]
)
+ AS_UNSET([warn_msg])
+ AS_VAR_IF([mhd_cv_works_func_epoll_create],["assuming yes"],
+ [[warn_msg="When cross-compiling it is not possible to check whether
'epoll_create()' really works on the host (final) platform.
+'epoll' is enabled as most probably the host kernel supports it (CONFIG_EPOLL
option enabled in case of Linux kernel).
+Use './configure mhd_cv_works_func_epoll_create=yes' to mute this warning."]]
+ )
+ AS_VAR_SET_IF([warn_msg],[AC_MSG_WARN([$warn_msg])
+ AS_IF([test -n "${CONF_FINAL_WARNS}" ],
+ [
+ CONF_FINAL_WARNS="${CONF_FINAL_WARNS}
+
+WARNING: "
+ ]
+ )
+ CONF_FINAL_WARNS="${CONF_FINAL_WARNS}${warn_msg}"
+ ]
+ )
]
)
@@ -2573,11 +2599,8 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len, struct
sockaddr_storage.ss_len,
#endif
])
-MHD_CHECK_LINK_RUN([[f][or working
getsockname()]],[[mhd_cv_getsockname_usable]],
- [[mhd_cv_getsockname_usable='assuming yes']],
- [
- AC_LANG_SOURCE(
- [[
+MHD_CHECK_FUNC_RUN([getsockname],
+ [[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -2607,8 +2630,8 @@ MHD_CHECK_LINK_RUN([[f][or working
getsockname()]],[[mhd_cv_getsockname_usable]]
static void zr_mem(void *ptr, socklen_t size)
{ char *mem = ptr; while(size--) {mem[0] = 0; mem++;} }
-int main(void)
-{
+ ]],
+ [[
const socklen_t c_addr_size = (socklen_t)sizeof(struct sockaddr_in);
struct sockaddr_in sa;
socklen_t addr_size;
@@ -2657,10 +2680,8 @@ int main(void)
WSACleanup();
#endif
return ret;
-}
- ]]
- )
- ],
+ ]],
+ [cacheVar='assuming yes'],
[AC_DEFINE([[MHD_USE_GETSOCKNAME]], [[1]], [Define if you have usable
`getsockname' function.])]
)
@@ -2823,15 +2844,12 @@ AS_UNSET([[use_itc]])
AS_IF([[test "x$enable_itc" = "xeventfd" || test "x$enable_itc" = "xauto"]],
[
- MHD_CHECK_LINK_RUN([[f][or working
eventfd(2)]],[[mhd_cv_eventfd_usable]],[[mhd_cv_eventfd_usable='assuming no']],
- [
- AC_LANG_SOURCE([[
+ MHD_CHECK_FUNC_RUN([eventfd],[[
#include <sys/eventfd.h>
#include <unistd.h>
-
-int main(void)
-{
- unsigned char buf[8];
+ ]],
+ [[
+ static unsigned char buf[8];
int ret;
int efd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
if (0 > efd)
@@ -2847,21 +2865,39 @@ int main(void)
}
close(efd);
return ret;
-}
- ]]
+ ]],
+ [
+ AS_VAR_IF([enable_itc],["eventfd"],
+ [cacheVar="assuming yes"],[cacheVar="assuming no"]
)
],
[
use_itc='eventfd'
enable_itc="$use_itc"
- AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD for
inter-thread communication])
- ],
- [
- AS_VAR_IF([[enable_itc]], [["eventfd"]], [AC_MSG_ERROR([[eventfd(2) is
not usable, consider using other type of inter-thread communication]])])
+ AC_DEFINE([[_MHD_ITC_EVENTFD]], [[1]], [Define to use eventFD f][or
inter-thread communication])
]
)
- AS_VAR_IF([mhd_cv_eventfd_usable],["assuming no"],
- [AC_MSG_WARN([if you have 'eventfd' support enabled on your target
system consider overriding test result by "mhd_cv_eventfd_usable=yes" configure
parameter])]
+ AS_UNSET([warn_msg])
+ AS_VAR_IF([mhd_cv_works_func_eventfd],["assuming yes"],
+ [[warn_msg="When cross-compiling it is not possible to check whether
'eventfd()' really works on the host (final) platform.
+'eventfd' is enabled as requested by configure parameters.
+Use './configure mhd_cv_works_func_eventfd=yes' to mute this warning."]]
+ )
+ AS_VAR_IF([mhd_cv_works_func_eventfd],["assuming no"],
+ [[warn_msg="When cross-compiling it is not possible to check whether
'eventfd()' really works on the host (final) platform.
+'eventfd()' is disabled. If it is available use './configure
mhd_cv_works_func_eventfd=yes' to enable.
+Use './configure mhd_cv_works_func_eventfd=no' to mute this warning."]]
+ )
+ AS_VAR_SET_IF([warn_msg],[AC_MSG_WARN([$warn_msg])
+ AS_IF([test -n "${CONF_FINAL_WARNS}" ],
+ [
+ CONF_FINAL_WARNS="${CONF_FINAL_WARNS}
+
+WARNING: "
+ ]
+ )
+ CONF_FINAL_WARNS="${CONF_FINAL_WARNS}${warn_msg}"
+ ]
)
]
)
@@ -2889,30 +2925,27 @@ AC_INCLUDES_DEFAULT
use_itc='pipe'
enable_itc="$use_itc"
AC_DEFINE([[_MHD_ITC_PIPE]], [[1]], [Define to use pipe for inter-thread
communication])
- MHD_CHECK_LINK_RUN([[whether pipe2(2) is
usable]],[[mhd_cv_pipe2_usable]],
- [
- # Cross-compiling
- AS_CASE([${host_os}], [kfreebsd*-gnu],
[[mhd_cv_pipe2_usable='assuming no']],
- [[mhd_cv_pipe2_usable='assuming yes']])
- ],
- [
- AC_LANG_PROGRAM([
+ MHD_CHECK_FUNC_RUN([pipe2],[
AC_INCLUDES_DEFAULT
+[
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
- ], [[
- int arr[2];
- int res;
- res = pipe2(arr, O_CLOEXEC | O_NONBLOCK);
- if (res != 0) return 33;
- close (arr[0]);
- close (arr[1]);
- ]]
- )
+ ]],[[
+ int arr[2];
+ int res;
+ res = pipe2(arr, O_CLOEXEC | O_NONBLOCK);
+ i][f (res != 0) return 33;
+ close (arr[0]);
+ close (arr[1]);
+ return 0;
+ ]],[
+ # Cross-compiling
+ AS_CASE([${host_os}], [kfreebsd*-gnu], [cacheVar='assuming no'],
+ [cacheVar='assuming yes'])
],
[AC_DEFINE([[HAVE_PIPE2_FUNC]], [[1]], [Define if you have usable
pipe2(2) function])]
)
@@ -6068,3 +6101,4 @@ AS_IF([test "x$enable_bauth" != "xyes" || \
test "x$enable_postprocessor" != "xyes"],
[AC_MSG_WARN([This will be a custom build with missing symbols. Do NOT use
this build in a distribution. Building with these kinds of configure options is
only for custom builds for embedded systems.])]
)
+AS_IF([test -n "${CONF_FINAL_WARNS}"],[AC_MSG_WARN([${CONF_FINAL_WARNS}])])
diff --git a/m4/ax_have_epoll.m4 b/m4/ax_have_epoll.m4
deleted file mode 100644
index 3098de69..00000000
--- a/m4/ax_have_epoll.m4
+++ /dev/null
@@ -1,104 +0,0 @@
-# ===========================================================================
-# https://www.gnu.org/software/autoconf-archive/ax_have_epoll.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AX_HAVE_EPOLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-# AX_HAVE_EPOLL_PWAIT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-#
-# DESCRIPTION
-#
-# This macro determines whether the system supports the epoll I/O event
-# interface. A neat usage example would be:
-#
-# AX_HAVE_EPOLL(
-# [AX_CONFIG_FEATURE_ENABLE(epoll)],
-# [AX_CONFIG_FEATURE_DISABLE(epoll)])
-# AX_CONFIG_FEATURE(
-# [epoll], [This platform supports epoll(7)],
-# [HAVE_EPOLL], [This platform supports epoll(7).])
-#
-# The epoll interface was added to the Linux kernel in version 2.5.45, and
-# the macro verifies that a kernel newer than this is installed. This
-# check is somewhat unreliable if <linux/version.h> doesn't match the
-# running kernel, but it is necessary regardless, because glibc comes with
-# stubs for the epoll_create(), epoll_wait(), etc. that allow programs to
-# compile and link even if the kernel is too old; the problem would then
-# be detected only at runtime.
-#
-# Linux kernel version 2.6.19 adds the epoll_pwait() call in addition to
-# epoll_wait(). The availability of that function can be tested with the
-# second macro. Generally speaking, it is safe to assume that
-# AX_HAVE_EPOLL would succeed if AX_HAVE_EPOLL_PWAIT has, but not the
-# other way round.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Peter Simons <simons@cryp.to>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved. This file is offered as-is, without any
-# warranty.
-
-#serial 12
-
-AC_DEFUN([AX_HAVE_EPOLL], [dnl
- ax_have_epoll_cppflags="${CPPFLAGS}"
- AC_CHECK_HEADER([linux/version.h], [CPPFLAGS="${CPPFLAGS}
-DHAVE_LINUX_VERSION_H"], [], [AC_INCLUDES_DEFAULT])
- AC_MSG_CHECKING([for Linux epoll(7) interface])
- AC_CACHE_VAL([ax_cv_have_epoll], [dnl
- AC_LINK_IFELSE([dnl
- AC_LANG_PROGRAM([dnl
-#include <sys/epoll.h>
-#ifdef HAVE_LINUX_VERSION_H
-# include <linux/version.h>
-# if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)
-# error linux kernel version is too old to have epoll
-# endif
-#endif
-], [dnl
-int fd;
-struct epoll_event ev;
-fd = epoll_create(128);
-epoll_wait(fd, &ev, 1, 0);])],
- [ax_cv_have_epoll=yes],
- [ax_cv_have_epoll=no])])
- CPPFLAGS="${ax_have_epoll_cppflags}"
- AS_IF([test "${ax_cv_have_epoll}" = "yes"],
- [AC_MSG_RESULT([yes])
-$1],[AC_MSG_RESULT([no])
-$2])
-])dnl
-
-AC_DEFUN([AX_HAVE_EPOLL_PWAIT], [dnl
- ax_have_epoll_cppflags="${CPPFLAGS}"
- AC_CHECK_HEADER([linux/version.h],
- [CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
- AC_MSG_CHECKING([for Linux epoll(7) interface with signals extension])
- AC_CACHE_VAL([ax_cv_have_epoll_pwait], [dnl
- AC_LINK_IFELSE([dnl
- AC_LANG_PROGRAM([dnl
-#ifdef HAVE_LINUX_VERSION_H
-# include <linux/version.h>
-# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-# error linux kernel version is too old to have epoll_pwait
-# endif
-#endif
-#include <sys/epoll.h>
-#include <signal.h>
-], [dnl
-int fd;
-struct epoll_event ev;
-fd = epoll_create(128);
-epoll_wait(fd, &ev, 1, 0);
-epoll_pwait(fd, &ev, 1, 0, (sigset_t const *)(0));])],
- [ax_cv_have_epoll_pwait=yes],
- [ax_cv_have_epoll_pwait=no])])
- CPPFLAGS="${ax_have_epoll_cppflags}"
- AS_IF([test "${ax_cv_have_epoll_pwait}" = "yes"],
- [AC_MSG_RESULT([yes])
-$1],[AC_MSG_RESULT([no])
-$2])
-])dnl
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (44db29ca -> 3a93f07d), gnunet, 2024/04/28
- [libmicrohttpd] 02/12: mhd_check_func.m4: corrected, gnunet, 2024/04/28
- [libmicrohttpd] 03/12: mhd_check_func_run.m4: new autoconf macro, gnunet, 2024/04/28
- [libmicrohttpd] 08/12: configure: enable largefile earlier as it may influence other checks, gnunet, 2024/04/28
- [libmicrohttpd] 10/12: bootstrap: better support Gentoo and MinGW, gnunet, 2024/04/28
- [libmicrohttpd] 01/12: mhd_check_link_run.m4: documentation fixes, gnunet, 2024/04/28
- [libmicrohttpd] 05/12: configure: cosmetics and formatting, gnunet, 2024/04/28
- [libmicrohttpd] 09/12: configure: enable 64 bit time_t by default if possible, gnunet, 2024/04/28
- [libmicrohttpd] 12/12: mhd_bool.m4: new autoconf macro that supports C23, gnunet, 2024/04/28
- [libmicrohttpd] 04/12: configure: improved portability when cross-compiling,
gnunet <=
- [libmicrohttpd] 11/12: configure: print DAuth defaults in the help message, gnunet, 2024/04/28
- [libmicrohttpd] 06/12: configure: fixed compiler warnings for new compilers, gnunet, 2024/04/28
- [libmicrohttpd] 07/12: configure: improved messages, gnunet, 2024/04/28