From 4f4171d80638281dfd26f04e7ef5429bbf37685e Mon Sep 17 00:00:00 2001
From: Isuru Fernando <isuruf@gmail.com>
Date: Sun, 5 Apr 2020 23:57:06 +0000
Subject: [PATCH 4/5] Manually link with libiconv whenever we use libintl.
 Sadly our Windows libintl DLL doesn't convey that it should pull in libiconv
 as a dependency (nor does it use pkg-config). Until I figure that out, let's
 just manually link with libintl when needed. There is also some hacking of
 gconvert.c and the toplevel meson.build file needed to adjust the build
 system -- it assumes that on Windows you're always going to use an internal
 iconv. Original Author: Peter Williams <peter@newton.cx>

---
 gio/win32/meson.build | 2 +-
 glib/gconvert.c       | 6 ------
 meson.build           | 6 +++---
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/gio/win32/meson.build b/gio/win32/meson.build
index 6699f10..1011270 100644
--- a/gio/win32/meson.build
+++ b/gio/win32/meson.build
@@ -15,7 +15,7 @@ giowin32_lib = static_library('giowin32',
     gioenumtypes_dep,
     libglib_dep,
     gmodule_inc_dep,
-  ],
+  ] + libiconv,
   gnu_symbol_visibility : 'hidden',
   pic : true,
   c_args : [gio_c_args, gio_c_args_internal])
diff --git a/glib/gconvert.c b/glib/gconvert.c
index e0cbdcf..c109111 100644
--- a/glib/gconvert.c
+++ b/glib/gconvert.c
@@ -23,18 +23,12 @@
 #include "config.h"
 #include "glibconfig.h"
 
-#ifndef G_OS_WIN32
 #include <iconv.h>
-#endif
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 
-#ifdef G_OS_WIN32
-#include "win_iconv.c"
-#endif
-
 #ifdef G_PLATFORM_WIN32
 #define STRICT
 #include <windows.h>
diff --git a/meson.build b/meson.build
index c659096..695f8b1 100644
--- a/meson.build
+++ b/meson.build
@@ -2191,7 +2191,7 @@ glibconfig_conf.set10('G_HAVE_GROWING_STACK', growing_stack)
 # We should never use the MinGW C library's iconv because it may not be
 # available in the actual runtime environment. On Windows, we always use
 # the built-in implementation
-if host_system == 'windows'
+if host_system == 'IGNOREME windows'
   # We have a #include "win_iconv.c" in gconvert.c on Windows, so we don't need
   # any external library for it
   libiconv = []
@@ -2274,8 +2274,8 @@ if libintl.found() and libintl.type_name() != 'internal'
   #
   # Meson's builtin dependency lookup as of 0.60.0 doesn't check for
   # pthread, so we do this manually here.
-  if cc.has_function('ngettext', dependencies : libintl, prefix: libintl_prefix)
-    libintl_deps += [libintl]
+  if cc.has_function('ngettext', dependencies : [libintl] + libiconv, prefix: libintl_prefix)
+    libintl_deps += [libintl] + libiconv
   else
     libintl_iconv = cc.find_library('iconv', required : false)
     if libintl_iconv.found() and cc.has_function('ngettext', args : osx_ldflags, dependencies : [libintl, libintl_iconv])
