From d7490b79ce621dc4d859c1a82712f2ffe7366593 Mon Sep 17 00:00:00 2001
From: Peter Williams <peter@newton.cx>
Date: Mon, 3 Sep 2018 17:34:54 -0400
Subject: [PATCH 3/8] Fix some DLL export markings in libintl.

A few files had inconsistent labeling for DLL exporting, which I guess MSVC
might be pickier about than it used to be. Tidy them up.
---
 gettext-runtime/gnulib-lib/relocatable.c |  2 +-
 gettext-runtime/intl/libgnuintl.in.h     | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/gettext-runtime/gnulib-lib/relocatable.c b/gettext-runtime/gnulib-lib/relocatable.c
index 365c085..5f7fad6 100644
--- a/gettext-runtime/gnulib-lib/relocatable.c
+++ b/gettext-runtime/gnulib-lib/relocatable.c
@@ -164,7 +164,7 @@ set_this_relocation_prefix (const char *orig_prefix_arg,
    by the corresponding pathname with the current prefix instead.  Both
    prefixes should be directory names without trailing slash (i.e. use ""
    instead of "/").  */
-void
+RELOCATABLE_DLL_EXPORTED void
 set_relocation_prefix (const char *orig_prefix_arg, const char *curr_prefix_arg)
 {
   set_this_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
diff --git a/gettext-runtime/intl/libgnuintl.in.h b/gettext-runtime/intl/libgnuintl.in.h
index ae81ffe..487675d 100644
--- a/gettext-runtime/intl/libgnuintl.in.h
+++ b/gettext-runtime/intl/libgnuintl.in.h
@@ -48,6 +48,15 @@
 # undef gettext
 #endif
 
+
+#if HAVE_VISIBILITY && BUILDING_DLL
+# define DLL_EXPORTED __attribute__((__visibility__("default")))
+#elif defined _MSC_VER && BUILDING_DLL
+# define DLL_EXPORTED __declspec(dllexport)
+#else
+# define DLL_EXPORTED
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -1095,7 +1104,7 @@ char *setlocale (int __category, const char *__locale)
 #    undef setlocale
 #    define setlocale libintl_setlocale
 #   endif
-extern char *setlocale (int, const char *)
+extern DLL_EXPORTED char *setlocale (int, const char *)
        _INTL_ASM (libintl_setlocale);
 #   if defined _INTL_REDIRECT_MACROS && defined __cplusplus && !defined _INTL_CXX_NO_CLOBBER_STD_NAMESPACE
 namespace std { using ::libintl_setlocale; }
@@ -1123,7 +1132,7 @@ locale_t newlocale (int __category_mask, const char *__name, locale_t __base)
 #     undef newlocale
 #     define newlocale libintl_newlocale
 #    endif
-extern locale_t newlocale (int, const char *, locale_t)
+extern DLL_EXPORTED locale_t newlocale (int, const char *, locale_t)
        _INTL_ASM (libintl_newlocale);
 #    if defined _INTL_REDIRECT_MACROS && defined __cplusplus && !defined _INTL_CXX_NO_CLOBBER_STD_NAMESPACE
 namespace std { using ::libintl_newlocale; }
@@ -1144,7 +1153,7 @@ namespace std { using ::libintl_newlocale; }
    prefixes should be directory names without trailing slash (i.e. use ""
    instead of "/").  */
 #define libintl_set_relocation_prefix libintl_set_relocation_prefix
-extern void
+extern DLL_EXPORTED void
        libintl_set_relocation_prefix (const char *orig_prefix,
                                       const char *curr_prefix);
 
diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac
index dcbf1d7..47b0a1c 100644
--- a/gettext-tools/configure.ac
+++ b/gettext-tools/configure.ac
@@ -392,8 +392,12 @@ AH_BOTTOM([
    the C macro DLL_EXPORT (together with PIC) when compiling for a shared
    library (called DLL under Windows) and does not define it when compiling
    an object file meant to be linked statically into some executable.  */
-#if (defined _WIN32 || defined __CYGWIN__) && defined DLL_EXPORT && !defined IN_RELOCWRAPPER
-# define DLL_VARIABLE __declspec (dllimport)
+#if (defined _WIN32 || defined __CYGWIN__) && !defined IN_RELOCWRAPPER
+# if defined DLL_EXPORT
+#  define DLL_VARIABLE __declspec (dllexport)
+# else
+#  define DLL_VARIABLE __declspec (dllimport)
+# endif
 #else
 # define DLL_VARIABLE
 #endif
diff --git a/gettext-runtime/intl/configure.ac b/gettext-runtime/intl/configure.ac
index 749a700..a74c122 100755
--- a/gettext-runtime/intl/configure.ac
+++ b/gettext-runtime/intl/configure.ac
@@ -235,8 +235,12 @@ AH_BOTTOM([
    the C macro DLL_EXPORT (together with PIC) when compiling for a shared
    library (called DLL under Windows) 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)
+#if defined _MSC_VER && !defined IN_RELOCWRAPPER
+# if defined DLL_EXPORT
+#  define DLL_VARIABLE __declspec (dllexport)
+# else
+#  define DLL_VARIABLE __declspec (dllimport)
+# endif
 #else
 # define DLL_VARIABLE
 #endif
