[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 164/335: configure: reworked _MHD_EXTERN definition
From: |
gnunet |
Subject: |
[libmicrohttpd] 164/335: configure: reworked _MHD_EXTERN definition |
Date: |
Sat, 27 Jul 2024 22:01:00 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to tag stf-m2
in repository libmicrohttpd.
commit 98c94f3b26c2c70aaa76c62e5c994498ca9be000
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed May 15 21:39:45 2024 +0200
configure: reworked _MHD_EXTERN definition
---
configure.ac | 50 +++++++++++++++++++++----------------------
src/include/mhd_options.h | 36 ++++++++++++++++++++++---------
src/microhttpd/Makefile.am | 2 +-
src/microhttpd_ws/Makefile.am | 2 +-
4 files changed, 52 insertions(+), 38 deletions(-)
diff --git a/configure.ac b/configure.ac
index c99c92d1..31a8b954 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3265,42 +3265,40 @@ MHD_CHECK_FUNC([[sysctlbyname]], [[
MHD_CHECK_FUNC([[usleep]], [[#include <unistd.h>]], [[usleep(100000);]])
MHD_CHECK_FUNC([[nanosleep]], [[#include <time.h>]], [[struct timespec ts2,
ts1 = {0, 0}; nanosleep(&ts1, &ts2);]])
-HIDDEN_VISIBILITY_CFLAGS=""
-AH_TEMPLATE([_MHD_EXTERN],[defines how to decorate public symbols w][hile
building the library])
-CFLAGS="${user_CFLAGS}"
-MHD_CHECK_CC_CFLAG([-fvisibility=hidden],[CFLAGS_ac],
+# NOTE: require setting of errattr_CFLAGS above
+CFLAGS="${CFLAGS_ac} ${user_CFLAGS} ${errattr_CFLAGS}"
+AC_CACHE_CHECK([whether $CC supports
__attribute__((visibility("default")))],[mhd_cv_cc_attr_visibility_default],
[
- # NOTE: require setting of errattr_CFLAGS above
- CFLAGS="${CFLAGS_ac} -fvisibility=hidden ${user_CFLAGS} ${errattr_CFLAGS}"
- AC_CACHE_CHECK([whether $CC supports
__attribute__((visibility("default")))],[mhd_cv_cc_attr_visibility],
- [
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
-extern __attribute__((visibility("default"))) int test_extrn_func(void);
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+extern __attribute__((visibility("default"))) int
+test_extrn_func(void);
-int test_extrn_func(void) {return 0;}
- ]])
- ],
- [mhd_cv_cc_attr_visibility="yes"],[mhd_cv_cc_attr_visibility="no"]
- )
- ]
+extern __attribute__((visibility("default"))) int
+test_extrn_func(void) {return 0;}
+ ]])
+ ],
+
[mhd_cv_cc_attr_visibility_default="yes"],[mhd_cv_cc_attr_visibility_default="no"]
+ )
+ ]
+)
+AS_VAR_IF([mhd_cv_cc_attr_visibility_default],["yes"],
+ [
+ AC_DEFINE([HAVE_ATTR_VISIBILITY_DEFAULT],[1],
+ [Define to '1' if your compiler supports
__attribute__((visibility("default")))]
)
- AS_VAR_IF([mhd_cv_cc_attr_visibility],["yes"],
+
+ CFLAGS="${user_CFLAGS}"
+ MHD_CHECK_CC_CFLAG([-fvisibility=hidden],[CFLAGS_ac],
[
- HIDDEN_VISIBILITY_CFLAGS="-fvisibility=hidden"
- AS_IF([test "x$os_is_native_w32" = "xyes" && test "x$enable_shared" =
"xyes"],
- [AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default")))
__declspec(dllexport) extern])],
- [AC_DEFINE([_MHD_EXTERN], [__attribute__((visibility("default")))
extern])]
- )
+ MHD_APPEND_FLAG_TO_VAR([MHD_LIB_CFLAGS],[-fvisibility=hidden])
],
[
- AC_MSG_WARN([$CC supports -fvisibility, but does not support
__attribute__((visibility("default"))). Check compiler and compiler flags.])
- AC_DEFINE([_MHD_EXTERN], [extern])
+ AC_MSG_WARN([[$CC supports __attribute__((visibility("default"))), but
does not support -fvisibility=hidden. Check compiler and compiler flags.]])
]
)
- ],[AC_DEFINE([_MHD_EXTERN], [extern])]
+ ]
)
CFLAGS="${CFLAGS_ac} ${user_CFLAGS}"
-AC_SUBST([HIDDEN_VISIBILITY_CFLAGS])
# libcurl (required for testing)
AC_ARG_ENABLE([curl],
diff --git a/src/include/mhd_options.h b/src/include/mhd_options.h
index 39316a28..b011804d 100644
--- a/src/include/mhd_options.h
+++ b/src/include/mhd_options.h
@@ -1,6 +1,6 @@
/*
This file is part of libmicrohttpd
- Copyright (C) 2016-2021 Karlson2k (Evgeny Grin)
+ Copyright (C) 2016-2024 Karlson2k (Evgeny Grin)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -41,17 +41,33 @@
*/
#define _(String) (String)
-#if defined(_MHD_EXTERN) && ! defined(BUILDING_MHD_LIB)
-#undef _MHD_EXTERN
-#endif /* _MHD_EXTERN && ! BUILDING_MHD_LIB */
+#ifdef HAVE_ATTR_VISIBILITY_DEFAULT
+# define MHD_VISIBILITY_EXTERN __attribute__((visibility ("default")))
+#else
+# define MHD_VISIBILITY_EXTERN /* empty */
+#endif
+
+#if ! defined(_WIN32) || \
+ (! defined(DLL_EXPORT) /* Defined by libtool for shared version */ \
+ && ! defined(MHD_W32DLL) /* Defined by MS VS projects for MHD DLL */)
+# define MHD_EXPORTED /* empty */
+#else
+# define MHD_EXPORTED __declspec(dllexport)
+#endif
+
+#if defined(_MHD_EXTERN) && defined(BUILDING_MHD_LIB)
+# undef _MHD_EXTERN
+#endif /* _MHD_EXTERN && BUILDING_MHD_LIB */
#ifndef _MHD_EXTERN
-#if defined(BUILDING_MHD_LIB) && defined(_WIN32) && \
- (defined(DLL_EXPORT) || defined(MHD_W32DLL))
-#define _MHD_EXTERN __declspec(dllexport) extern
-#else /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */
-#define _MHD_EXTERN extern
-#endif /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */
+# ifdef BUILDING_MHD_LIB
+/* Building MHD itself */
+# define _MHD_EXTERN \
+ extern MHD_VISIBILITY_EXTERN MHD_EXPORTED
+# else /* ! BUILDING_MHD_LIB */
+/* Test or example code, using MHD as a library */
+# define _MHD_EXTERN extern
+# endif /* ! BUILDING_MHD_LIB */
#endif /* ! _MHD_EXTERN */
/* Some platforms (FreeBSD, Solaris, W32) allow to override
diff --git a/src/microhttpd/Makefile.am b/src/microhttpd/Makefile.am
index ef5f9bb5..ccd88986 100644
--- a/src/microhttpd/Makefile.am
+++ b/src/microhttpd/Makefile.am
@@ -4,7 +4,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/include \
$(CPPFLAGS_ac)
-AM_CFLAGS = $(CFLAGS_ac) $(HIDDEN_VISIBILITY_CFLAGS)
+AM_CFLAGS = $(CFLAGS_ac)
AM_LDFLAGS = $(LDFLAGS_ac)
diff --git a/src/microhttpd_ws/Makefile.am b/src/microhttpd_ws/Makefile.am
index 3ce8a9fe..3df6b247 100644
--- a/src/microhttpd_ws/Makefile.am
+++ b/src/microhttpd_ws/Makefile.am
@@ -3,7 +3,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/microhttpd
-AM_CFLAGS = $(HIDDEN_VISIBILITY_CFLAGS)
+AM_CFLAGS = $(CFLAGS_ac)
$(top_builddir)/src/microhttpd/libmicrohttpd.la:
$(top_builddir)/src/microhttpd/Makefile
@echo ' cd $(top_builddir)/src/microhttpd && $(MAKE) $(AM_MAKEFLAGS)
libmicrohttpd.la'; \
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] 145/335: Revert most of cacc8860fce31961570a1ba0d6f74836890cfa5b, (continued)
- [libmicrohttpd] 145/335: Revert most of cacc8860fce31961570a1ba0d6f74836890cfa5b, gnunet, 2024/07/27
- [libmicrohttpd] 132/335: Unified enum formatting, gnunet, 2024/07/27
- [libmicrohttpd] 140/335: Tmp: add doxy-config, gnunet, 2024/07/27
- [libmicrohttpd] 148/335: Fixed all doxygen warnings, gnunet, 2024/07/27
- [libmicrohttpd] 162/335: configure: check for more optional headers, gnunet, 2024/07/27
- [libmicrohttpd] 150/335: microhttpd2.h: fixed all g++ warnings and errors, gnunet, 2024/07/27
- [libmicrohttpd] 146/335: microhttpd2.h: more fixes, gnunet, 2024/07/27
- [libmicrohttpd] 163/335: configure: use more headers when checking for calloc(), gnunet, 2024/07/27
- [libmicrohttpd] 151/335: spellcheck, gnunet, 2024/07/27
- [libmicrohttpd] 166/335: renamed mhd_sys_options.h -> mhd_sys_options.h, gnunet, 2024/07/27
- [libmicrohttpd] 164/335: configure: reworked _MHD_EXTERN definition,
gnunet <=
- [libmicrohttpd] 149/335: microhttpd2.h: fixed all GCC warnings and errors, gnunet, 2024/07/27
- [libmicrohttpd] 153/335: say it is STF-funded, gnunet, 2024/07/27
- [libmicrohttpd] 169/335: mhd_sys_options.h: added support for more attributes for functions, gnunet, 2024/07/27
- [libmicrohttpd] 158/335: add response option generation;, gnunet, 2024/07/27
- [libmicrohttpd] 156/335: generator v1, gnunet, 2024/07/27
- [libmicrohttpd] 170/335: mhd_sys_options.h: renamed _MHD_EXTERN -> MHD_EXTERN_, gnunet, 2024/07/27
- [libmicrohttpd] 167/335: mhd_sys_options.h: formatting, gnunet, 2024/07/27
- [libmicrohttpd] 159/335: remove dependency on recutils and libjansson, gnunet, 2024/07/27
- [libmicrohttpd] 160/335: This API is TERRIBLE., gnunet, 2024/07/27
- [libmicrohttpd] 174/335: sys_socket_types.h: new internal header, gnunet, 2024/07/27