From 7f095cee48df29312b3e1a1c341b59e0b8731653 Mon Sep 17 00:00:00 2001
From: George Hartzell <hartzell@alerce.com>
Date: Fri, 21 Dec 2018 09:33:28 -0800
Subject: [PATCH] Add libiconv variant to glib (#10165)

Enable explicitly building glib with or without libiconv.

Heads up: if you build with ~iconv but there is something else in the
spec that includes libiconv then glib will *still* automagically
discover it and the build will fail.
---
 var/spack/repos/builtin/packages/glib/package.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/var/spack/repos/builtin/packages/glib/package.py b/var/spack/repos/builtin/packages/glib/package.py
index d27fd86b19..c4838f77e0 100644
--- a/var/spack/repos/builtin/packages/glib/package.py
+++ b/var/spack/repos/builtin/packages/glib/package.py
@@ -32,6 +32,7 @@ class Glib(AutotoolsPackage):
     version('2.48.1', '67bd3b75c9f6d5587b457dc01cdcd5bb')
     version('2.42.1', '89c4119e50e767d3532158605ee9121a')
 
+    variant('iconv', default=False, description='Build with iconv support')
     variant('libmount', default=False, description='Build with libmount support')
     variant(
         'tracing',
@@ -49,6 +50,7 @@ class Glib(AutotoolsPackage):
     depends_on('python', type=('build', 'run'), when='@2.53.4:')
     depends_on('pcre+utf', when='@2.48:')
     depends_on('util-linux', when='+libmount')
+    depends_on('libiconv', when='+iconv')
 
     # The following patch is needed for gcc-6.1
     patch('g_date_strftime.patch', when='@2.42.1')
@@ -72,6 +74,10 @@ def configure_args(self):
             args.append('--with-python={0}'.format(
                 os.path.basename(self.spec['python'].command.path))
             )
+        if self.spec.satisfies('+iconv'):
+            args.append('--with-libiconv=gnu')
+        else:
+            args.append('--with-libiconv=no')
         args.extend(self.enable_or_disable('tracing'))
         # SELinux is not available in Spack, so glib should not use it.
         args.append('--disable-selinux')
-- 
GitLab