diff --git a/var/spack/repos/builtin/packages/ImageMagick/package.py b/var/spack/repos/builtin/packages/ImageMagick/package.py
index b0ccba100992bd5cedde4f14267de5e0573b2877..61d4cc0cb49a28fa4479ea514434a28787214d76 100644
--- a/var/spack/repos/builtin/packages/ImageMagick/package.py
+++ b/var/spack/repos/builtin/packages/ImageMagick/package.py
@@ -26,29 +26,14 @@
 
 
 class Imagemagick(Package):
-    """ImageMagick is a image processing library"""
-    homepage = "http://www.imagemagic.org"
-
-    # -------------------------------------------------------------------------
-    # ImageMagick does not keep around anything but *-10 versions, so
-    # this URL may change.  If you want the bleeding edge, you can
-    # uncomment it and see if it works but you may need to try to
-    # fetch a newer version (-6, -7, -8, -9, etc.) or you can stick
-    # wtih the older, stable, archived -10 versions below.
-    #
-    # TODO: would be nice if spack had a way to recommend avoiding a
-    # TODO: bleeding edge version, but not comment it out.
-    # -------------------------------------------------------------------------
-    # version('6.9.0-6', 'c1bce7396c22995b8bdb56b7797b4a1b',
-    # url="http://www.imagemagick.org/download/ImageMagick-6.9.0-6.tar.bz2")
-
-    # -------------------------------------------------------------------------
-    # *-10 versions are archived, so these versions should fetch reliably.
-    # -------------------------------------------------------------------------
-    version(
-        '6.8.9-10',
-        'aa050bf9785e571c956c111377bbf57c',
-        url="http://sourceforge.net/projects/imagemagick/files/old-sources/6.x/6.8/ImageMagick-6.8.9-10.tar.gz/download")
+    """ImageMagick is a software suite to create, edit, compose,
+    or convert bitmap images."""
+
+    homepage = "http://www.imagemagick.org"
+    url = "https://github.com/ImageMagick/ImageMagick/archive/7.0.2-7.tar.gz"
+
+    version('7.0.2-7', 'c59cdc8df50e481b2bd1afe09ac24c08')
+    version('7.0.2-6', 'aa5689129c39a5146a3212bf5f26d478')
 
     depends_on('jpeg')
     depends_on('libtool', type='build')
@@ -56,8 +41,14 @@ class Imagemagick(Package):
     depends_on('freetype')
     depends_on('fontconfig')
     depends_on('libtiff')
+    depends_on('ghostscript')
+
+    def url_for_version(self, version):
+        return "https://github.com/ImageMagick/ImageMagick/archive/{0}.tar.gz".format(version)
 
     def install(self, spec, prefix):
-        configure("--prefix=%s" % prefix)
+        configure('--prefix={0}'.format(prefix))
+
         make()
-        make("install")
+        make('check')
+        make('install')
diff --git a/var/spack/repos/builtin/packages/ghostscript/package.py b/var/spack/repos/builtin/packages/ghostscript/package.py
index c22b90088e32f64483bbe05ec199d0c6d3ac7dd6..f63ebac0c148b2b11156ee7c3f98ad313d8c4045 100644
--- a/var/spack/repos/builtin/packages/ghostscript/package.py
+++ b/var/spack/repos/builtin/packages/ghostscript/package.py
@@ -26,16 +26,20 @@
 
 
 class Ghostscript(Package):
-    """an interpreter for the PostScript language and for PDF. """
+    """An interpreter for the PostScript language and for PDF."""
+
     homepage = "http://ghostscript.com/"
-    url      = "http://downloads.ghostscript.com/public/old-gs-releases/ghostscript-9.18.tar.gz"
+    url = "http://downloads.ghostscript.com/public/old-gs-releases/ghostscript-9.18.tar.gz"
 
     version('9.18', '33a47567d7a591c00a253caddd12a88a')
 
     parallel = False
 
+    depends_on('libtiff')
+
     def install(self, spec, prefix):
-        configure("--prefix=%s" % prefix, "--enable-shared")
+        configure('--prefix={0}'.format(prefix),
+                  '--with-system-libtiff')
 
         make()
