From 65df41744435ab80f50e0b592320832fd138adc5 Mon Sep 17 00:00:00 2001
From: George Hartzell <hartzell@alerce.com>
Date: Thu, 8 Dec 2016 09:43:29 -0800
Subject: [PATCH] Update emacs: current release, use our x11 bits (#2052)

* Update emacs: current release, use our x11 bits

Add checksum for 25.1 release.

Rework the X support:

- use Spack's X11 bits
- add ability to specify an X toolkit (gtk or athena, default is gtk).
- change toolkit names to align with Emacs' configure usage.

* PEP8 cleanups.

* glib dependency should not be type=build

I'd like to blame that on a typo, but it's a few too many characters
for that to be viable.  I'm not sure what I was thinking.

* Pass X variant down: emacs->pango->cairo

* X variants default to False, warn on bad toolkit

Change the X variants for emacs, pango and cairo to default to False.

Check that the toolkit is a valid choice and give a reasonable error if
not.

* Fix flake8 issue, reword warning text

* gtkplus needs to use +X variant for pango to work

In order for a useful variant of pango to be built into the spec I
needed to make the dependency on gtkplus explicitly specify it's X
variant.  The X variant is the default, but that wasn't enough to make
it happy.  Since it's happiness is the most imporant thing in the
world, this change! :)
---
 .../repos/builtin/packages/emacs/package.py   | 21 +++++++++----------
 .../builtin/packages/gdk-pixbuf/package.py    |  2 ++
 .../repos/builtin/packages/gtkplus/package.py |  6 +++++-
 .../repos/builtin/packages/pango/package.py   |  4 ++++
 4 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/var/spack/repos/builtin/packages/emacs/package.py b/var/spack/repos/builtin/packages/emacs/package.py
index 238f766240..1f9caee24c 100644
--- a/var/spack/repos/builtin/packages/emacs/package.py
+++ b/var/spack/repos/builtin/packages/emacs/package.py
@@ -23,7 +23,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ##############################################################################
 from spack import *
-import llnl.util.tty as tty
 
 
 class Emacs(Package):
@@ -35,32 +34,32 @@ class Emacs(Package):
     version('25.1', '95c12e6a9afdf0dcbdd7d2efa26ca42c')
     version('24.5', 'd74b597503a68105e61b5b9f6d065b44')
 
-    variant('X', default=True, description="Enable a X toolkit (GTK+)")
-    variant('gtkplus', default=False,
-            description="Enable a GTK+ as X toolkit (ignored if ~X)")
+    variant('X', default=False, description="Enable an X toolkit")
+    variant('toolkit', default='gtk',
+            description="Select an X toolkit (gtk, athena)")
 
     depends_on('ncurses')
     depends_on('libtiff', when='+X')
     depends_on('libpng', when='+X')
     depends_on('libxpm', when='+X')
     depends_on('giflib', when='+X')
-    depends_on('gtkplus', when='+X+gtkplus')
+    depends_on('libx11', when='+X')
+    depends_on('libxaw', when='+X toolkit=athena')
+    depends_on('gtkplus+X', when='+X toolkit=gtk')
 
     def install(self, spec, prefix):
         args = []
+        toolkit = spec.variants['toolkit'].value
         if '+X' in spec:
-            if '+gtkplus' in spec:
-                toolkit = 'gtk{0}'.format(spec['gtkplus'].version.up_to(1))
-            else:
-                toolkit = 'no'
+            if toolkit not in ('gtk', 'athena'):
+                raise InstallError("toolkit must be in (gtk, athena), not %s" %
+                                   toolkit)
             args = [
                 '--with-x',
                 '--with-x-toolkit={0}'.format(toolkit)
             ]
         else:
             args = ['--without-x']
-            if '+gtkplus' in spec:
-                tty.warn('The variant +gtkplus is ignored if ~X is selected.')
 
         configure('--prefix={0}'.format(prefix), *args)
 
diff --git a/var/spack/repos/builtin/packages/gdk-pixbuf/package.py b/var/spack/repos/builtin/packages/gdk-pixbuf/package.py
index d7a0200395..4d39086b06 100644
--- a/var/spack/repos/builtin/packages/gdk-pixbuf/package.py
+++ b/var/spack/repos/builtin/packages/gdk-pixbuf/package.py
@@ -36,6 +36,8 @@ class GdkPixbuf(Package):
 
     version('2.31.2', '6be6bbc4f356d4b79ab4226860ab8523')
 
+    depends_on("pkg-config", type="build")
+    depends_on("gettext")
     depends_on("glib")
     depends_on("jpeg")
     depends_on("libpng")
diff --git a/var/spack/repos/builtin/packages/gtkplus/package.py b/var/spack/repos/builtin/packages/gtkplus/package.py
index 183662dd0e..b0b11db64f 100644
--- a/var/spack/repos/builtin/packages/gtkplus/package.py
+++ b/var/spack/repos/builtin/packages/gtkplus/package.py
@@ -34,10 +34,14 @@ class Gtkplus(Package):
         '2.24.25', '612350704dd3aacb95355a4981930c6f',
         url="http://ftp.gnome.org/pub/gnome/sources/gtk+/2.24/gtk+-2.24.25.tar.xz")
 
+    variant('X', default=True, description="Enable an X toolkit")
+
     depends_on("atk")
     depends_on("gdk-pixbuf")
-    depends_on("pango")
     depends_on("glib")
+    depends_on("pango")
+    depends_on("pango~X", when='~X')
+    depends_on("pango+X", when='+X')
 
     def patch(self):
         # remove disable deprecated flag.
diff --git a/var/spack/repos/builtin/packages/pango/package.py b/var/spack/repos/builtin/packages/pango/package.py
index 5cf3edb8da..579e5a0984 100644
--- a/var/spack/repos/builtin/packages/pango/package.py
+++ b/var/spack/repos/builtin/packages/pango/package.py
@@ -38,9 +38,13 @@ class Pango(Package):
     version('1.36.8', '217a9a753006275215fa9fa127760ece')
     version('1.40.1', '6fc88c6529890d6c8e03074d57a3eceb')
 
+    variant('X', default=False, description="Enable an X toolkit")
+
     depends_on("pkg-config", type="build")
     depends_on("harfbuzz")
     depends_on("cairo")
+    depends_on("cairo~X", when='~X')
+    depends_on("cairo+X", when='+X')
     depends_on("glib")
 
     def install(self, spec, prefix):
-- 
GitLab