]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Don't export symbols from static MSVC .obj files.
authorBruno Haible <bruno@clisp.org>
Wed, 6 Sep 2023 18:59:03 +0000 (20:59 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 6 Sep 2023 23:40:53 +0000 (01:40 +0200)
* gettext-runtime/intl/configure.ac (WOE32DLL): Set to 1 or 0, not 'yes' or
'no'. Don't define as C macro any more.
(DLL_VARIABLE): Test DLL_EXPORT, not _DLL.
* gettext-runtime/intl/export.h: Use the value of WOE32DLL at configure time.
Set LIBINTL_DLL_EXPORTED to empty on MSVC when DLL_EXPORT is not defined.
* gettext-runtime/intl/Makefile.am (libgnuintl.h): Substitute the value of
@WOE32DLL@.
* gettext-runtime/intl/intl-compat.c (DLL_EXPORTED): Set to empty on MSVC when
DLL_EXPORT is not defined.
* gettext-runtime/intl/printf.c (DLL_EXPORTED): Likewise.
* gettext-runtime/intl/setlocale.c (DLL_EXPORTED): Likewise.

gettext-runtime/intl/Makefile.am
gettext-runtime/intl/configure.ac
gettext-runtime/intl/export.h
gettext-runtime/intl/intl-compat.c
gettext-runtime/intl/printf.c
gettext-runtime/intl/setlocale.c

index 1694815cd1292254992cae6887fb5d020c069ed2..da7abb7583db82de7916f14a1f8c83af79d75eee 100644 (file)
@@ -230,7 +230,7 @@ libgnuintl.h: $(srcdir)/libgnuintl.in.h $(srcdir)/export.h
            -e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \
            -e 's,@''ENHANCE_LOCALE_FUNCS''@,@ENHANCE_LOCALE_FUNCS@,g' \
          < $(srcdir)/libgnuintl.in.h \
-       | if test '@WOE32DLL@' = yes; then \
+       | if test '@WOE32DLL@' = 1; then \
            sed -e 's/extern \([^()]*\);/extern __declspec (dllimport) \1;/'; \
          else \
            cat; \
@@ -239,6 +239,7 @@ libgnuintl.h: $(srcdir)/libgnuintl.in.h $(srcdir)/export.h
              -e "/#define _LIBINTL_H/r $(srcdir)/export.h" \
        | sed -e '/#define _LIBINTL_H/,/[*][/]$$/{/#define _LIBINTL_H/!d;}' \
        | sed -e 's,@''HAVE_VISIBILITY''@,@HAVE_VISIBILITY@,g' \
+       | sed -e 's,@''WOE32DLL''@,@WOE32DLL@,g' \
          > libgnuintl.h
 MOSTLYCLEANFILES += libgnuintl.h
 
index 2a31e3475d46ed0b393e612bc79852dd0c25fc06..30a86065ef7c5bb95027314f6d14e60f24c9a335 100644 (file)
@@ -229,21 +229,26 @@ if test "$enable_shared" = yes; then
 else
   is_woe32dll=no
 fi
-WOE32DLL=$is_woe32dll
-AC_SUBST([WOE32DLL])
-AM_CONDITIONAL([WOE32DLL], [test $is_woe32dll = yes])
 if test $is_woe32dll = yes; then
-  AC_DEFINE([WOE32DLL], [1],
-    [Define when --enable-shared is used on Windows.])
+  WOE32DLL=1
+else
+  WOE32DLL=0
 fi
+AC_SUBST([WOE32DLL])
+AM_CONDITIONAL([WOE32DLL], [test $is_woe32dll = yes])
 
 dnl Put some default definitions into config.h.
 AH_BOTTOM([
 /* Tweak gnulib code according to the needs of this library.  */
 #define IN_LIBINTL 1
 
-/* On Windows, variables that may be in a DLL must be marked specially.  */
-#if (defined _MSC_VER && defined _DLL) && !defined IN_RELOCWRAPPER
+/* On Windows, variables that may be in a DLL must be marked specially.
+   The symbols marked with DLL_VARIABLE should be exported if and only if the
+   object file gets included in a DLL.  Libtool, on Windows platforms, defines
+   the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
+   and does not define it when compiling an object file meant to be linked
+   statically into some executable.  */
+#if (defined _MSC_VER && defined DLL_EXPORT) && !defined IN_RELOCWRAPPER
 # define DLL_VARIABLE __declspec (dllimport)
 #else
 # define DLL_VARIABLE
index 7988aca3ea7bcce5f5093f3150a0122d28cf57e5..aadf1633e782b1a3377c626672170f3f012a40de 100644 (file)
@@ -1,5 +1,5 @@
 /* Control of exported symbols from libintl.
-   Copyright (C) 2005-2022 Free Software Foundation, Inc.
+   Copyright (C) 2005-2023 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #if @HAVE_VISIBILITY@ && BUILDING_LIBINTL
-#define LIBINTL_DLL_EXPORTED __attribute__((__visibility__("default")))
-#elif (defined _WIN32 && !defined __CYGWIN__) && defined WOE32DLL && BUILDING_LIBINTL
-#define LIBINTL_DLL_EXPORTED __declspec(dllexport)
-#elif (defined _WIN32 && !defined __CYGWIN__) && defined WOE32DLL
-#define LIBINTL_DLL_EXPORTED __declspec(dllimport)
+# define LIBINTL_DLL_EXPORTED __attribute__((__visibility__("default")))
+#elif (defined _WIN32 && !defined __CYGWIN__) && @WOE32DLL@ && BUILDING_LIBINTL
+/* The symbols from this file should be exported if and only if the object
+   file gets included in a DLL.  Libtool, on Windows platforms, defines
+   the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
+   and does not define it when compiling an object file meant to be linked
+   statically into some executable.  */
+# if defined DLL_EXPORT
+#  define LIBINTL_DLL_EXPORTED __declspec(dllexport)
+# else
+#  define LIBINTL_DLL_EXPORTED
+# endif
+#elif (defined _WIN32 && !defined __CYGWIN__) && @WOE32DLL@
+# define LIBINTL_DLL_EXPORTED __declspec(dllimport)
 #else
-#define LIBINTL_DLL_EXPORTED
+# define LIBINTL_DLL_EXPORTED
 #endif
index e2b8d6c371aea8ef65200e8b18e29ed4658ea212..d141e0453a4936dcefab11a73f214f372a08f734 100644 (file)
@@ -1,6 +1,6 @@
 /* intl-compat.c - Stub functions to call gettext functions from GNU gettext
    Library.
-   Copyright (C) 1995, 2000-2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2000-2003, 2005, 2023 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
 #if HAVE_VISIBILITY && BUILDING_DLL
 # define DLL_EXPORTED __attribute__((__visibility__("default")))
 #elif defined _MSC_VER && BUILDING_DLL
-# define DLL_EXPORTED __declspec(dllexport)
+/* When building with MSVC, exporting a symbol means that the object file
+   contains a "linker directive" of the form /EXPORT:symbol.  This can be
+   inspected through the "objdump -s --section=.drectve FILE" or
+   "dumpbin /directives FILE" commands.
+   The symbols from this file should be exported if and only if the object
+   file gets included in a DLL.  Libtool, on Windows platforms, defines
+   the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
+   and does not define it when compiling an object file meant to be linked
+   statically into some executable.  */
+# if defined DLL_EXPORT
+#  define DLL_EXPORTED __declspec(dllexport)
+# else
+#  define DLL_EXPORTED
+# endif
 #else
 # define DLL_EXPORTED
 #endif
index de2d58470dd6fc6b1b2d204cc4a91c5c4724b89f..836cc07329417fd091384ed8f47de3e83e20c719 100644 (file)
@@ -64,7 +64,20 @@ char *alloca ();
 #if HAVE_VISIBILITY && BUILDING_DLL
 # define DLL_EXPORTED __attribute__((__visibility__("default")))
 #elif defined _MSC_VER && BUILDING_DLL
-# define DLL_EXPORTED __declspec(dllexport)
+/* When building with MSVC, exporting a symbol means that the object file
+   contains a "linker directive" of the form /EXPORT:symbol.  This can be
+   inspected through the "objdump -s --section=.drectve FILE" or
+   "dumpbin /directives FILE" commands.
+   The symbols from this file should be exported if and only if the object
+   file gets included in a DLL.  Libtool, on Windows platforms, defines
+   the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
+   and does not define it when compiling an object file meant to be linked
+   statically into some executable.  */
+# if defined DLL_EXPORT
+#  define DLL_EXPORTED __declspec(dllexport)
+# else
+#  define DLL_EXPORTED
+# endif
 #else
 # define DLL_EXPORTED
 #endif
index d18e1f39dd0a56576e6a05430093ee67970c4bd5..ea671833e2ed06fab07117a7cd039f357ed3ecd1 100644 (file)
@@ -1,5 +1,5 @@
 /* setlocale() function that respects the locale chosen by the user.
-   Copyright (C) 2009, 2011, 2013, 2018-2019, 2022 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011, 2013, 2018-2019, 2022-2023 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2009.
 
    This program is free software: you can redistribute it and/or modify
 #if HAVE_VISIBILITY && BUILDING_DLL
 # define DLL_EXPORTED __attribute__((__visibility__("default")))
 #elif defined _MSC_VER && BUILDING_DLL
-# define DLL_EXPORTED __declspec(dllexport)
+/* When building with MSVC, exporting a symbol means that the object file
+   contains a "linker directive" of the form /EXPORT:symbol.  This can be
+   inspected through the "objdump -s --section=.drectve FILE" or
+   "dumpbin /directives FILE" commands.
+   The symbols from this file should be exported if and only if the object
+   file gets included in a DLL.  Libtool, on Windows platforms, defines
+   the C macro DLL_EXPORT (together with PIC) when compiling for a DLL
+   and does not define it when compiling an object file meant to be linked
+   statically into some executable.  */
+# if defined DLL_EXPORT
+#  define DLL_EXPORTED __declspec(dllexport)
+# else
+#  define DLL_EXPORTED
+# endif
 #else
 # define DLL_EXPORTED
 #endif