-        make("install")
+        make('install')
diff --git a/var/spack/repos/builtin/packages/pcre/package.py b/var/spack/repos/builtin/packages/pcre/package.py
index 6f306ab0f9cd6595d997db6f56d7e4872018761f..a2236e682b0aadbdaaa26ec7489d3b54ea264cc8 100644
--- a/var/spack/repos/builtin/packages/pcre/package.py
+++ b/var/spack/repos/builtin/packages/pcre/package.py
@@ -32,10 +32,10 @@ class Pcre(Package):
     homepage = "http://www.pcre.org"""
     url      = "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.bz2"
 
-    version('8.36', 'b767bc9af0c20bc9c1fe403b0d41ad97')
+    version('8.39', 'e3fca7650a0556a2647821679d81f585')
     version('8.38', '00aabbfe56d5a48b270f999b508c5ad2')
 
-    patch("intel.patch")
+    patch("intel.patch", when='@8.38')
 
     variant('utf', default=True,
             description='Enable support for UTF-8/16/32, '
diff --git a/var/spack/repos/builtin/packages/py-cycler/package.py b/var/spack/repos/builtin/packages/py-cycler/package.py
new file mode 100644
index 0000000000000000000000000000000000000000..16da057f2196dde5df673dced9e55edb37e23b64
--- /dev/null
+++ b/var/spack/repos/builtin/packages/py-cycler/package.py
@@ -0,0 +1,42 @@
+##############################################################################
+# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/llnl/spack
+# Please also see the LICENSE file for our notice and the LGPL.
+#
+# 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 the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+from spack import *
+
+
+class PyCycler(Package):
+    """Composable style cycles."""
+
+    homepage = "http://matplotlib.org/cycler/"
+    url      = "https://github.com/matplotlib/cycler/archive/v0.10.0.tar.gz"
+
+    version('0.10.0', '83dd0df7810e838b59e4dd9fa6e2d198')
+
+    extends('python')
+
+    depends_on('py-setuptools', type='build')
+    depends_on('py-six',        type=nolink)
+
+    def install(self, spec, prefix):
+        setup_py('install', '--prefix={0}'.format(prefix))
diff --git a/var/spack/repos/builtin/packages/py-matplotlib/package.py b/var/spack/repos/builtin/packages/py-matplotlib/package.py
index c454a47ec31b3f434382afa77b30f4b0f2b6e085..0b8ff4715d1c54bba52e28620d91d13b2edc3766 100644
--- a/var/spack/repos/builtin/packages/py-matplotlib/package.py
+++ b/var/spack/repos/builtin/packages/py-matplotlib/package.py
@@ -27,55 +27,73 @@
 
 
 class PyMatplotlib(Package):
-    """Python plotting package."""
+    """matplotlib is a python 2D plotting library which produces publication
+    quality figures in a variety of hardcopy formats and interactive
+    environments across platforms."""
+
     homepage = "https://pypi.python.org/pypi/matplotlib"
     url      = "https://pypi.python.org/packages/source/m/matplotlib/matplotlib-1.4.2.tar.gz"
 
-    version('1.4.2', '7d22efb6cce475025733c50487bd8898')
+    version('1.5.1', 'f51847d8692cb63df64cd0bd0304fd20')
     version('1.4.3', '86af2e3e3c61849ac7576a6f5ca44267')
+    version('1.4.2', '7d22efb6cce475025733c50487bd8898')
 
-    variant('gui', default=False, description='Enable GUI')
+    variant('gui',     default=False, description='Enable GUI')
     variant('ipython', default=False, description='Enable ipython support')
 
+    # Python 2.7, 3.4, or 3.5
     extends('python', ignore=r'bin/nosetests.*$|bin/pbr$')
 
-    depends_on('py-setuptools', type='build')
+    # Required dependencies
+    depends_on('py-numpy@1.6:',    type=nolink)
+    depends_on('py-setuptools',    type='build')
+    depends_on('py-dateutil@1.1:', type=nolink)
+    depends_on('py-pyparsing',     type=nolink)
+    depends_on('libpng@1.2:')
+    depends_on('py-pytz',          type=nolink)
+    depends_on('freetype@2.3:')
+    depends_on('py-cycler@0.9:',   type=nolink)
+
+    # Optional GUI framework
+    depends_on('tk@8.3:',   when='+gui')  # not 8.6.0 or 8.6.1
+    depends_on('qt',        when='+gui')
     depends_on('py-pyside', when='+gui', type=nolink)
-    depends_on('py-ipython', when='+ipython', type=nolink)
-    depends_on('py-pyparsing', type=nolink)
-    depends_on('py-six', type=nolink)
-    depends_on('py-dateutil', type=nolink)
-    depends_on('py-pytz', type=nolink)
-    depends_on('py-nose', type=nolink)
-    depends_on('py-numpy', type=nolink)
-    depends_on('py-mock', type=nolink)
-    depends_on('py-pbr', type=nolink)
-    depends_on('py-funcsigs', type=nolink)
+    # TODO: Add more GUI dependencies
 
+    # Optional external programs
+    # ffmpeg/avconv or mencoder
+    depends_on('ImageMagick')
+
+    # Optional dependencies
+    depends_on('py-pillow',  type=nolink)
     depends_on('pkg-config', type='build')
-    depends_on('freetype')
-    depends_on('qt', when='+gui')
-    depends_on('bzip2')
-    depends_on('tcl', when='+gui')
-    depends_on('tk', when='+gui')
-    depends_on('qhull')
+    depends_on('py-ipython', when='+ipython')
+
+    # Testing dependencies
+    depends_on('py-nose')  # type='test'
+    depends_on('py-mock')  # type='test'
+
+    # Required libraries that ship with matplotlib
+    # depends_on('agg@2.4:')
+    depends_on('qhull@2012.1:')
+    # depends_on('ttconv')
+    depends_on('py-six@1.9.0:', type=nolink)
 
     def install(self, spec, prefix):
-        python('setup.py', 'install', '--prefix=%s' % prefix)
+        setup_py('build')
+        setup_py('install', '--prefix={0}'.format(prefix))
 
-        if str(self.version) in ['1.4.2', '1.4.3']:
-            # hack to fix configuration file
+        if '+gui' in spec:
+            # Set backend in matplotlib configuration file
             config_file = None
             for p, d, f in os.walk(prefix.lib):
                 for file in f:
                     if file.find('matplotlibrc') != -1:
                         config_file = join_path(p, 'matplotlibrc')
-                        print config_file
-            if config_file is None:
-                raise InstallError('could not find config file')
-            filter_file(r'backend      : pyside',
-                        'backend      : Qt4Agg',
-                        config_file)
-            filter_file(r'#backend.qt4 : PyQt4',
-                        'backend.qt4 : PySide',
-                        config_file)
+            if not config_file:
+                raise InstallError('Could not find matplotlibrc')
+
+            kwargs = {'ignore_absent': False, 'backup': False, 'string': False}
+            rc = FileFilter(config_file)
+            rc.filter('^backend.*',      'backend     : Qt4Agg', **kwargs)
+            rc.filter('^#backend.qt4.*', 'backend.qt4 : PySide', **kwargs)
diff --git a/var/spack/repos/builtin/packages/py-pyside/package.py b/var/spack/repos/builtin/packages/py-pyside/package.py
index 1cb3e4745f1bc9064f97a75e456b3a2b2dc176a8..e575864fab249f8a2436d702e92ee1ed831a6f57 100644
--- a/var/spack/repos/builtin/packages/py-pyside/package.py
+++ b/var/spack/repos/builtin/packages/py-pyside/package.py
@@ -31,13 +31,16 @@ class PyPyside(Package):
     homepage = "https://pypi.python.org/pypi/pyside"
     url      = "https://pypi.python.org/packages/source/P/PySide/PySide-1.2.2.tar.gz"
 
-    version('1.2.2', 'c45bc400c8a86d6b35f34c29e379e44d')
+    version('1.2.4', '3cb7174c13bd45e3e8f77638926cb8c0')  # rpath problems
+    version('1.2.2', 'c45bc400c8a86d6b35f34c29e379e44d', preferred=True)
 
     depends_on('cmake', type='build')
 
     extends('python')
     depends_on('py-setuptools', type='build')
-    depends_on('qt@:4')
+    depends_on('qt@4.5:4.9')
+    depends_on('libxml2@2.6.32:')
+    depends_on('libxslt@1.1.19:')
 
     def patch(self):
         """Undo PySide RPATH handling and add Spack RPATH."""
@@ -58,12 +61,23 @@ def patch(self):
 
         # PySide tries to patch ELF files to remove RPATHs
         # Disable this and go with the one we set.
-        filter_file(
-            r'^\s*rpath_cmd\(pyside_path, srcpath\)',
-            r'#rpath_cmd(pyside_path, srcpath)',
-            'pyside_postinstall.py')
+        if self.spec.satisfies('@1.2.4:'):
+            rpath_file = 'setup.py'
+        else:
+            rpath_file = 'pyside_postinstall.py'
+
+        filter_file(r'(^\s*)(rpath_cmd\(.*\))', r'\1#\2', rpath_file)
+
+        # TODO: rpath handling for PySide 1.2.4 still doesn't work.
+        # PySide can't find the Shiboken library, even though it comes
+        # bundled with it and is installed in the same directory.
+
+        # PySide does not provide official support for
+        # Python 3.5, but it should work fine
+        filter_file("'Programming Language :: Python :: 3.4'",
+                    "'Programming Language :: Python :: 3.4',\r\n        "
+                    "'Programming Language :: Python :: 3.5'",
+                    "setup.py")
 
     def install(self, spec, prefix):
-        python('setup.py', 'install',
-               '--prefix=%s' % prefix,
-               '--jobs=%s' % make_jobs)
+        setup_py('install', '--prefix=%s' % prefix, '--jobs=%s' % make_jobs)
diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py
index c4e67549690faa84d28188501eef6135ef9b5a4b..57783b05426937d40b108dd0468efbd91963353f 100644
--- a/var/spack/repos/builtin/packages/python/package.py
+++ b/var/spack/repos/builtin/packages/python/package.py
@@ -133,6 +133,8 @@ def install(self, spec, prefix):
     # TODO: Once better testing support is integrated, add the following tests
     # https://wiki.python.org/moin/TkInter
     #
+    # Note: Only works if ForwardX11Trusted is enabled, i.e. `ssh -Y`
+    #
     #    if '+tk' in spec:
     #        env['TK_LIBRARY']  = join_path(spec['tk'].prefix.lib,
     #            'tk{0}'.format(spec['tk'].version.up_to(2)))
diff --git a/var/spack/repos/builtin/packages/qhull/package.py b/var/spack/repos/builtin/packages/qhull/package.py
index 2733d8b65256b33df610a2b57637d45e32fe531b..462a681ad997cf86132ea37d86b9c2ef26c1a500 100644
--- a/var/spack/repos/builtin/packages/qhull/package.py
+++ b/var/spack/repos/builtin/packages/qhull/package.py
@@ -37,16 +37,13 @@ class Qhull(Package):
 
     homepage = "http://www.qhull.org"
 
-    version('7.2.0', 'e6270733a826a6a7c32b796e005ec3dc',
+    version('2015.2', 'e6270733a826a6a7c32b796e005ec3dc',
             url="http://www.qhull.org/download/qhull-2015-src-7.2.0.tgz")
 
-    version('1.0', 'd0f978c0d8dfb2e919caefa56ea2953c',
+    version('2012.1', 'd0f978c0d8dfb2e919caefa56ea2953c',
             url="http://www.qhull.org/download/qhull-2012.1-src.tgz")
 
-    # https://github.com/qhull/qhull/pull/5
-    patch('qhull-iterator.patch', when='@1.0')
-
-    depends_on('cmake', type='build')
+    depends_on('cmake@2.6:', type='build')
 
     def install(self, spec, prefix):
         with working_dir('spack-build', create=True):
diff --git a/var/spack/repos/builtin/packages/qhull/qhull-iterator.patch b/var/spack/repos/builtin/packages/qhull/qhull-iterator.patch
deleted file mode 100644
index 88e931d84f2f0e7dfdb9a50b466cecbfbd2722e5..0000000000000000000000000000000000000000
--- a/var/spack/repos/builtin/packages/qhull/qhull-iterator.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From 93f4b306c54bb5be7724dcc19c6e747b62ac76dd Mon Sep 17 00:00:00 2001
-From: Ben Boeckel <mathstuf@gmail.com>
-Date: Thu, 28 May 2015 11:12:25 -0400
-Subject: [PATCH] iterator: use the header
-
-Standard libraries are doing funky things with inline namespaces which
-make these declarations impossible to get right. Just include the
-header.
----
- src/libqhullcpp/QhullIterator.h   | 3 +--
- src/libqhullcpp/QhullLinkedList.h | 5 +----
- 2 files changed, 2 insertions(+), 6 deletions(-)
-
-diff --git a/src/libqhullcpp/QhullIterator.h b/src/libqhullcpp/QhullIterator.h
-index 9dde894..49f3a3b 100644
---- a/src/libqhullcpp/QhullIterator.h
-+++ b/src/libqhullcpp/QhullIterator.h
-@@ -14,10 +14,9 @@ extern "C" {
- }
- 
- #include <assert.h>
-+#include <iterator>
- #include <string>
- #include <vector>
--//! Avoid dependence on <iterator>
--namespace std { struct bidirectional_iterator_tag; struct random_access_iterator_tag; }
- 
- namespace orgQhull {
- 
-diff --git a/src/libqhullcpp/QhullLinkedList.h b/src/libqhullcpp/QhullLinkedList.h
-index d828ac6..00b9008 100644
---- a/src/libqhullcpp/QhullLinkedList.h
-+++ b/src/libqhullcpp/QhullLinkedList.h
-@@ -9,10 +9,7 @@
- #ifndef QHULLLINKEDLIST_H
- #define QHULLLINKEDLIST_H
- 
--namespace std {
--    struct bidirectional_iterator_tag;
--    struct random_access_iterator_tag;
--}//std
-+#include <iterator>
- 
- #include "QhullError.h"
- extern "C" {
diff --git a/var/spack/repos/builtin/packages/qt/btn_trigger_happy.patch b/var/spack/repos/builtin/packages/qt/btn_trigger_happy.patch
new file mode 100644
index 0000000000000000000000000000000000000000..e6a27d5fab3ff276836a31c4dd648305556b41cf
--- /dev/null
+++ b/var/spack/repos/builtin/packages/qt/btn_trigger_happy.patch
@@ -0,0 +1,17 @@
+--- a/qtgamepad/src/plugins/gamepads/evdev/qevdevgamepadbackend.cpp	2016-08-08 11:34:44.517184658 -0500
++++ b/qtgamepad/src/plugins/gamepads/evdev/qevdevgamepadbackend.cpp	2016-08-08 11:36:42.371995567 -0500
+@@ -262,10 +262,10 @@
+     m_buttonsMap[BTN_TR2] = QGamepadManager::ButtonR2;
+     m_buttonsMap[BTN_THUMB] = m_buttonsMap[BTN_THUMBL] = QGamepadManager::ButtonL3;
+     m_buttonsMap[BTN_THUMBR] = QGamepadManager::ButtonR3;
+-    m_buttonsMap[BTN_TRIGGER_HAPPY1] = QGamepadManager::ButtonLeft;
+-    m_buttonsMap[BTN_TRIGGER_HAPPY2] = QGamepadManager::ButtonRight;
+-    m_buttonsMap[BTN_TRIGGER_HAPPY3] = QGamepadManager::ButtonUp;
+-    m_buttonsMap[BTN_TRIGGER_HAPPY4] = QGamepadManager::ButtonDown;
++    m_buttonsMap[0x2c0] = QGamepadManager::ButtonLeft;
++    m_buttonsMap[0x2c1] = QGamepadManager::ButtonRight;
++    m_buttonsMap[0x2c2] = QGamepadManager::ButtonUp;
++    m_buttonsMap[0x2c3] = QGamepadManager::ButtonDown;
+ 
+     if (m_productId)
+         m_backend->saveSettings(m_productId, QVariant());
diff --git a/var/spack/repos/builtin/packages/qt/package.py b/var/spack/repos/builtin/packages/qt/package.py
index 4239fa292bb73877b5c4f0fc723c94bfb5f00345..436702fa4e4feed2f20830d1109ff2e754b078a0 100644
--- a/var/spack/repos/builtin/packages/qt/package.py
+++ b/var/spack/repos/builtin/packages/qt/package.py
@@ -29,7 +29,11 @@
 class Qt(Package):
     """Qt is a comprehensive cross-platform C++ application framework."""
     homepage = 'http://qt.io'
+    url      = 'http://download.qt.io/archive/qt/5.7/5.7.0/single/qt-everywhere-opensource-src-5.7.0.tar.gz'
+    list_url = 'http://download.qt.io/archive/qt/'
+    list_depth = 4
 
+    version('5.7.0',  '9a46cce61fc64c20c3ac0a0e0fa41b42')
     version('5.5.1',  '59f0216819152b77536cf660b015d784')
     version('5.4.2',  'fa1c4d819b401b267eb246a543a63ea5')
     version('5.4.0',  'e8654e4b37dd98039ba20da7a53877e6')
@@ -40,17 +44,18 @@ class Qt(Package):
 
     # Add patch for compile issues with qt3 found with use in the
     # OpenSpeedShop project
-    variant('krellpatch', default=False,
-            description="Build with openspeedshop based patch.")
+    variant('krellpatch', default=False, description="Build with openspeedshop based patch.")
     variant('mesa',       default=False, description="Depend on mesa.")
     variant('gtk',        default=False, description="Build with gtkplus.")
 
     patch('qt3krell.patch', when='@3.3.8b+krellpatch')
 
+    # https://github.com/xboxdrv/xboxdrv/issues/188
+    patch('btn_trigger_happy.patch', when='@5.7.0:')
+
     # Use system openssl for security.
     # depends_on("openssl")
 
-    depends_on("glib")
     depends_on("gtkplus", when='+gtk')
     depends_on("libxml2")
     depends_on("zlib")
@@ -73,29 +78,33 @@ class Qt(Package):
     depends_on("libxcb")
 
     def url_for_version(self, version):
-        url = "http://download.qt.io/archive/qt/"
+        # URL keeps getting more complicated with every release
+        url = self.list_url
+
+        if version >= Version('4.0'):
+            url += version.up_to(2) + '/'
+        else:
+            url += version.up_to(1) + '/'
+
+        if version >= Version('4.8'):
+            url += str(version) + '/'
 
         if version >= Version('5'):
-            url += "%s/%s/single/qt-everywhere-opensource-src-%s.tar.gz" % \
-                (version.up_to(2), version, version)
-        elif version >= Version('4.8'):
-            url += "%s/%s/qt-everywhere-opensource-src-%s.tar.gz" % \
-                (version.up_to(2), version, version)
-        elif version >= Version('4.6'):
-            url += "%s/qt-everywhere-opensource-src-%s.tar.gz" % \
-                (version.up_to(2), version)
-        elif version >= Version('4.0'):
-            url += "%s/qt-x11-opensource-src-%s.tar.gz" % \
-                (version.up_to(2), version)
-        elif version >= Version('3'):
-            url += "%s/qt-x11-free-%s.tar.gz" % \
-                (version.up_to(1), version)
+            url += 'single/'
+
+        url += 'qt-'
+
+        if version >= Version('4.6'):
+            url += 'everywhere-'
         elif version >= Version('2.1'):
-            url += "%s/qt-x11-%s.tar.gz" % \
-                (version.up_to(1), version)
-        else:
-            url += "%s/qt-%s.tar.gz" % \
-                (version.up_to(1), version)
+            url += 'x11-'
+
+        if version >= Version('4.0'):
+            url += 'opensource-src-'
+        elif version >= Version('3'):
+            url += 'free-'
+
+        url += str(version) + '.tar.gz'
 
         return url
 
@@ -107,27 +116,34 @@ def setup_dependent_environment(self, spack_env, run_env, dspec):
 
     def patch(self):
         if self.spec.satisfies('@4'):
-            qmake_conf      = 'mkspecs/common/g++-base.conf'
-            qmake_unix_conf = 'mkspecs/common/g++-unix.conf'
-        elif self.spec.satisfies('@5'):
-            qmake_conf      = 'qtbase/mkspecs/common/g++-base.conf'
-            qmake_unix_conf = 'qtbase/mkspecs/common/g++-unix.conf'
-        else:
-            return
-
-        # Fix qmake compilers in the default mkspec
-        filter_file(r'^QMAKE_COMPILER *=.*$',
-                    'QMAKE_COMPILER = cc', qmake_conf)
-        filter_file(r'^QMAKE_CC *=.*$',
-                    'QMAKE_CC = cc',       qmake_conf)
-        filter_file(r'^QMAKE_CXX *=.*$',
-                    'QMAKE_CXX = c++',     qmake_conf)
-        filter_file(r'^QMAKE_LFLAGS_NOUNDEF *\+?=.*$',
-                    'QMAKE_LFLAGS_NOUNDEF =', qmake_unix_conf)
+            # Fix qmake compilers in the default mkspec
+            filter_file('^QMAKE_CC .*', 'QMAKE_CC = cc',
+                        'mkspecs/common/g++-base.conf')
+            filter_file('^QMAKE_CXX .*', 'QMAKE_CXX = c++',
+                        'mkspecs/common/g++-base.conf')
+
+            # Necessary to build with GCC 6 and other modern compilers
+            # http://stackoverflow.com/questions/10354371/
+            filter_file('(^QMAKE_CXXFLAGS .*)', r'\1 -std=gnu++98',
+                        'mkspecs/common/gcc-base.conf')
+
+            filter_file('^QMAKE_LFLAGS_NOUNDEF .*', 'QMAKE_LFLAGS_NOUNDEF = ',
+                        'mkspecs/common/g++-unix.conf')
+        elif self.spec.satisfies('@5:'):
+            # Fix qmake compilers in the default mkspec
+            filter_file('^QMAKE_COMPILER .*', 'QMAKE_COMPILER = cc',
+                        'qtbase/mkspecs/common/g++-base.conf')
+            filter_file('^QMAKE_CC .*', 'QMAKE_CC = cc',
+                        'qtbase/mkspecs/common/g++-base.conf')
+            filter_file('^QMAKE_CXX .*', 'QMAKE_CXX = c++',
+                        'qtbase/mkspecs/common/g++-base.conf')
+
+            filter_file('^QMAKE_LFLAGS_NOUNDEF .*', 'QMAKE_LFLAGS_NOUNDEF = ',
+                        'qtbase/mkspecs/common/g++-unix.conf')
 
     @property
     def common_config_args(self):
-        config_args = [
+        return [
             '-prefix', self.prefix,
             '-v',
             '-opensource',
@@ -144,19 +160,12 @@ def common_config_args(self):
             '-no-nis'
         ]
 
-        if '+gtk' in self.spec:
-            config_args.append('-gtkstyle')
-        else:
-            config_args.append('-no-gtkstyle')
-
-        return config_args
-
     # Don't disable all the database drivers, but should
     # really get them into spack at some point.
 
     @when('@3')
     def configure(self):
-        # An user report that this was necessary to link Qt3 on ubuntu
+        # A user reported that this was necessary to link Qt3 on ubuntu
         os.environ['LD_LIBRARY_PATH'] = os.getcwd() + '/lib'
         configure('-prefix', self.prefix,
                   '-v',
@@ -169,18 +178,27 @@ def configure(self):
     def configure(self):
         configure('-fast',
                   '-no-webkit',
+                  '{0}-gtkstyle'.format('' if '+gtk' in self.spec else '-no'),
                   *self.common_config_args)
 
-    @when('@5')
+    @when('@5.0:5.6')
     def configure(self):
         configure('-no-eglfs',
                   '-no-directfb',
                   '-qt-xcb',
-                  # If someone wants to get a webkit build working, be my
-                  # guest!
+                  '{0}-gtkstyle'.format('' if '+gtk' in self.spec else '-no'),
                   '-skip', 'qtwebkit',
                   *self.common_config_args)
 
+    @when('@5.7:')
+    def configure(self):
+        configure('-no-eglfs',
+                  '-no-directfb',
+                  '-qt-xcb',
+                  '{0}-gtk'.format('' if '+gtk' in self.spec else '-no'),
+                  '-skip', 'webengine',
+                  *self.common_config_args)
+
     def install(self, spec, prefix):
         self.configure()
         make()