From 102bb4ade3274509a7de06a12fe0de720f60b001 Mon Sep 17 00:00:00 2001
From: Sylvester Joosten <sjoosten@anl.gov>
Date: Tue, 1 Dec 2020 14:49:18 +0000
Subject: [PATCH] Add back spack directory

---
 spack/.gitignore                              | 141 ++++
 spack/README.md                               |  27 +
 spack/packages/dawn/exec.patch                |   7 +
 spack/packages/dawn/install.patch             |  12 +
 spack/packages/dawn/package.py                |  51 ++
 spack/packages/dawncut/install.patch          |  20 +
 spack/packages/dawncut/package.py             |  33 +
 spack/packages/dd4hep/package.py              |  97 +++
 spack/packages/dd4hep/tbb-workarounds.patch   |  41 ++
 spack/packages/dd4hep/tbb2.patch              |  14 +
 spack/packages/eicd/package.py                |  31 +
 .../fmt/fmt-attributes-cpp11_4.1.0.patch      |  13 +
 .../fmt/fmt-no-export-cpp11flag_3.0.0.patch   |  13 +
 .../fmt-use-cmake-cxx-standard_3.0.0.patch    |  15 +
 spack/packages/fmt/package.py                 |  86 +++
 spack/packages/geant4/CLHEP-10.03.03.patch    |  34 +
 spack/packages/geant4/cxx17.patch             |  22 +
 spack/packages/geant4/cxx17_geant4_10_0.patch |  22 +
 ...geant4-10.4.3-cxx17-removed-features.patch |  18 +
 spack/packages/geant4/package.py              | 159 +++++
 .../packages/graphviz/fix-quartz-darwin.patch |  30 +
 spack/packages/graphviz/implicit.patch        |  25 +
 spack/packages/graphviz/package.py            | 174 +++++
 spack/packages/graphviz/ps2pdf.patch          |  15 +
 spack/packages/npdet/package.py               |  37 +
 spack/packages/qt/gcc10.patch                 |  22 +
 spack/packages/qt/package.py                  | 606 +++++++++++++++++
 spack/packages/qt/qt3-accept.patch            |  38 ++
 spack/packages/qt/qt3-headers.patch           |  30 +
 spack/packages/qt/qt4-87-configure-gcc.patch  |  20 +
 spack/packages/qt/qt4-asm-volatile.patch      | 236 +++++++
 spack/packages/qt/qt4-configure-gcc.patch     |  20 +
 spack/packages/qt/qt4-mac.patch               | 631 ++++++++++++++++++
 spack/packages/qt/qt4-pcre.patch              |  16 +
 spack/packages/qt/qt4-qforeach.patch          |  64 ++
 spack/packages/qt/qt4-tools.patch             |  12 +
 spack/packages/qt/qt5-11-intel-overflow.patch |  11 +
 spack/packages/qt/qt5-12-configure.patch      |  13 +
 spack/packages/qt/qt5-12-intel-overflow.patch |  11 +
 spack/packages/qt/qt5-8-framework.patch       |  17 +
 spack/packages/qt/qt5-8-freetype.patch        |  12 +
 spack/packages/qt/qt5-asm-volatile.patch      | 235 +++++++
 spack/packages/qt/qt5-btn_trigger_happy.patch |  17 +
 spack/packages/qt/qt5-pcre.patch              |  33 +
 spack/packages/qt/qt5-restore-pc-files.patch  |  15 +
 spack/packages/root/find-mysql.patch          |  60 ++
 .../packages/root/format-stringbuf-size.patch |  14 +
 spack/packages/root/honor-unuran-switch.patch |  26 +
 spack/packages/root/math_uint.patch           | 115 ++++
 spack/packages/root/package.py                | 505 ++++++++++++++
 .../packages/root/root6-60606-mathmore.patch  |  29 +
 spack/packages/root/root7-webgui.patch        | 106 +++
 spack/repo.yaml                               |   2 +
 53 files changed, 4053 insertions(+)
 create mode 100644 spack/.gitignore
 create mode 100644 spack/README.md
 create mode 100644 spack/packages/dawn/exec.patch
 create mode 100644 spack/packages/dawn/install.patch
 create mode 100644 spack/packages/dawn/package.py
 create mode 100644 spack/packages/dawncut/install.patch
 create mode 100644 spack/packages/dawncut/package.py
 create mode 100644 spack/packages/dd4hep/package.py
 create mode 100644 spack/packages/dd4hep/tbb-workarounds.patch
 create mode 100644 spack/packages/dd4hep/tbb2.patch
 create mode 100644 spack/packages/eicd/package.py
 create mode 100644 spack/packages/fmt/fmt-attributes-cpp11_4.1.0.patch
 create mode 100644 spack/packages/fmt/fmt-no-export-cpp11flag_3.0.0.patch
 create mode 100644 spack/packages/fmt/fmt-use-cmake-cxx-standard_3.0.0.patch
 create mode 100644 spack/packages/fmt/package.py
 create mode 100644 spack/packages/geant4/CLHEP-10.03.03.patch
 create mode 100644 spack/packages/geant4/cxx17.patch
 create mode 100644 spack/packages/geant4/cxx17_geant4_10_0.patch
 create mode 100644 spack/packages/geant4/geant4-10.4.3-cxx17-removed-features.patch
 create mode 100644 spack/packages/geant4/package.py
 create mode 100644 spack/packages/graphviz/fix-quartz-darwin.patch
 create mode 100644 spack/packages/graphviz/implicit.patch
 create mode 100644 spack/packages/graphviz/package.py
 create mode 100644 spack/packages/graphviz/ps2pdf.patch
 create mode 100644 spack/packages/npdet/package.py
 create mode 100644 spack/packages/qt/gcc10.patch
 create mode 100644 spack/packages/qt/package.py
 create mode 100644 spack/packages/qt/qt3-accept.patch
 create mode 100644 spack/packages/qt/qt3-headers.patch
 create mode 100644 spack/packages/qt/qt4-87-configure-gcc.patch
 create mode 100644 spack/packages/qt/qt4-asm-volatile.patch
 create mode 100644 spack/packages/qt/qt4-configure-gcc.patch
 create mode 100644 spack/packages/qt/qt4-mac.patch
 create mode 100644 spack/packages/qt/qt4-pcre.patch
 create mode 100644 spack/packages/qt/qt4-qforeach.patch
 create mode 100644 spack/packages/qt/qt4-tools.patch
 create mode 100644 spack/packages/qt/qt5-11-intel-overflow.patch
 create mode 100644 spack/packages/qt/qt5-12-configure.patch
 create mode 100644 spack/packages/qt/qt5-12-intel-overflow.patch
 create mode 100644 spack/packages/qt/qt5-8-framework.patch
 create mode 100644 spack/packages/qt/qt5-8-freetype.patch
 create mode 100644 spack/packages/qt/qt5-asm-volatile.patch
 create mode 100644 spack/packages/qt/qt5-btn_trigger_happy.patch
 create mode 100644 spack/packages/qt/qt5-pcre.patch
 create mode 100644 spack/packages/qt/qt5-restore-pc-files.patch
 create mode 100644 spack/packages/root/find-mysql.patch
 create mode 100644 spack/packages/root/format-stringbuf-size.patch
 create mode 100644 spack/packages/root/honor-unuran-switch.patch
 create mode 100644 spack/packages/root/math_uint.patch
 create mode 100644 spack/packages/root/package.py
 create mode 100644 spack/packages/root/root6-60606-mathmore.patch
 create mode 100644 spack/packages/root/root7-webgui.patch
 create mode 100644 spack/repo.yaml

diff --git a/spack/.gitignore b/spack/.gitignore
new file mode 100644
index 000000000..2927022e8
--- /dev/null
+++ b/spack/.gitignore
@@ -0,0 +1,141 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+cover/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+.pybuilder/
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+#   For a library or package, you might want to ignore these files since the code is
+#   intended to run in multiple environments; otherwise, check them in:
+# .python-version
+
+# pipenv
+#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version
+#   control.
+#   However, in case of collaboration, if having platform-specific dependencies or
+#   dependencies
+#   having no cross-platform support, pipenv may install dependencies that don't work, or
+#   not
+#   install all needed dependencies.
+#Pipfile.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# pytype static type analyzer
+.pytype/
+
+# Cython debug symbols
+cython_debug/
diff --git a/spack/README.md b/spack/README.md
new file mode 100644
index 000000000..32d611093
--- /dev/null
+++ b/spack/README.md
@@ -0,0 +1,27 @@
+# Custom Spack Repository
+
+Extra spack repository with EIC-related packages and overrides. 
+
+## How to load this repository
+To load the repository, clone and then load with spack:
+```bash
+spack clone https://eicweb.phy.anl.gov/containers/eic_container.git
+spack repo add eic_contaienr/spack
+```
+
+Then use spack as you normally would.
+
+## Packages
+  * New packages
+    - `dawn`: A tool to visualize detector geometries.
+    - `dawncut`: A tool to edit detector visualizations.
+  * Package overrides
+    * `dd4hep`: Disabled use of the Ninja backend for cmake as it was running into dependency issues building assymp
+    * `fmt`: Modified compiler flags to build shared library version.
+    * `geant4`: Added explicit glu dependency for OpenGL
+    * `graphviz`: Set upper version limit to stop applying implicit.patch to the newest version
+    * `qt`: Added gcc10.patch to fix issues compiling QT with gcc10
+    * `root`: Re-enabled http module as this builds fine on modern Linux systems and we use this heavily.
+
+
+
diff --git a/spack/packages/dawn/exec.patch b/spack/packages/dawn/exec.patch
new file mode 100644
index 000000000..f0b939a65
--- /dev/null
+++ b/spack/packages/dawn/exec.patch
@@ -0,0 +1,7 @@
+diff --git a/DAWN_GUI_menu.header2 b/DAWN_GUI_menu.header2
+index ef35492..7fa067b 100644
+--- a/DAWN_GUI_menu.header2
++++ b/DAWN_GUI_menu.header2
+@@ -1 +1 @@
+-exec wish "$0" "$@"
++exec wish "$0" ${1+"$@"}
diff --git a/spack/packages/dawn/install.patch b/spack/packages/dawn/install.patch
new file mode 100644
index 000000000..961dfde2b
--- /dev/null
+++ b/spack/packages/dawn/install.patch
@@ -0,0 +1,12 @@
+diff --git a/Makefile b/Makefile
+index 96e42e7..c9bb589 100644
+--- a/Makefile
++++ b/Makefile
+@@ -267,6 +267,7 @@ clean:
+ 
+ ### install 
+ install:
++	mkdir -p $(INSTALL_DIR)
+ 	cp -p ./$(EXEC)    	   $(INSTALL_DIR)/$(EXEC)
+ 	cp -p ./$(GUI_MENU)        $(INSTALL_DIR)/$(GUI_MENU)
+ 	cp -p ./$(EXEC)unixd       $(INSTALL_DIR)/$(EXEC)unixd
diff --git a/spack/packages/dawn/package.py b/spack/packages/dawn/package.py
new file mode 100644
index 000000000..c9d3d050c
--- /dev/null
+++ b/spack/packages/dawn/package.py
@@ -0,0 +1,51 @@
+# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+import os
+
+
+class Dawn(MakefilePackage):
+    """ Fukui  Renderer   DAWN (Drawer for Academic WritiNgs) 
+    is a renderer, which reads 3D geometrical data and visualize them.  
+    It is a vectorized 3D PostScript processor with analytical 
+    hidden line/surface removal. 
+    It aims at precise technical drawing of complex geometries.  
+    It performs geometrical hidden line/surface removal and calculates 
+    out all visible parts of the 3D data before drawing.  This drawing 
+    algorithm realizes device-independent technical high quality of
+    vectorized graphics.
+    3D Data files should be generated by a modeler or by hands 
+    separately.  If you use DAWN as a visualizer of, 
+    say, a simulator of physical experiments, 
+    the simulator application itself is recognized as a modeler.
+    An important feature of DAWN is that
+    it has been developed to visualize 3D data generated by
+    a high-energy experimental detector simulator "GEANT4" 
+    ( http://geant4.web.cern.ch/geant4 , http://geant4.kek.jp ).  
+
+    Note: we set 'gv' as default pdf/ps viewer, assuming this is
+          installed on your system.
+    """
+
+    homepage = "https://geant4.kek.jp/~tanaka"
+    url      = "http://geant4.kek.jp/~tanaka/src/dawn_3_91a.tgz"
+    maintainers = ['sly2j']
+
+    version('3_91a', sha256='81d855ead1117681b188242dd0be3a24e005d9bd4063fd2bda9a7a794ebcf5f4')
+
+    depends_on('tcl')
+    depends_on('tk')
+
+    ## Patch to ensure wish is called correctly
+    patch('exec.patch')
+    patch('install.patch')
+
+    def edit(self, spec, prefix):
+        makefile = FileFilter("Makefile")
+        makefile.filter('CC= .*', 'CC = ' + env['CC'])
+        makefile.filter('CXX = .*', 'CXX = ' + env['CXX'])
+        makefile.filter('INSTALL_DIR = .*', 'INSTALL_DIR = {}/bin'.format(prefix))
+        os.environ['DAWN_PS_PREVIEWER'] = 'gv'
diff --git a/spack/packages/dawncut/install.patch b/spack/packages/dawncut/install.patch
new file mode 100644
index 000000000..3f939a4ec
--- /dev/null
+++ b/spack/packages/dawncut/install.patch
@@ -0,0 +1,20 @@
+diff --git a/Makefile b/Makefile
+index 1dda775..e8a567f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,6 +1,7 @@
+ include ./Makefile.architecture
+ 
+ TARGET = dawncut
++INSTALL_DIR ?= /usr/local/bin
+ 
+ SRC_DIR = src
+ 
+@@ -44,3 +45,7 @@ clean :
+ 	$(RM) $(TARGET) core
+ 	$(RM) *~ \#*
+ 
++### install 
++install:
++	mkdir -p $(INSTALL_DIR)
++	cp -p ./$(TARGET)    	   $(INSTALL_DIR)/$(TARGET)
diff --git a/spack/packages/dawncut/package.py b/spack/packages/dawncut/package.py
new file mode 100644
index 000000000..c0eac789f
--- /dev/null
+++ b/spack/packages/dawncut/package.py
@@ -0,0 +1,33 @@
+# Copyright 203-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+import os
+
+class Dawncut(MakefilePackage):
+    """DAWNCUT is a tool to generate a 3D scene data clipped with an arbitrary plane.
+    It reads a source DAWN-format file and outputs a new DAWN-format data, 
+    describing a plane-clipped 3D scene.  The output DAWN-format data can be 
+    visualized with Fukui Renderer DAWN.
+    """
+
+    homepage = "https://geant4.kek.jp/~tanaka"
+    url = "http://10.10.241.20/software/dawncut_1_54a.tar.gz"
+    maintainers = ['sly2j']
+
+    version('1_54a',
+            sha256='17d7ccd2ff863e2f3700cc3e751cfca37a1425abfa0edc3b8f6497d8746ddcf4')
+
+    # FIXME: Add dependencies if required.
+    # depends_on('foo')
+
+    ## Patch to add install directive to Makefile
+    patch('install.patch')
+
+    def edit(self, spec, prefix):
+        makefile = FileFilter("Makefile")
+        makefile.filter('CC= .*', 'CC = ' + env['CC'])
+        makefile.filter('CXX = .*', 'CXX = ' + env['CXX'])
+        os.environ['INSTALL_DIR'] = '{}/bin'.format(prefix)
diff --git a/spack/packages/dd4hep/package.py b/spack/packages/dd4hep/package.py
new file mode 100644
index 000000000..8b8412767
--- /dev/null
+++ b/spack/packages/dd4hep/package.py
@@ -0,0 +1,97 @@
+# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class Dd4hep(CMakePackage):
+    """DD4hep is a software framework for providing a complete solution for
+       full detector description (geometry, materials, visualization, readout,
+       alignment, calibration, etc.) for the full experiment life cycle
+       (detector concept development, detector optimization, construction,
+       operation). It offers a consistent description through a single source
+       of detector information for simulation, reconstruction, analysis, etc.
+       It distributed under the LGPLv3 License."""
+
+    homepage = "https://dd4hep.web.cern.ch/dd4hep/"
+    url      = "https://github.com/AIDASoft/DD4hep/archive/v01-12-01.tar.gz"
+    git      = "https://github.com/AIDASoft/DD4hep.git"
+
+    maintainers = ['vvolkl', 'drbenmorgan']
+
+    version('master', branch='master')
+    version('1.14.1', sha256='5b5742f1e23c2b36d3174cca95f810ce909c0eb66f3d6d7acb0ba657819e6717')
+    version('1.14.0', sha256='b603aa3c0db8dda392253aa71fa4a0f0c3c9715d47df0b895d45c1e8849f4895')
+    version('1.13.1', sha256='83fa70cd74ce93b2f52f098388dff58d179f05ace5b50aea3f408bb8abf7cb73')
+    version('1.13.0', sha256='0b1f9d902ebe21a9178c1e41204c066b29f68c8836fd1d03a9ce979811ddb295')
+    version('1.12.1', sha256='85e8c775ec03c499ce10911e228342e757c81ce9ef2a9195cb253b85175a2e93')
+    version('1.12.0', sha256='133a1fb8ce0466d2482f3ebb03e60b3bebb9b2d3e33d14ba15c8fbb91706b398')
+    version('1.11.2', sha256='96a53dd26cb8df11c6dae54669fbc9cc3c90dd47c67e07b24be9a1341c95abc4')
+    version('1.11.1', sha256='d7902dd7f6744bbda92f6e303ad5a3410eec4a0d2195cdc86f6c1167e72893f0')
+    version('1.11.0', sha256='25643296f15f9d11ad4ad550b7c3b92e8974fc56f1ee8e4455501010789ae7b6')
+    version('1.10.0', sha256='1d6b5d1c368dc8bcedd9c61b7c7e1a44bad427f8bd34932516aff47c88a31d95')
+
+
+    # Workarounds for various TBB issues in DD4hep v1.11
+    # See https://github.com/AIDASoft/DD4hep/pull/613 .
+    patch('tbb-workarounds.patch', when='@1.11.0')
+    patch('tbb2.patch', when='@1.12.1')
+
+    variant('xercesc', default=False, description="Enable 'Detector Builders' based on XercesC")
+    variant('geant4', default=False, description="Enable the simulation part based on Geant4")
+    variant('assimp', default=False, description="Enable CAD interface based on Assimp")
+    variant('hepmc3', default=False, description="Enable build with hepmc3")
+    variant('lcio', default=False, description="Enable build with lcio")
+    variant('debug', default=False, description="Enable debug build")
+
+    depends_on('cmake @3.12:', type='build')
+    depends_on('boost @1.49:')
+    depends_on('root @6.08: +gdml +math +opengl +python +x')
+    extends('python')
+    depends_on('xerces-c', when='+xercesc')
+    depends_on('geant4@10.2.2:', when='+geant4')
+    depends_on('assimp', when='+assimp')
+    depends_on('hepmc3', when="+hepmc3")
+    depends_on('lcio', when="+lcio")
+
+    def cmake_args(self):
+        spec = self.spec
+        cxxstd = spec['root'].variants['cxxstd'].value
+        # root can be built with cxxstd=11, but dd4hep requires 14
+        if cxxstd == "11":
+            cxxstd = "14"
+        args = [
+            "-DCMAKE_CXX_STANDARD={0}".format(cxxstd),
+            "-DDD4HEP_USE_XERCESC={0}".format(spec.satisfies('+xercesc')),
+            "-DDD4HEP_USE_GEANT4={0}".format(spec.satisfies('+geant4')),
+            "-DDD4HEP_USE_LCIO={0}".format(spec.satisfies('+lcio')),
+            "-DDD4HEP_LOAD_ASSIMP={0}".format(spec.satisfies('+assimp')),
+            "-DDD4HEP_USE_HEPMC3={0}".format(spec.satisfies('+hepmc3')),
+            "-DDD4HEP_BUILD_DEBUG={0}".format(spec.satisfies('+debug')),
+            "-DBUILD_TESTING={0}".format(self.run_tests),
+            "-DBOOST_ROOT={0}".format(spec['boost'].prefix),
+            "-DBoost_NO_BOOST_CMAKE=ON",
+            "-DPYTHON_EXECUTABLE={0}".format(spec['python'].command.path),
+        ]
+        return args
+
+    def setup_run_environment(self, env):
+        # used p.ex. in ddsim to find DDDetectors dir
+        env.set("DD4hepINSTALL", self.prefix)
+        env.set("DD4hep_DIR", self.prefix)
+        env.set("DD4hep_ROOT", self.prefix)
+
+    def url_for_version(self, version):
+        # dd4hep releases are dashes and padded with a leading zero
+        # the patch version is omitted when 0
+        # so for example v01-12-01, v01-12 ...
+        major = (str(version[0]).zfill(2))
+        minor = (str(version[1]).zfill(2))
+        patch = (str(version[2]).zfill(2))
+        if version[2] == 0:
+            url = "https://github.com/AIDASoft/DD4hep/archive/v%s-%s.tar.gz" % (major, minor)
+        else:
+            url = "https://github.com/AIDASoft/DD4hep/archive/v%s-%s-%s.tar.gz" % (major, minor, patch)
+        return url
diff --git a/spack/packages/dd4hep/tbb-workarounds.patch b/spack/packages/dd4hep/tbb-workarounds.patch
new file mode 100644
index 000000000..659232977
--- /dev/null
+++ b/spack/packages/dd4hep/tbb-workarounds.patch
@@ -0,0 +1,41 @@
+diff --git a/DDDigi/CMakeLists.txt b/DDDigi/CMakeLists.txt
+index e6fb1096..88eb5c92 100644
+--- a/DDDigi/CMakeLists.txt
++++ b/DDDigi/CMakeLists.txt
+@@ -34,12 +34,10 @@ target_include_directories(DDDigi
+ 
+ FIND_PACKAGE(TBB QUIET)
+ if(TBB_FOUND)
+-  dd4hep_print( "|++> TBB_INCLUDE_DIR -->  ${TBB_INCLUDE_DIR}")
+-  dd4hep_print( "|++> TBB_LIBRARY     -->  ${TBB_LIBRARY}")
++  dd4hep_print( "|++> TBB_IMPORTED_TARGETS -->  ${TBB_IMPORTED_TARGETS}")
+   dd4hep_print( "|++> TBB found. DDDigi will run multi threaded.")
+   target_compile_definitions(DDDigi PUBLIC DD4HEP_USE_TBB)
+-  target_link_libraries(DDDigi ${TBB_LIBRARY})
+-  target_include_directories(DDDigi ${TBB_INCLUDE_DIRS})
++  target_link_libraries(DDDigi PUBLIC ${TBB_IMPORTED_TARGETS})
+ else()
+   dd4hep_print( "|++> TBB not found. DDDigi will only work single threaded.")
+ endif()
+diff --git a/DDDigi/src/DigiKernel.cpp b/DDDigi/src/DigiKernel.cpp
+index d62c6694..f2c2e86c 100644
+--- a/DDDigi/src/DigiKernel.cpp
++++ b/DDDigi/src/DigiKernel.cpp
+@@ -91,7 +91,7 @@ public:
+   DigiEventAction*  action = 0;
+   Wrapper(DigiContext& c, DigiEventAction* a)
+     : context(c), action(a) {}
+-  Wrapper(Wrapper&& copy) = delete;
++  Wrapper(Wrapper&& copy) = default;
+   Wrapper(const Wrapper& copy) = default;
+   Wrapper& operator=(Wrapper&& copy) = delete;
+   Wrapper& operator=(const Wrapper& copy) = delete;
+@@ -111,7 +111,7 @@ class DigiKernel::Processor {
+   DigiKernel& kernel;
+ public: 
+   Processor(DigiKernel& k) : kernel(k) {}
+-  Processor(Processor&& l) = delete;
++  Processor(Processor&& l) = default;
+   Processor(const Processor& l) = default;
+   void operator()()  const {
+     int todo = 1;
diff --git a/spack/packages/dd4hep/tbb2.patch b/spack/packages/dd4hep/tbb2.patch
new file mode 100644
index 000000000..932458001
--- /dev/null
+++ b/spack/packages/dd4hep/tbb2.patch
@@ -0,0 +1,14 @@
+diff --git a/DDDigi/src/DigiKernel.cpp b/DDDigi/src/DigiKernel.cpp
+index f2c2e86c..f168ef9b 100644
+--- a/DDDigi/src/DigiKernel.cpp
++++ b/DDDigi/src/DigiKernel.cpp
+@@ -273,7 +273,7 @@ void DigiKernel::submit(const DigiAction::Actors<DigiEventAction>& actions, Digi
+   if ( parallel )   {
+     tbb::task_group que;
+     for ( auto* i : actions )
+-      que.run(Wrapper(context, *i));
++      que.run(Wrapper(context, i));
+     que.wait();
+     goto print_stamp;
+   }
+
diff --git a/spack/packages/eicd/package.py b/spack/packages/eicd/package.py
new file mode 100644
index 000000000..5eff4ed55
--- /dev/null
+++ b/spack/packages/eicd/package.py
@@ -0,0 +1,31 @@
+from spack import *
+
+class Eicd(CMakePackage):
+    '''EICD podio-based data model for the EIC'''
+
+    homepage = 'https://eicweb.phy.anl.gov/EIC/eicd'
+    #git      = 'https://eicweb.phy.anl.gov/EIC/NPDet.git'
+    #list_url = 'https://eicweb.phy.anl.gov/EIC/NPDet/-/tags'
+    maintainers = ['sly2j', 'whit']
+
+    ## Master branch
+    version('master', git='https://eicweb.phy.anl.gov/EIC/eicd.git',
+                      branch='master',
+                      preferred=True)
+
+    variant('cxxstd',
+            default='11',
+            values=('11', '14', '17'),
+            multi=False,
+            description='Use the specified C++ standard when building.')
+
+    depends_on('cmake@3.2:', type='build')
+    depends_on('podio')
+    depends_on('root')
+
+    def cmake_args(self):
+        options = []
+        ## C++ standard
+        options.append('-DCMAKE_CXX_STANDARD={0}'.format(
+            self.spec.variants['cxxstd'].value))
+        return options
diff --git a/spack/packages/fmt/fmt-attributes-cpp11_4.1.0.patch b/spack/packages/fmt/fmt-attributes-cpp11_4.1.0.patch
new file mode 100644
index 000000000..cc7f7f3ca
--- /dev/null
+++ b/spack/packages/fmt/fmt-attributes-cpp11_4.1.0.patch
@@ -0,0 +1,13 @@
+diff --git a/fmt/format.h b/fmt/format.h
+index 561a9e0..9faf5ca 100644
+--- a/fmt/format.h
++++ b/fmt/format.h
+@@ -153,7 +153,7 @@ typedef __int64          intmax_t;
+ # define FMT_HAS_CPP_ATTRIBUTE(x) 0
+ #endif
+ 
+-#if FMT_HAS_CPP_ATTRIBUTE(maybe_unused)
++#if FMT_HAS_CPP_ATTRIBUTE(maybe_unused) && __cplusplus >= 201103L
+ # define FMT_HAS_CXX17_ATTRIBUTE_MAYBE_UNUSED
+ // VC++ 1910 support /std: option and that will set _MSVC_LANG macro
+ // Clang with Microsoft CodeGen doesn't define _MSVC_LANG macro
diff --git a/spack/packages/fmt/fmt-no-export-cpp11flag_3.0.0.patch b/spack/packages/fmt/fmt-no-export-cpp11flag_3.0.0.patch
new file mode 100644
index 000000000..6b5ea4d86
--- /dev/null
+++ b/spack/packages/fmt/fmt-no-export-cpp11flag_3.0.0.patch
@@ -0,0 +1,13 @@
+diff --git a/fmt/CMakeLists.txt b/fmt/CMakeLists.txt
+index c0ef02e..1634924 100644
+--- a/fmt/CMakeLists.txt
++++ b/fmt/CMakeLists.txt
+@@ -14,8 +14,6 @@ if (FMT_CPPFORMAT)
+   add_library(cppformat ${FMT_SOURCES} ${FMT_HEADERS})
+ endif ()
+ 
+-# Starting with cmake 3.1 the CXX_STANDARD property can be used instead.
+-target_compile_options(fmt PUBLIC ${CPP11_FLAG})
+ if (FMT_PEDANTIC)
+   target_compile_options(fmt PRIVATE ${PEDANTIC_COMPILE_FLAGS})
+ endif ()
diff --git a/spack/packages/fmt/fmt-use-cmake-cxx-standard_3.0.0.patch b/spack/packages/fmt/fmt-use-cmake-cxx-standard_3.0.0.patch
new file mode 100644
index 000000000..407430bcf
--- /dev/null
+++ b/spack/packages/fmt/fmt-use-cmake-cxx-standard_3.0.0.patch
@@ -0,0 +1,15 @@
+diff --git a/support/cmake/cxx11.cmake b/support/cmake/cxx11.cmake
+index 31ea106..8581b9a 100644
+--- a/support/cmake/cxx11.cmake
++++ b/support/cmake/cxx11.cmake
+@@ -37,6 +37,10 @@ if (FMT_USE_CPP11)
+   endif ()
+ endif ()
+ 
++if (CMAKE_CXX_STANDARD)
++  set(CPP11_FLAG )
++endif ()
++
+ set(CMAKE_REQUIRED_FLAGS ${CPP11_FLAG})
+ 
+ # Check if variadic templates are working and not affected by GCC bug 39653:
diff --git a/spack/packages/fmt/package.py b/spack/packages/fmt/package.py
new file mode 100644
index 000000000..26de8998a
--- /dev/null
+++ b/spack/packages/fmt/package.py
@@ -0,0 +1,86 @@
+# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class Fmt(CMakePackage):
+    """fmt (formerly cppformat) is an open-source formatting library.
+    It can be used as a safe alternative to printf or as a fast alternative
+    to C++ IOStreams."""
+
+    homepage = "http://fmtlib.net/latest/index.html"
+    url      = "https://github.com/fmtlib/fmt/releases/download/7.1.2/fmt-7.1.2.zip"
+
+    version('7.1.2', sha256='4d6968ab7c01e95cc76df136755703defb985105a117b83057e4fd5d53680ea7')
+    version('7.1.0', sha256='308af4e36ee3ab527b51014a2a5d862682c84f5d16f7a597aea34c84853cbcb0')
+    version('6.1.2', sha256='63650f3c39a96371f5810c4e41d6f9b0bb10305064e6faf201cbafe297ea30e8')
+    version('5.3.0', sha256='4c0741e10183f75d7d6f730b8708a99b329b2f942dad5a9da3385ab92bb4a15c')
+    version('5.2.1', sha256='43894ab8fe561fc9e523a8024efc23018431fa86b95d45b06dbe6ddb29ffb6cd')
+    version('5.2.0', sha256='c016db7f825bce487a7929e1edb747b9902a2935057af6512cad3df3a080a027')
+    version('5.1.0', sha256='77ef9fea638dc846e484409fbc1ea710bb9bcea042e7b35b8805041bf7655ad5')
+    version('5.0.0', sha256='8dd58daf13e7e8adca99f8725ef3ae598f9c97efda7d6d8d4c49db5047879097')
+    version('4.1.0', sha256='9d49bf02ceb9d0eec51144b203b63b77e69d3798bb402fb82e7d0bdb06c79eeb')
+    version('4.0.0', sha256='10a9f184d4d66f135093a08396d3b0a0ebe8d97b79f8b3ddb8559f75fe4fcbc3')
+    version('3.0.2', sha256='51407b62a202b29d1a9c0eb5ecd4095d30031aea65407c42c25cb10cb5c59ad4')
+    version('3.0.1', sha256='4c9af0dc919a8ae7022b44e1a03c435e42d65c866f44667d8d920d342b098550')
+    version('3.0.0', sha256='1b050b66fa31b74f1d75a14f15e99e728ab79572f176a53b2f8ad7c201c30ceb')
+
+    variant('cxxstd',
+            default='11',
+            values=('98', '11', '14', '17'),
+            multi=False,
+            description='Use the specified C++ standard when building')
+    variant('pic', default=True, description='Enable generation of position-independent code')
+
+    depends_on('cmake@3.1.0:', type='build')
+
+    # Supported compilers/standards are detailed here:
+    # http://fmtlib.net/latest/index.html#portability
+    conflicts('%gcc@:4.3.999', when='@5:')
+    conflicts('%llvm@:2.8.999', when='@5:')
+    # 5 and above require C++11
+    conflicts('cxxstd=98', when='@5:')
+    # 5.0.0 enables C++14 auto return types in C++11 mode
+    conflicts('cxxstd=11', when='@5.0.0')
+    # 4.1 fails with C++17 (https://github.com/fmtlib/fmt/issues/722)
+    conflicts('cxxstd=17', when='@4.1.0')
+
+    # Use CMAKE_CXX_STANDARD to define C++ flag, as in later versions
+    patch('fmt-use-cmake-cxx-standard_3.0.0.patch', when='@3.0.0')
+
+    # Remove hardcoding of "-std=c++11/0x" in INTERFACE_COMPILE_OPTIONS
+    patch('fmt-no-export-cpp11flag_3.0.0.patch', when='@3.0.0:3.0.1')
+
+    # Only allow [[attributes]] on C++11 and higher
+    patch('fmt-attributes-cpp11_4.1.0.patch', when='@4.1.0')
+
+    def cmake_args(self):
+        spec = self.spec
+        args = []
+
+        if '+pic' in spec:
+            args.extend([
+                '-DCMAKE_C_FLAGS={0}'.format(self.compiler.cc_pic_flag),
+                '-DCMAKE_CXX_FLAGS={0}'.format(self.compiler.cxx_pic_flag)
+            ])
+
+        args.append('-DCMAKE_CXX_STANDARD={0}'.format(
+                    spec.variants['cxxstd'].value))
+        # Require standard at configure time to guarantee the
+        # compiler supports the selected standard.
+        args.append('-DCMAKE_CXX_STANDARD_REQUIRED=ON')
+
+        args.append('-DBUILD_SHARED_LIBS=TRUE')
+
+        # When cxxstd is 98, must disable FMT_USE_CPP11
+        if 'cxxstd=98' in spec:
+            args.append('-DFMT_USE_CPP11=OFF')
+
+        # Can't build docs without doxygen+python+virtualenv
+        # and call to build "doc" target
+        args.append("-DFMT_DOC=OFF")
+
+        return args
diff --git a/spack/packages/geant4/CLHEP-10.03.03.patch b/spack/packages/geant4/CLHEP-10.03.03.patch
new file mode 100644
index 000000000..b865f3bde
--- /dev/null
+++ b/spack/packages/geant4/CLHEP-10.03.03.patch
@@ -0,0 +1,34 @@
+diff --git a/cmake/Modules/FindCLHEP.cmake b/cmake/Modules/FindCLHEP.cmake
+index 8b59f1c0a..f616d678e 100644
+--- a/cmake/Modules/FindCLHEP.cmake
++++ b/cmake/Modules/FindCLHEP.cmake
+@@ -180,7 +180,10 @@ if(UNIX)
+         execute_process(COMMAND ${CLHEP_CONFIG_EXECUTABLE} --prefix
+             OUTPUT_VARIABLE _clhep_config_prefix
+             OUTPUT_STRIP_TRAILING_WHITESPACE)
+-
++          if (_clhep_config_prefix)
++            # Remove wrapping double quotes.
++            string(REGEX REPLACE "\"(.*)\"" "\\1" _clhep_config_prefix "${_clhep_config_prefix}")
++          endif()
+         list(APPEND _clhep_root_hints ${_clhep_config_prefix})
+     endif()
+ elseif(WIN32 AND NOT UNIX)
+diff --git a/cmake/Templates/Geant4Config.cmake.in b/cmake/Templates/Geant4Config.cmake.in
+index d6fe408b3..f355be2af 100644
+--- a/cmake/Templates/Geant4Config.cmake.in
++++ b/cmake/Templates/Geant4Config.cmake.in
+@@ -268,13 +268,7 @@ set(Geant4_builtin_clhep_FOUND @GEANT4_USE_BUILTIN_CLHEP@)
+ if(NOT Geant4_builtin_clhep_FOUND)
+   set(Geant4_system_clhep_ISGRANULAR @GEANT4_USE_SYSTEM_CLHEP_GRANULAR@)
+ 
+-  set(CLHEP_ROOT_DIR "@CLHEP_ROOT_DIR@")
+-  set(__GEANT4_OLD_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
+-  set(CMAKE_MODULE_PATH "${_geant4_thisdir}/Modules" ${CMAKE_MODULE_PATH})
+   find_package(CLHEP @CLHEP_VERSION@ REQUIRED @__g4_clhep_components@)
+-  set(CMAKE_MODULE_PATH ${__GEANT4_OLD_CMAKE_MODULE_PATH})
+-  unset(CLHEP_ROOT_DIR)
+-  unset(__GEANT4_OLD_CMAKE_MODULE_PATH)
+   #CLHEP doesn't use target properties fully yet, so always include_directories
+   include_directories(${CLHEP_INCLUDE_DIRS})
+ endif()
diff --git a/spack/packages/geant4/cxx17.patch b/spack/packages/geant4/cxx17.patch
new file mode 100644
index 000000000..3845e9e20
--- /dev/null
+++ b/spack/packages/geant4/cxx17.patch
@@ -0,0 +1,22 @@
+diff -Naur geant4.10.03.p03/cmake/Modules/Geant4LibraryBuildOptions.cmake geant4.10.03.p03/cmake/Modules/Geant4LibraryBuildOptions.cmake
+--- geant4.10.03.p03/cmake/Modules/Geant4LibraryBuildOptions.cmake	2017-10-20 06:30:46.000000000 -0500
++++ geant4.10.03.p03/cmake/Modules/Geant4LibraryBuildOptions.cmake	2018-04-16 16:48:02.194321171 -0500
+@@ -76,7 +76,7 @@
+ # Mark as advanced because most users will not need it
+ enum_option(GEANT4_BUILD_CXXSTD
+   DOC "C++ Standard to compile against"
+-  VALUES 11 14 c++11 c++14
++  VALUES 11 14 17 c++11 c++14 c++17
+   CASE_INSENSITIVE
+   )
+ 
+@@ -106,6 +106,9 @@
+ 
+ # Add Definition to flags for temporary back compatibility
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DG4USE_STD11")
++if(GEANT4_BUILD_CXXSTD GREATER 14)
++  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES=1")
++endif()
+ 
+ # Hold any appropriate compile flag(s) in variable for later export to
+ # config files. Needed to support late CMake 2.8 where compile features
diff --git a/spack/packages/geant4/cxx17_geant4_10_0.patch b/spack/packages/geant4/cxx17_geant4_10_0.patch
new file mode 100644
index 000000000..228985ebc
--- /dev/null
+++ b/spack/packages/geant4/cxx17_geant4_10_0.patch
@@ -0,0 +1,22 @@
+diff -Naur geant4/cmake/Modules/G4BuildSettings.cmake geant4/cmake/Modules/G4BuildSettings.cmake
+--- geant4/cmake/Modules/G4BuildSettings.cmake	2017-10-20 06:30:46.000000000 -0500
++++ geant4/cmake/Modules/G4BuildSettings.cmake	2018-04-16 16:48:02.194321171 -0500
+@@ -76,7 +76,7 @@
+ # Mark as advanced because most users will not need it
+ enum_option(GEANT4_BUILD_CXXSTD
+   DOC "C++ Standard to compile against"
+-  VALUES 11 14 c++11 c++14
++  VALUES 11 14 17 c++11 c++14 c++17
+   CASE_INSENSITIVE
+   )
+ 
+@@ -106,6 +106,9 @@
+ 
+ # Add Definition to flags for temporary back compatibility
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DG4USE_STD11")
++if(GEANT4_BUILD_CXXSTD GREATER 14)
++  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES=1")
++endif()
+ 
+ # Hold any appropriate compile flag(s) in variable for later export to
+ # config files. Needed to support late CMake 2.8 where compile features
diff --git a/spack/packages/geant4/geant4-10.4.3-cxx17-removed-features.patch b/spack/packages/geant4/geant4-10.4.3-cxx17-removed-features.patch
new file mode 100644
index 000000000..a49388767
--- /dev/null
+++ b/spack/packages/geant4/geant4-10.4.3-cxx17-removed-features.patch
@@ -0,0 +1,18 @@
+diff --git a/cmake/Modules/G4BuildSettings.cmake b/cmake/Modules/G4BuildSettings.cmake
+index f68cb0a44..6bf4b6948 100644
+--- a/cmake/Modules/G4BuildSettings.cmake
++++ b/cmake/Modules/G4BuildSettings.cmake
+@@ -205,6 +205,13 @@ endif()
+ # Add Definition to flags for temporary back compatibility
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DG4USE_STD11")
+ 
++# Spack patch to support use of C++ features deprecated/removed in C++17
++# Only checked on AppleClang for now
++if(GEANT4_BUILD_CXXSTD GREATER 14)
++  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES=1")
++endif()
++#----
++
+ # Hold any appropriate compile flag(s) in variable for later export to
+ # config files. Needed to support clients using late CMake 2.8 where compile features
+ # are not available.
diff --git a/spack/packages/geant4/package.py b/spack/packages/geant4/package.py
new file mode 100644
index 000000000..a8e6ea73f
--- /dev/null
+++ b/spack/packages/geant4/package.py
@@ -0,0 +1,159 @@
+# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class Geant4(CMakePackage):
+    """Geant4 is a toolkit for the simulation of the passage of particles
+    through matter. Its areas of application include high energy, nuclear
+    and accelerator physics, as well as studies in medical and space
+    science."""
+
+    homepage = "http://geant4.cern.ch/"
+    url = "https://gitlab.cern.ch/geant4/geant4/-/archive/v10.6.0/geant4-v10.6.0.tar.gz"
+
+    maintainers = ['drbenmorgan']
+
+    version('10.6.2', sha256='e381e04c02aeade1ed8cdd9fdbe7dcf5d6f0f9b3837a417976b839318a005dbd')
+    version('10.6.1', sha256='4fd64149ae26952672a81ce5579d3806fda4bd251d486897093ac57633a42b7e')
+    version('10.6.0', sha256='eebe6a170546064ff81ab3b00f513ccd1d4122a026514982368d503ac55a4ee4')
+    version('10.5.1', sha256='2397eb859dc4de095ff66059d8bda9f060fdc42e10469dd7890946293eeb0e39')
+    version('10.4.3', sha256='67f3bb6405a2c77e573936c2b933f5a4a33915aa379626a2eb3012009b91e1da')
+    version('10.4.0', sha256='e919b9b0a88476e00c0b18ab65d40e6a714b55ee4778f66bac32a5396c22aa74')
+    version('10.3.3', sha256='bcd36a453da44de9368d1d61b0144031a58e4b43a6d2d875e19085f2700a89d8')
+
+    _cxxstd_values = ('11', '14', '17')
+    variant('cxxstd',
+            default=_cxxstd_values[0],
+            values=_cxxstd_values,
+            multi=False,
+            description='Use the specified C++ standard when building.')
+
+    variant('threads', default=True, description='Build with multithreading')
+    variant('vecgeom', default=False, description='Enable vecgeom support')
+    variant('opengl', default=False, description='Optional OpenGL support')
+    variant('x11', default=False, description='Optional X11 support')
+    variant('motif', default=False, description='Optional motif support')
+    variant('qt', default=False, description='Enable Qt support')
+    variant('python', default=False, description='Enable Python bindings')
+
+    depends_on('cmake@3.5:', type='build')
+    depends_on('cmake@3.8:', type='build', when='@10.6.0:')
+
+    depends_on('geant4-data@10.6.2', when='@10.6.2')
+    depends_on('geant4-data@10.6.1', when='@10.6.1')
+    depends_on('geant4-data@10.6.0', when='@10.6.0')
+    depends_on('geant4-data@10.5.1', when='@10.5.1')
+    depends_on('geant4-data@10.4.3', when='@10.4.3')
+    depends_on('geant4-data@10.4.0', when='@10.4.0')
+    depends_on('geant4-data@10.3.3', when='@10.3.3')
+
+    depends_on("expat")
+    depends_on("zlib")
+
+    # Python, with boost requirement dealt with in cxxstd section
+    depends_on('python@3:', when='+python')
+    extends('python', when='+python')
+    conflicts('+python', when='@:10.6.1',
+              msg='Geant4 <= 10.6.1 cannont be built with Python bindings')
+
+    for std in _cxxstd_values:
+        # CLHEP version requirements to be reviewed
+        depends_on('clhep@2.3.3.0: cxxstd=' + std,
+                   when='@10.3.3: cxxstd=' + std)
+
+        # Spack only supports Xerces-c 3 and above, so no version req
+        depends_on('xerces-c cxxstd=' + std, when='cxxstd=' + std)
+
+        # Vecgeom specific versions for each Geant4 version
+        depends_on('vecgeom@1.1.5 cxxstd=' + std,
+                   when='@10.6.0:10.6.99 +vecgeom cxxstd=' + std)
+        depends_on('vecgeom@1.1.0 cxxstd=' + std,
+                   when='@10.5.0:10.5.99 +vecgeom cxxstd=' + std)
+        depends_on('vecgeom@0.5.2 cxxstd=' + std,
+                   when='@10.4.0:10.4.99 +vecgeom cxxstd=' + std)
+        depends_on('vecgeom@0.3rc cxxstd=' + std,
+                   when='@10.3.0:10.3.99 +vecgeom cxxstd=' + std)
+
+        # Boost.python, conflict handled earlier
+        depends_on('boost@1.70: +python cxxstd=' + std,
+                   when='+python cxxstd=' + std)
+
+    # Visualization driver dependencies
+    depends_on("gl", when='+opengl')
+    depends_on("glu", when='+opengl')
+    depends_on("glx", when='+opengl+x11')
+    depends_on("libx11", when='+x11')
+    depends_on("libxmu", when='+x11')
+    depends_on("motif", when='+motif')
+    depends_on("qt@5: +opengl", when="+qt")
+
+    # As released, 10.03.03 has issues with respect to using external
+    # CLHEP.
+    patch('CLHEP-10.03.03.patch', level=1, when='@10.3.3')
+    # These patches can be applied independent of the cxxstd value?
+    patch('cxx17.patch', when='@:10.3.99 cxxstd=17')
+    patch('cxx17_geant4_10_0.patch', level=1, when='@10.4.0 cxxstd=17')
+    patch('geant4-10.4.3-cxx17-removed-features.patch',
+          level=1, when='@10.4.3 cxxstd=17')
+
+    def cmake_args(self):
+        spec = self.spec
+
+        # Core options
+        options = [
+            '-DGEANT4_BUILD_CXXSTD=c++{0}'.format(
+                self.spec.variants['cxxstd'].value),
+            '-DGEANT4_USE_SYSTEM_CLHEP=ON',
+            '-DGEANT4_USE_SYSTEM_EXPAT=ON',
+            '-DGEANT4_USE_SYSTEM_ZLIB=ON',
+            '-DGEANT4_USE_G3TOG4=ON',
+            '-DGEANT4_USE_GDML=ON',
+            '-DXERCESC_ROOT_DIR={0}'.format(spec['xerces-c'].prefix)
+        ]
+
+        # Multithreading
+        options.append(self.define_from_variant('GEANT4_BUILD_MULTITHREADED',
+                                                'threads'))
+        if '+threads' in spec:
+            # Locked at global-dynamic to allow use cases that load the
+            # geant4 libs at application runtime
+            options.append('-DGEANT4_BUILD_TLS_MODEL=global-dynamic')
+
+        # install the data with geant4
+        datadir = spec['geant4-data'].prefix.share
+        dataver = '{0}-{1}'.format(spec['geant4-data'].name,
+                                   spec['geant4-data'].version.dotted)
+        datapath = join_path(datadir, dataver)
+        options.append('-DGEANT4_INSTALL_DATADIR={0}'.format(datapath))
+
+        # Vecgeom
+        if '+vecgeom' in spec:
+            options.append('-DGEANT4_USE_USOLIDS=ON')
+            options.append('-DUSolids_DIR=%s' % spec[
+                'vecgeom'].prefix.lib.CMake.USolids)
+
+        # Visualization options
+        if 'platform=darwin' not in spec:
+            if "+x11" in spec and "+opengl" in spec:
+                options.append('-DGEANT4_USE_OPENGL_X11=ON')
+            if "+motif" in spec and "+opengl" in spec:
+                options.append('-DGEANT4_USE_XM=ON')
+            if "+x11" in spec:
+                options.append('-DGEANT4_USE_RAYTRACER_X11=ON')
+
+        if '+qt' in spec:
+            options.append('-DGEANT4_USE_QT=ON')
+            options.append(
+                '-DQT_QMAKE_EXECUTABLE=%s' %
+                spec['qt'].prefix.bin.qmake)
+
+        # Python
+        if spec.version > Version('10.6.1'):
+            options.append(self.define_from_variant('GEANT4_USE_PYTHON',
+                                                    'python'))
+
+        return options
diff --git a/spack/packages/graphviz/fix-quartz-darwin.patch b/spack/packages/graphviz/fix-quartz-darwin.patch
new file mode 100644
index 000000000..f20ade2f9
--- /dev/null
+++ b/spack/packages/graphviz/fix-quartz-darwin.patch
@@ -0,0 +1,30 @@
+--- a/configure.ac	2019-04-08 12:14:26.000000000 -0400
++++ b/configure.ac	2019-04-08 12:15:03.000000000 -0400
+@@ -170,16 +170,8 @@
+ 	BROWSER="open"
+ 	JSHEXT=jnilib
+ 	AC_DEFINE_UNQUOTED(DARWIN_DYLIB,"$DARWIN_DYLIB",[Define for Darwin-style shared library names.])
+-	case "${host_os}" in
+-	*darwin9*)
+-		DARWIN9=yes
+-		;;
+-        esac
+-	case "${host_os}" in
+-	*darwin9.4* | *darwin9.5* )
+-		EXTRA_SMYRNA_LDFLAGS="-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"
+-		;;
+-        esac
++        DARWIN9=yes
++        EXTRA_SMYRNA_LDFLAGS="-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"
+ 	;;
+   * ) # This sucks!  Whatever happened to standards for file system layout?   (Good job its no longer used unless fontconfig is unavailable.)
+ 	DEFAULT_FONTPATH="/usr/share/fonts/sun/TrueType:/usr/share/fonts/TrueType:/usr/X11/lib/X11/fonts/TrueType:/usr/share/fonts/sun/Type1:/usr/openwin/lib/X11/fonts/Type1:/usr/share/fonts/X11/Type1:/usr/share/fonts/default/Type1:/usr/X11R6/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/fonts/TTF:/usr/share/fonts/truetype:/usr/openwin/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/Type1:/usr/common/share/fonts/ttf";
+--- a/plugin/quartz/Makefile.am	2019-04-06 08:33:24.000000000 -0400
++++ b/plugin/quartz/Makefile.am	2019-04-08 12:32:41.000000000 -0400
+@@ -39,5 +39,5 @@
+
+ if WITH_DARWIN9
+ libgvplugin_quartz_la_LDFLAGS += -Wl,-exported_symbol,_gvplugin_quartz_LTX_library
+-AM_LIBTOOLSFLAGS = --tag=CC
++AM_LIBTOOLFLAGS = --tag=CC
+ endif
diff --git a/spack/packages/graphviz/implicit.patch b/spack/packages/graphviz/implicit.patch
new file mode 100644
index 000000000..dd174761a
--- /dev/null
+++ b/spack/packages/graphviz/implicit.patch
@@ -0,0 +1,25 @@
+Fix "error: implicit declaration of function 'makeTetrix'" and another
+problem fixed by the same upstream commit.
+https://gitlab.com/graphviz/graphviz/-/commit/b4947d67a4ebd48ca0105d44f92e47f044e51600
+--- cmd/lefty/dot2l/dotlex.c.orig	2016-08-09 16:02:09.000000000 -0500
++++ cmd/lefty/dot2l/dotlex.c	2020-08-27 14:45:45.000000000 -0500
+@@ -252,7 +252,7 @@
+     char *q;
+ 
+     q = lexbuf;
+-    if (p == '\0')
++    if (!p || *p == '\0')
+         return NULL;
+     while (isalnum (*p) || (*p == '_') || (!isascii (*p)))
+         *q++ = *p++;
+--- cmd/tools/gvgen.c.orig	2016-11-22 23:43:56.000000000 -0600
++++ cmd/tools/gvgen.c	2020-08-27 14:45:45.000000000 -0500
+@@ -458,6 +458,8 @@
+ 	fprintf(opts.outfile, "}\ngraph {\n");
+ }
+ 
++extern void makeTetrix(int depth, edgefn ef);
++
+ int main(int argc, char *argv[])
+ {
+     GraphType graphType;
diff --git a/spack/packages/graphviz/package.py b/spack/packages/graphviz/package.py
new file mode 100644
index 000000000..344ecd990
--- /dev/null
+++ b/spack/packages/graphviz/package.py
@@ -0,0 +1,174 @@
+# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+from spack.operating_systems.mac_os import macos_version
+
+import os
+import sys
+
+
+MACOS_VERSION = macos_version() if sys.platform == 'darwin' else None
+
+
+class Graphviz(AutotoolsPackage):
+    """Graph Visualization Software"""
+
+    homepage = 'http://www.graphviz.org'
+    git      = 'https://gitlab.com/graphviz/graphviz.git'
+
+    # This commit hash is tag='stable_release_2.44.1'
+    version('2.44.1', commit='771bc4dbff3e6f358fa75cdc7774a413ccacad51')
+    # This commit hash is tag='stable_release_2.42.2'
+    version('2.42.2', commit='da4c2ec6f24ca1b6d1752c6b5bc4389e55682147')
+    # This commit hash is tag='stable_release_2.40.1'
+    version('2.40.1', commit='67cd2e5121379a38e0801cc05cce5033f8a2a609')
+
+    conflicts('%gcc@:5.9',
+              when='@2.40.1+qt ^qt@5:',
+              msg='graphviz-2.40.1 needs gcc-6 or greater to compile with QT5 '
+              'suppport')
+
+    # Language bindings
+    language_bindings = ['java']
+
+    # Additional language bindings are nominally supported by GraphViz via SWIG
+    # but are untested and need the proper dependencies added:
+    # language_bindings += ['sharp', 'go', 'guile', 'io', 'lua', 'ocaml',
+    #                       'perl', 'php', 'python', 'r', 'ruby', 'tcl']
+
+    for lang in language_bindings:
+        variant(lang, default=False,
+                description='Enable for optional {0} language '
+                'bindings'.format(lang))
+
+    # Feature variants
+    variant('expat', default=False,
+            description='Build with Expat support (enables HTML-like labels)')
+    variant('gts', default=False,
+            description='Build with GNU Triangulated Surface Library')
+    variant('ghostscript', default=False,
+            description='Build with Ghostscript support')
+    variant('gtkplus', default=False,
+            description='Build with GTK+ support')
+    variant('libgd', default=False,
+            description='Build with libgd support (more output formats)')
+    variant('pangocairo', default=False,
+            description='Build with pango+cairo support (more output formats)')
+    variant('poppler', default=False,
+            description='Build with poppler support (pdf formats)')
+    variant('qt', default=False,
+            description='Build with Qt support')
+    variant('quartz', default=(MACOS_VERSION is not None),
+            description='Build with Quartz and PDF support')
+    variant('x', default=False,
+            description='Use the X Window System')
+
+    patch('http://www.linuxfromscratch.org/patches/blfs/9.0/graphviz-2.40.1-qt5-1.patch',
+          sha256='bd532df325df811713e311d17aaeac3f5d6075ea4fd0eae8d989391e6afba930',
+          when='@:2.40+qt^qt@5:')
+    patch('https://raw.githubusercontent.com/easybuilders/easybuild-easyconfigs/master/easybuild/easyconfigs/g/Graphviz/Graphviz-2.38.0_icc_sfio.patch',
+          sha256='393a0a772315a89dcc970b5efd4765d22dba83493d7956303673eb89c45b949f',
+          level=0,
+          when='@:2.40%intel')
+    patch('https://raw.githubusercontent.com/easybuilders/easybuild-easyconfigs/master/easybuild/easyconfigs/g/Graphviz/Graphviz-2.40.1_icc_vmalloc.patch',
+          sha256='813e6529e79161a18b0f24a969b7de22f8417b2e942239e658b5402884541bc2',
+          when='@:2.40%intel')
+    patch('ps2pdf.patch')
+    ## Don't apply to newer versions, as they are already fixed
+    patch('implicit.patch', when='@:2.42.0')
+
+    if not MACOS_VERSION:
+        conflicts('+quartz',
+                  msg="Graphviz can only be build with Quartz on macOS.")
+    elif MACOS_VERSION >= Version('10.9'):
+        # Doesn't detect newer mac os systems as being new
+        patch('fix-quartz-darwin.patch')
+
+    # Language dependencies
+    depends_on('java', when='+java')
+    for lang in language_bindings:
+        depends_on('swig', when=('+' + lang))
+
+    # Feature dependencies
+    depends_on('expat', when='+expat')
+    depends_on('libgd', when='+libgd')
+    depends_on('fontconfig', when='+libgd')
+    depends_on('freetype', when='+libgd')
+    depends_on('ghostscript', when='+ghostscript')
+    depends_on('gtkplus', when='+gtkplus')
+    depends_on('gts', when='+gts')
+    depends_on('cairo+pdf+png+svg', when='+pangocairo')
+    depends_on('fontconfig', when='+pangocairo')
+    depends_on('freetype', when='+pangocairo')
+    depends_on('glib', when='+pangocairo')
+    depends_on('libpng', when='+pangocairo')
+    depends_on('pango', when='+pangocairo')
+    depends_on('poppler+glib', when='+poppler')
+    depends_on('zlib')
+    depends_on('qt', when='+qt')
+    depends_on('libx11', when="+x")
+
+    # Build dependencies
+    depends_on('pkgconfig', type='build')
+    # The following are needed when building from git
+    depends_on('automake', type='build')
+    depends_on('autoconf', type='build')
+    depends_on('bison', type='build')
+    depends_on('flex', type='build')
+    depends_on('libtool', type='build')
+    # required to build docs
+    depends_on('groff', type='build')
+    depends_on('ghostscript', type='build')
+
+    parallel = False
+
+    def autoreconf(self, spec, prefix):
+        # We need to generate 'configure' when checking out sources from git
+        # If configure exists nothing needs to be done
+        if os.path.exists(self.configure_abs_path):
+            return
+        # Else bootstrap (disabling auto-configure with NOCONFIG)
+        bash = which('bash')
+        bash('./autogen.sh', 'NOCONFIG')
+
+    def setup_build_environment(self, env):
+        if '+quartz' in self.spec:
+            env.set('OBJC', self.compiler.cc)
+
+    @when('%clang platform=darwin')
+    def patch(self):
+        # When using Clang, replace GCC's libstdc++ with LLVM's libc++
+        mkdirs = ['cmd/dot', 'cmd/edgepaint', 'cmd/mingle', 'plugin/gdiplus']
+        filter_file(r'-lstdc\+\+', '-lc++', 'configure.ac',
+                    *(d + '/Makefile.am' for d in mkdirs))
+
+    @when('%apple-clang')
+    def patch(self):
+        # When using Clang, replace GCC's libstdc++ with LLVM's libc++
+        mkdirs = ['cmd/dot', 'cmd/edgepaint', 'cmd/mingle', 'plugin/gdiplus']
+        filter_file(r'-lstdc\+\+', '-lc++', 'configure.ac',
+                    *(d + '/Makefile.am' for d in mkdirs))
+
+    def configure_args(self):
+        spec = self.spec
+        args = ['--disable-silent-rules']
+
+        use_swig = False
+        for lang in self.language_bindings:
+            if '+' + lang in spec:
+                use_swig = True
+                args.append('--enable-' + lang)
+
+        args.append('--{0}-swig'.format('enable' if use_swig else 'disable'))
+
+        for var in ["expat", "gts", "ghostscript", "libgd", "pangocairo",
+                    "poppler", "qt", "quartz", "x"]:
+            args += self.with_or_without(var)
+
+        args.append('--{0}-gtk'.format(
+            "with" if "+gtkplus" in spec else "without"))
+
+        return args
diff --git a/spack/packages/graphviz/ps2pdf.patch b/spack/packages/graphviz/ps2pdf.patch
new file mode 100644
index 000000000..6bf9d067f
--- /dev/null
+++ b/spack/packages/graphviz/ps2pdf.patch
@@ -0,0 +1,15 @@
+https://gitlab.com/graphviz/graphviz/-/issues/1826
+https://github.com/Homebrew/homebrew-core/pull/57132
+diff --git a/configure.ac b/configure.ac
+index cf42504..68db027 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -284,8 +284,7 @@ AC_CHECK_PROGS(SORT,gsort sort,false)
+
+ AC_CHECK_PROG(EGREP,egrep,egrep,false)
+ AC_CHECK_PROG(GROFF,groff,groff,false)
+-AC_CHECK_PROG(PS2PDF,ps2pdf,ps2pdf,false)
+-AC_CHECK_PROG(PS2PDF,pstopdf,pstopdf,false)
++AC_CHECK_PROGS(PS2PDF,ps2pdf pstopdf,false)
+
+ PKG_PROG_PKG_CONFIG
diff --git a/spack/packages/npdet/package.py b/spack/packages/npdet/package.py
new file mode 100644
index 000000000..0083e250d
--- /dev/null
+++ b/spack/packages/npdet/package.py
@@ -0,0 +1,37 @@
+from spack import *
+
+class Npdet(CMakePackage):
+    '''NPDet DD4hep detector library for Nuclear Physics.'''
+
+    homepage = 'https://eicweb.phy.anl.gov/EIC/NPDet'
+    url      = 'https://eicweb.phy.anl.gov/EIC/NPDet/-/archive/v0.2.0/NPDet-v0.2.0.tar.gz'
+    #git      = 'https://eicweb.phy.anl.gov/EIC/NPDet.git'
+    #list_url = 'https://eicweb.phy.anl.gov/EIC/NPDet/-/tags'
+    maintainers = ['sly2j', 'whit']
+
+    ## Master branch
+    version('master', git='https://eicweb.phy.anl.gov/EIC/NPDet.git',
+                      branch='master',
+                      preferred=True)
+    version('0.2.0', sha256='e0e9018e891cd7c195d15f3c0b2e5fc872f140e8ad94f90fbf2b607f10e5688c')
+
+    variant('cxxstd',
+            default='11',
+            values=('11', '14', '17'),
+            multi=False,
+            description='Use the specified C++ standard when building.')
+
+    depends_on('cmake@3.2:', type='build')
+    depends_on('hepmc3')
+    depends_on('dd4hep')
+    depends_on('root')
+    depends_on('fmt')
+    depends_on('spdlog')
+    depends_on('podio')
+
+    def cmake_args(self):
+        options = []
+        ## C++ standard
+        options.append('-DCMAKE_CXX_STANDARD={0}'.format(
+            self.spec.variants['cxxstd'].value))
+        return options
diff --git a/spack/packages/qt/gcc10.patch b/spack/packages/qt/gcc10.patch
new file mode 100644
index 000000000..212e91ff4
--- /dev/null
+++ b/spack/packages/qt/gcc10.patch
@@ -0,0 +1,22 @@
+diff --git a/qtlocation/src/3rdparty/mapbox-gl-native/platform/default/bidi.cpp b/qtlocation/src/3rdparty/mapbox-gl-native/platform/default/bidi.cpp
+index d475c38..c1710a6 100644
+--- a/qtlocation/src/3rdparty/mapbox-gl-native/platform/default/bidi.cpp
++++ b/qtlocation/src/3rdparty/mapbox-gl-native/platform/default/bidi.cpp
+@@ -5,6 +5,7 @@
+ #include <unicode/ushape.h>
+ 
+ #include <memory>
++#include <stdexcept>
+ 
+ namespace mbgl {
+ 
+diff --git a/qtlocation/src/3rdparty/mapbox-gl-native/src/mbgl/util/convert.cpp b/qtlocation/src/3rdparty/mapbox-gl-native/src/mbgl/util/convert.cpp
+index 97bfe91..30125a8 100644
+--- a/qtlocation/src/3rdparty/mapbox-gl-native/src/mbgl/util/convert.cpp
++++ b/qtlocation/src/3rdparty/mapbox-gl-native/src/mbgl/util/convert.cpp
+@@ -1,4 +1,5 @@
+ #include <mbgl/util/convert.hpp>
++#include <cstdint>
+ 
+ namespace mbgl {
+ namespace util {
diff --git a/spack/packages/qt/package.py b/spack/packages/qt/package.py
new file mode 100644
index 000000000..5bcc06f46
--- /dev/null
+++ b/spack/packages/qt/package.py
@@ -0,0 +1,606 @@
+# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+from spack.operating_systems.mac_os import macos_version
+import llnl.util.tty as tty
+import itertools
+import os
+import sys
+
+MACOS_VERSION = macos_version() if sys.platform == 'darwin' else None
+
+
+class Qt(Package):
+    """Qt is a comprehensive cross-platform C++ application framework."""
+    homepage = 'http://qt.io'
+    # Alternative location 'http://download.qt.io/official_releases/qt/'
+    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 = 3
+    maintainers = ['sethrj']
+
+    phases = ['configure', 'build', 'install']
+
+    version('5.14.2', sha256='c6fcd53c744df89e7d3223c02838a33309bd1c291fcb6f9341505fe99f7f19fa')
+    version('5.14.1', sha256='6f17f488f512b39c2feb57d83a5e0a13dcef32999bea2e2a8f832f54a29badb8')
+    version('5.14.0', sha256='be9a77cd4e1f9d70b58621d0753be19ea498e6b0da0398753e5038426f76a8ba')
+    version('5.13.1', sha256='adf00266dc38352a166a9739f1a24a1e36f1be9c04bf72e16e142a256436974e')
+    version('5.12.7', sha256='873783a0302129d98a8f63de9afe4520fb5f8d5316be8ad7b760c59875cd8a8d')
+    version('5.12.5', sha256='a2299e21db7767caf98242767bffb18a2a88a42fee2d6a393bedd234f8c91298')
+    version('5.12.2', sha256='59b8cb4e728450b21224dcaaa40eb25bafc5196b6988f2225c394c6b7f881ff5')
+    version('5.11.3', sha256='859417642713cee2493ee3646a7fee782c9f1db39e41d7bb1322bba0c5f0ff4d')
+    version('5.11.2', sha256='c6104b840b6caee596fa9a35bc5f57f67ed5a99d6a36497b6fe66f990a53ca81')
+    version('5.10.0', sha256='936d4cf5d577298f4f9fdb220e85b008ae321554a5fcd38072dc327a7296230e')
+    version('5.9.1',  sha256='7b41a37d4fe5e120cdb7114862c0153f86c07abbec8db71500443d2ce0c89795')
+    version('5.9.0',  sha256='f70b5c66161191489fc13c7b7eb69bf9df3881596b183e7f6d94305a39837517')
+    version('5.8.0',  sha256='9dc5932307ae452855863f6405be1f7273d91173dcbe4257561676a599bd58d3')
+    version('5.7.1',  sha256='c86684203be61ae7b33a6cf33c23ec377f246d697bd9fb737d16f0ad798f89b7')
+    version('5.7.0',  sha256='4661905915d6265243e17fe59852930a229cf5b054ce5af5f48b34da9112ab5f')
+    version('5.5.1',  sha256='c7fad41a009af1996b62ec494e438aedcb072b3234b2ad3eeea6e6b1f64be3b3')
+    version('5.4.2',  sha256='cfc768c55f0a0cd232bed914a9022528f8f2e50cb010bf0e4f3f62db3dfa17bd')
+    version('5.4.0',  sha256='1739633424bde3d89164ae6ff1c5c913be38b9997e451558ef873aac4bbc408a')
+    version('5.3.2',  sha256='c8d3fd2ead30705c6673c5e4af6c6f3973346b4fb2bd6079c7be0943a5b0282d')
+    version('5.2.1',  sha256='84e924181d4ad6db00239d87250cc89868484a14841f77fb85ab1f1dbdcd7da1')
+    version('4.8.7',  sha256='e2882295097e47fe089f8ac741a95fef47e0a73a3f3cdf21b56990638f626ea0')
+    version('4.8.6',  sha256='8b14dd91b52862e09b8e6a963507b74bc2580787d171feda197badfa7034032c')
+    version('4.8.5',  sha256='eb728f8268831dc4373be6403b7dd5d5dde03c169ad6882f9a8cb560df6aa138')
+    version('3.3.8b', sha256='1b7a1ff62ec5a9cb7a388e2ba28fda6f960b27f27999482ebeceeadb72ac9f6e')
+
+    variant('debug',      default=False,
+            description="Build debug version.")
+    variant('gtk',        default=False,
+            description="Build with gtkplus.")
+    variant('webkit',     default=False,
+            description="Build the Webkit extension")
+    variant('examples',   default=False,
+            description="Build examples.")
+    variant('framework',   default=bool(MACOS_VERSION),
+            description="Build as a macOS Framework package.")
+    variant('tools',      default=True,
+            description="Build tools, including Qt Designer.")
+    variant('dbus',       default=False,
+            description="Build with D-Bus support.")
+    variant('phonon',     default=False,
+            description="Build with phonon support.")
+    variant('opengl',     default=False,
+            description="Build with OpenGL support.")
+    variant('sql',        default=True,
+            description="Build with SQL support.")
+    variant('shared',     default=True,
+            description='Build shared libraries.')
+    variant('ssl',    default=True,
+            description="Build with OpenSSL support.")
+    variant('freetype', default='spack', description='Freetype2 support',
+            values=('spack', 'qt', 'none'), multi=False)
+
+    # Patches for gcc10
+    patch('gcc10.patch', when=('%gcc@10:'))
+
+    # Patches for qt@3
+    patch('qt3-accept.patch', when='@3')
+    patch('qt3-headers.patch', when='@3')
+
+    # Patches for qt@4
+    patch('qt4-configure-gcc.patch', when='@4:4.8.6 %gcc')
+    patch('qt4-87-configure-gcc.patch', when='@4.8.7 %gcc')
+    patch('qt4-tools.patch', when='@4+tools')
+    patch('qt4-mac.patch', when='@4.8.7 platform=darwin')
+    # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=925811
+    patch("qt4-qforeach.patch", when="@4 %gcc@9:")
+
+    # Patches for qt@4:
+    # https://github.com/spack/spack/issues/1517
+    patch('qt4-pcre.patch', when='@4')
+    patch('qt5-pcre.patch', when='@5:')
+    # https://bugreports.qt.io/browse/QTBUG-74196
+    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89585
+    patch('qt4-asm-volatile.patch', when='@4')
+    patch('qt5-asm-volatile.patch', when='@5.0.0:5.12.1')
+
+    # Patches for qt@5
+    # https://bugreports.qt.io/browse/QTBUG-74219
+    patch('qt5-btn_trigger_happy.patch', when='@5.7:5.12')
+    # https://bugreports.qt.io/browse/QTBUG-57656
+    patch('qt5-8-framework.patch', when='@5.8.0 +framework')
+    # https://bugreports.qt.io/browse/QTBUG-58038
+    patch('qt5-8-freetype.patch', when='@5.8.0 freetype=spack')
+    # https://codereview.qt-project.org/c/qt/qtbase/+/245425
+    patch('https://github.com/qt/qtbase/commit/a52d7861edfb5956de38ba80015c4dd0b596259b.patch',
+          sha256='c49b228c27e3ad46ec3af4bac0e9985af5b5b28760f238422d32e14f98e49b1e',
+          working_dir='qtbase',
+          when='@5.10:5.12.0 %gcc@9:')
+    # https://github.com/Homebrew/homebrew-core/pull/5951
+    patch('qt5-restore-pc-files.patch', when='@5.9:5.11 platform=darwin')
+    # https://github.com/spack/spack/issues/14400
+    patch('qt5-11-intel-overflow.patch', when='@5.11 %intel')
+    patch('qt5-12-intel-overflow.patch', when='@5.12:5.14.0 %intel')
+    # https://bugreports.qt.io/browse/QTBUG-78937
+    patch('qt5-12-configure.patch', when='@5.12')
+
+    # Build-only dependencies
+    depends_on("pkgconfig", type='build')
+    depends_on("flex", when='+webkit', type='build')
+    depends_on("bison", when='+webkit', type='build')
+    depends_on("python", when='@5.7.0:', type='build')
+
+    # Dependencies, then variant- and version-specific dependencies
+    depends_on("icu4c")
+    depends_on("jpeg")
+    depends_on("libmng")
+    depends_on("libtiff")
+    depends_on("libxml2")
+    depends_on("zlib")
+    depends_on("freetype", when='freetype=spack')
+    depends_on("gperf", when='+webkit')
+    depends_on("gtkplus", when='+gtk')
+    depends_on("openssl", when='+ssl')
+    depends_on("sqlite+column_metadata", when='+sql', type=('build', 'run'))
+
+    depends_on("libpng@1.2.57", when='@3')
+    depends_on("libsm", when='@3')
+    depends_on("pcre+multibyte", when='@5.0:5.8')
+    depends_on("inputproto", when='@:5.8')
+    depends_on("openssl@:1.0.999", when='@4:5.9+ssl')
+
+    depends_on("glib", when='@4:')
+    depends_on("libpng", when='@4:')
+    depends_on("dbus", when='@4:+dbus')
+    depends_on("gl", when='@4:+opengl')
+
+    depends_on("harfbuzz", when='@5:')
+    depends_on("double-conversion", when='@5.7:')
+    depends_on("pcre2+multibyte", when='@5.9:')
+
+    # gcc@4 is not supported as of Qt@5.14
+    # https://doc.qt.io/qt-5.14/supported-platforms.html
+    conflicts('%gcc@:4.99', when='@5.14:')
+
+    # Non-macOS dependencies and special macOS constraints
+    if MACOS_VERSION is None:
+        depends_on("fontconfig", when='freetype=spack')
+        depends_on("libsm")
+        depends_on("libx11")
+        depends_on("libxcb")
+        depends_on("libxkbcommon")
+        depends_on("xcb-util-image")
+        depends_on("xcb-util-keysyms")
+        depends_on("xcb-util-renderutil")
+        depends_on("xcb-util-wm")
+        depends_on("libxext")
+        depends_on("libxrender")
+        conflicts('+framework',
+                  msg="QT cannot be built as a framework except on macOS.")
+    else:
+        conflicts('platform=darwin', when='@4.8.6',
+                  msg="QT 4 for macOS is only patched for 4.8.7")
+
+    use_xcode = True
+
+    # Mapping for compilers/systems in the QT 'mkspecs'
+    compiler_mapping = {'intel': ('icc',),
+                        'apple-clang': ('clang-libc++', 'clang'),
+                        'clang': ('clang-libc++', 'clang'),
+                        'gcc': ('g++',)}
+    platform_mapping = {'darwin': 'macx'}
+
+    def url_for_version(self, version):
+        # URL keeps getting more complicated with every release
+        url = self.list_url
+
+        if version >= Version('4.0'):
+            url += str(version.up_to(2)) + '/'
+        else:
+            url += str(version.up_to(1)) + '/'
+
+        if version >= Version('4.8'):
+            url += str(version) + '/'
+
+        if version >= Version('5'):
+            url += 'single/'
+
+        url += 'qt-'
+
+        if version >= Version('4.6'):
+            url += 'everywhere-'
+        elif version >= Version('2.1'):
+            url += 'x11-'
+
+        if version >= Version('5.10.0'):
+            url += 'src-'
+        elif version >= Version('4.0'):
+            url += 'opensource-src-'
+        elif version >= Version('3'):
+            url += 'free-'
+
+        # 5.9 only has xz format. From 5.2.1 -> 5.8.0 .gz or .xz were possible
+        if version >= Version('5.9'):
+            url += str(version) + '.tar.xz'
+        else:
+            url += str(version) + '.tar.gz'
+
+        return url
+
+    def setup_build_environment(self, env):
+        env.set('MAKEFLAGS', '-j{0}'.format(make_jobs))
+
+    def setup_run_environment(self, env):
+        env.set('QTDIR', self.prefix)
+
+    def setup_dependent_build_environment(self, env, dependent_spec):
+        env.set('QTDIR', self.prefix)
+
+    def setup_dependent_package(self, module, dependent_spec):
+        module.qmake = Executable(join_path(self.spec.prefix.bin, 'qmake'))
+
+    def get_mkspec(self):
+        """Determine the mkspecs root directory and QT platform.
+        """
+        spec = self.spec
+        cname = spec.compiler.name
+        pname = spec.architecture.platform
+
+        # Transform spack compiler name to a list of possible QT compilers
+        cnames = self.compiler_mapping.get(cname, [cname])
+        # Transform platform name to match those in QT
+        pname = self.platform_mapping.get(pname, pname)
+
+        qtplat = None
+        mkspec_dir = 'qtbase/mkspecs' if spec.satisfies('@5:') else 'mkspecs'
+        for subdir, cname in itertools.product(('', 'unsupported/'), cnames):
+            platdirname = "".join([subdir, pname, "-", cname])
+            tty.debug("Checking for platform '{0}' in {1}".format(
+                      platdirname, mkspec_dir))
+            if os.path.exists(os.path.join(mkspec_dir, platdirname)):
+                qtplat = platdirname
+                break
+        else:
+            tty.warn("No matching QT platform was found in {0} "
+                     "for platform '{1}' and compiler {2}".format(
+                         mkspec_dir, pname, ",".join(cnames)))
+
+        return (mkspec_dir, qtplat)
+
+    @when('@4 platform=darwin')
+    def patch(self):
+        ogl = self.spec['opengl'] if '+opengl' in self.spec else None
+        deployment_target = str(MACOS_VERSION.up_to(2))
+
+        patches = {
+            'MACOSX_DEPLOYMENT_TARGET': deployment_target,
+            'PREFIX': self.prefix,
+            'OPENGL_INCDIR': ogl.prefix.include if ogl else "",
+            'OPENGL_LIBS': ogl.libs.ld_flags if ogl else "",
+        }
+
+        def repl(match):
+            # Replace the original config variable value with the one chosen
+            # here if it is mentioned in 'patches'; otherwise return the
+            # original value.
+            return patches.get(match.group(1), match.group(0))
+
+        files_to_filter = [
+            "configure",
+            "mkspecs/common/mac.conf",
+            "mkspecs/common/unix.conf",
+            "mkspecs/common/gcc-base-macx.conf",
+            "mkspecs/common/gcc-base.conf",
+            "qmake/generators/unix/unixmake.cpp",
+            "qmake/qmake.pri",
+            "src/tools/bootstrap/bootstrap.pro"
+        ]
+        if '%clang' in self.spec or '%apple-clang' in self.spec:
+            files_to_filter += [
+                "mkspecs/unsupported/macx-clang-libc++/qmake.conf",
+                "mkspecs/common/clang.conf"
+            ]
+        elif '%gcc' in self.spec:
+            files_to_filter += [
+                "mkspecs/common/g++-macx.conf",
+                "mkspecs/darwin-g++/qmake.conf"
+            ]
+
+        # Filter inserted configure variables
+        filter_file(r'@([a-zA-Z0-9_]+)@', repl, *files_to_filter)
+
+        # Remove debug build
+        files_to_filter = [
+            "src/3rdparty/webkit/Source/WebKit.pri",
+            "src/3rdparty/webkit/Source/WebKit/qt/declarative/declarative.pro",
+            "src/imports/qimportbase.pri",
+            "src/plugins/qpluginbase.pri",
+            "src/qbase.pri",
+            "tools/designer/src/components/lib/lib.pro",
+            "tools/designer/src/lib/lib.pro",
+            "tools/designer/src/plugins/activeqt/activeqt.pro",
+            "tools/designer/src/plugins/plugins.pri",
+            "tools/designer/src/uitools/uitools.pro",
+        ]
+        filter_file(r'(\+=.*)debug_and_release', r'\1', *files_to_filter)
+
+    @when('@4: %gcc')  # *NOT* darwin/mac gcc
+    def patch(self):
+        (mkspec_dir, platform) = self.get_mkspec()
+
+        def conf(name):
+            return os.path.join(mkspec_dir, 'common', name + '.conf')
+
+        # Fix qmake compilers in the default mkspec
+        filter_file('^QMAKE_CC .*', 'QMAKE_CC = cc', conf('g++-base'))
+        filter_file('^QMAKE_CXX .*', 'QMAKE_CXX = c++', conf('g++-base'))
+
+        # Don't error out on undefined symbols
+        filter_file('^QMAKE_LFLAGS_NOUNDEF .*', 'QMAKE_LFLAGS_NOUNDEF = ',
+                    conf('g++-unix'))
+
+        if self.spec.satisfies('@4'):
+            # Necessary to build with GCC 6 and other modern compilers
+            # http://stackoverflow.com/questions/10354371/
+            with open(conf('gcc-base'), 'a') as f:
+                f.write("QMAKE_CXXFLAGS += -std=gnu++98\n")
+                f.write("QMAKE_CXXFLAGS += -fcommon\n")
+                f.write("QMAKE_CFLAGS += -fcommon\n")
+
+    @when('@4: %intel')
+    def patch(self):
+        (mkspec_dir, platform) = self.get_mkspec()
+        conf_file = os.path.join(mkspec_dir, platform, "qmake.conf")
+
+        # Intel's `ar` equivalent might not be in the path: replace it with
+        # explicit
+        xiar = os.path.join(os.path.dirname(self.compiler.cc), 'xiar')
+        filter_file(r'\bxiar\b', xiar, conf_file)
+
+        if self.spec.satisfies('@4'):
+            with open(conf_file, 'a') as f:
+                f.write("QMAKE_CXXFLAGS += -std=gnu++98\n")
+
+    @when('@4 %clang')
+    def patch(self):
+        (mkspec_dir, platform) = self.get_mkspec()
+        conf_file = os.path.join(mkspec_dir, platform, "qmake.conf")
+
+        with open(conf_file, 'a') as f:
+            f.write("QMAKE_CXXFLAGS += -std=gnu++98\n")
+
+    @property
+    def common_config_args(self):
+        # incomplete list is here http://doc.qt.io/qt-5/configure-options.html
+        config_args = [
+            '-prefix', self.prefix,
+            '-v',
+            '-opensource',
+            '-{0}opengl'.format('' if '+opengl' in self.spec else 'no-'),
+            '-{0}'.format('debug' if '+debug' in self.spec else 'release'),
+            '-confirm-license',
+            '-optimized-qmake',
+            '-no-pch',
+        ]
+
+        if self.spec.variants['freetype'].value == 'spack':
+            config_args.extend([
+                '-system-freetype'
+            ])
+            config_args.extend(
+                self.spec['freetype'].headers.include_flags.split()
+            )
+            if not MACOS_VERSION:
+                config_args.append('-fontconfig')
+
+        elif self.spec.variants['freetype'].value == 'qt':
+            config_args.append('-qt-freetype')
+        else:
+            config_args.append('-no-freetype')
+
+        if '+ssl' in self.spec:
+            openssl = self.spec['openssl']
+            config_args.extend([
+                '-openssl-linked',
+                openssl.libs.search_flags,
+                openssl.headers.include_flags,
+            ])
+        else:
+            config_args.append('-no-openssl')
+
+        if '+sql' in self.spec:
+            sqlite = self.spec['sqlite']
+            config_args.extend([
+                '-system-sqlite',
+                '-R', sqlite.prefix.lib,
+            ])
+        else:
+            comps = ['db2', 'ibase', 'oci', 'tds', 'mysql', 'odbc', 'psql',
+                     'sqlite', 'sqlite2']
+            config_args.extend("-no-sql-" + component for component in comps)
+
+        if '+shared' in self.spec:
+            config_args.append('-shared')
+        else:
+            config_args.append('-static')
+
+        if self.spec.satisfies('@5:'):
+            pcre = self.spec['pcre'] if self.spec.satisfies('@5.0:5.8') \
+                else self.spec['pcre2']
+            harfbuzz = self.spec['harfbuzz']
+            config_args.extend([
+                '-system-harfbuzz',
+                harfbuzz.libs.search_flags,
+                harfbuzz.headers.include_flags,
+                '-system-pcre',
+                pcre.libs.search_flags,
+                pcre.headers.include_flags
+            ])
+
+        if self.spec.satisfies('@5.7:'):
+            dc = self.spec['double-conversion']
+            config_args.extend([
+                '-system-doubleconversion',
+                dc.libs.search_flags,
+                dc.headers.include_flags
+            ])
+
+        if '@:5.7.1' in self.spec:
+            config_args.append('-no-openvg')
+        else:
+            # FIXME: those could work for other versions
+            png = self.spec['libpng']
+            config_args.append('-system-libpng')
+            if not png.external:
+                config_args.extend([
+                    png.libs.search_flags,
+                    png.headers.include_flags
+                ])
+
+            jpeg = self.spec['jpeg']
+            config_args.append('-system-libjpeg')
+            if not jpeg.external:
+                config_args.extend([
+                    jpeg.libs.search_flags,
+                    jpeg.headers.include_flags,
+                ])
+            zlib = self.spec['zlib']
+            config_args.append('-system-zlib')
+            if not zlib.external:
+                config_args.extend([
+                    zlib.libs.search_flags,
+                    zlib.headers.include_flags
+                ])
+
+        if '@:5.7.0' in self.spec:
+            config_args.extend([
+                # NIS is deprecated in more recent glibc,
+                # but qt-5.7.1 does not recognize this option
+                '-no-nis',
+            ])
+
+        if '~examples' in self.spec:
+            config_args.extend(['-nomake', 'examples'])
+
+        if '~tools' in self.spec:
+            config_args.extend(['-nomake', 'tools'])
+
+        if '+dbus' in self.spec:
+            dbus = self.spec['dbus'].prefix
+            config_args.append('-dbus-linked')
+            config_args.append('-I%s/dbus-1.0/include' % dbus.lib)
+            config_args.append('-I%s/dbus-1.0' % dbus.include)
+            config_args.append('-L%s' % dbus.lib)
+        else:
+            config_args.append('-no-dbus')
+
+        if MACOS_VERSION:
+            config_args.append('-{0}framework'.format(
+                '' if '+framework' in self.spec else 'no-'))
+
+        (_, qtplat) = self.get_mkspec()
+        if qtplat is not None:
+            config_args.extend(['-platform', qtplat])
+
+        return config_args
+
+    @when('@3')
+    def configure(self, spec, prefix):
+        # A user reported that this was necessary to link Qt3 on ubuntu.
+        # However, if LD_LIBRARY_PATH is not set the qt build fails, check
+        # and set LD_LIBRARY_PATH if not set, update if it is set.
+        if os.environ.get('LD_LIBRARY_PATH'):
+            os.environ['LD_LIBRARY_PATH'] += os.pathsep + os.getcwd() + '/lib'
+        else:
+            os.environ['LD_LIBRARY_PATH'] = os.pathsep + os.getcwd() + '/lib'
+
+        configure('-prefix', prefix,
+                  '-v',
+                  '-thread',
+                  '-shared',
+                  '-release',
+                  '-fast')
+
+    @when('@4')
+    def configure(self, spec, prefix):
+        config_args = self.common_config_args
+
+        config_args.extend([
+            '-fast',
+            '-no-declarative-debug',
+            '-{0}gtkstyle'.format('' if '+gtk' in spec else 'no-'),
+            '-{0}webkit'.format('' if '+webkit' in spec else 'no-'),
+            '-{0}phonon'.format('' if '+phonon' in spec else 'no-'),
+            '-arch', str(spec.target.family),
+            '-xmlpatterns',
+        ])
+
+        # Disable phonon backend until gstreamer is setup as dependency
+        if '+phonon' in self.spec:
+            config_args.append('-no-phonon-backend')
+
+        if '~examples' in self.spec:
+            config_args.extend(['-nomake', 'demos'])
+
+        if MACOS_VERSION:
+            sdkpath = which('xcrun')('--show-sdk-path', output=str).strip()
+            config_args.extend([
+                '-cocoa',
+                '-sdk', sdkpath])
+
+        configure(*config_args)
+
+    @when('@5')
+    def configure(self, spec, prefix):
+        config_args = self.common_config_args
+        version = self.version
+
+        config_args.extend([
+            '-no-eglfs',
+            '-no-directfb',
+            '-{0}gtk{1}'.format(
+                '' if '+gtk' in spec else 'no-',
+                '' if version >= Version('5.7') else 'style')
+        ])
+
+        if MACOS_VERSION:
+            config_args.extend([
+                '-no-xcb-xlib',
+                '-no-pulseaudio',
+                '-no-alsa',
+            ])
+            if version < Version('5.12'):
+                config_args.append('-no-xinput2')
+        else:
+            # Linux-only QT5 dependencies
+            config_args.append('-system-xcb')
+
+        if '~webkit' in spec:
+            config_args.extend([
+                '-skip',
+                'webengine' if version >= Version('5.7') else 'qtwebkit',
+            ])
+
+        if spec.satisfies('@5.7'):
+            config_args.extend(['-skip', 'virtualkeyboard'])
+
+        if version >= Version('5.8'):
+            # relies on a system installed wayland, i.e. no spack package yet
+            # https://wayland.freedesktop.org/ubuntu16.04.html
+            # https://wiki.qt.io/QtWayland
+            config_args.extend(['-skip', 'wayland'])
+
+        if version >= Version('5.10') and '~opengl' in spec:
+            config_args.extend([
+                '-skip', 'webglplugin',
+                '-skip', 'qt3d',
+            ])
+
+        if version >= Version('5.14') and '~opengl' in spec:
+            config_args.extend([
+                '-skip', 'qtquick3d',
+            ])
+
+        configure(*config_args)
+
+    def build(self, spec, prefix):
+        make()
+
+    def install(self, spec, prefix):
+        make("install")
diff --git a/spack/packages/qt/qt3-accept.patch b/spack/packages/qt/qt3-accept.patch
new file mode 100644
index 000000000..32dfb9df0
--- /dev/null
+++ b/spack/packages/qt/qt3-accept.patch
@@ -0,0 +1,38 @@
+--- qt-x11-free-3.3.8b/configure	2008-01-15 13:09:15.000000000 -0600
++++ qt-x11-free-3.3.8b-fixes/configure	2015-07-08 15:49:03.379560633 -0500
+@@ -2339,7 +2339,7 @@
+         else
+             echo "Do you accept the terms of the $TheLicense? \c"
+         fi
+-        read acceptance
++        acceptance=yes
+         echo
+ 	if [ "$acceptance" = yes ]; then
+ 	    break
+@@ -2397,7 +2397,7 @@
+ 	else
+ 	    echo "Do you accept the terms of $affix license? \c"
+ 	fi
+-	read acceptance
++        acceptance=yes
+ 	echo
+ 	if [ "$acceptance" = "yes" ]; then
+ 	    break
+@@ -2443,7 +2443,7 @@
+ 	else
+ 	    echo "Do you accept the terms of the license? \c"
+ 	fi
+-	read acceptance
++        acceptance=yes
+ 	echo
+ 	if [ "$acceptance" = "yes" ]; then
+ 	    break
+@@ -2524,7 +2524,7 @@
+ 	else
+ 	    echo "Do you accept the terms of the $Platform License? \c"
+ 	fi
+-	read acceptance
++        acceptance=yes
+ 	echo
+ 	if [ "$acceptance" = "yes" ]; then
+ 	    break
diff --git a/spack/packages/qt/qt3-headers.patch b/spack/packages/qt/qt3-headers.patch
new file mode 100644
index 000000000..52b133b57
--- /dev/null
+++ b/spack/packages/qt/qt3-headers.patch
@@ -0,0 +1,30 @@
+--- a/src/tools/qmap.h	2008-01-16 06:09:13.000000000 +1100
++++ b/src/tools/qmap.h	2018-01-07 11:32:38.720893324 +1100
+@@ -52,6 +52,7 @@
+ #ifndef QT_NO_STL
+ #include <iterator>
+ #include <map>
++#include <stddef.h>
+ #endif
+ 
+ //#define QT_CHECK_MAP_RANGE
+--- a/src/tools/qvaluelist.h	2008-01-16 06:09:13.000000000 +1100
++++ b/src/tools/qvaluelist.h	2018-01-07 11:33:03.393206961 +1100
+@@ -50,6 +50,7 @@
+ #ifndef QT_NO_STL
+ #include <iterator>
+ #include <list>
++#include <stddef.h>
+ #endif
+ 
+ //#define QT_CHECK_VALUELIST_RANGE
+--- qt-x11-free-3.3.8b/src/tools/qvaluevector.h	2008-01-15 13:09:13.000000000 -0600
++++ qt-x11-free-3.3.8b-fixes/src/tools/qvaluevector.h	2015-07-08 15:47:34.758565247 -0500
+@@ -47,6 +47,7 @@
+ 
+ #ifndef QT_NO_STL
+ #include <vector>
++#include <cstddef>
+ #endif
+ 
+ template <class T>
diff --git a/spack/packages/qt/qt4-87-configure-gcc.patch b/spack/packages/qt/qt4-87-configure-gcc.patch
new file mode 100644
index 000000000..ee3a6cd52
--- /dev/null
+++ b/spack/packages/qt/qt4-87-configure-gcc.patch
@@ -0,0 +1,20 @@
+--- a/configure.orig	2018-09-18 07:02:33.866633000 +1000
++++ b/configure	2018-09-18 07:05:21.935194000 +1000
+@@ -7708,7 +7708,7 @@
+ 
+ 	# Check gcc's version
+ 	case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in
+-	    4*)
++	    [4-8]*)
+ 		;;
+ 	    3.4*)
+ 		canBuildQtXmlPatterns="no"
+@@ -7729,7 +7729,7 @@
+     *-g++*)
+ 	# Check gcc's version
+ 	case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in
+-	    5*|4*|3.4*)
++	    [4-8]*|3.4*)
+ 		;;
+             3.3*)
+                 canBuildWebKit="no"
diff --git a/spack/packages/qt/qt4-asm-volatile.patch b/spack/packages/qt/qt4-asm-volatile.patch
new file mode 100644
index 000000000..e3d3cae1f
--- /dev/null
+++ b/spack/packages/qt/qt4-asm-volatile.patch
@@ -0,0 +1,236 @@
+From 97ec1d1882a83c23c91f0f7daea48e05858d8c32 Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Mon, 28 Jan 2019 14:33:12 -0800
+Subject: [PATCH] Fix build with GCC 8.3
+
+Qualifiers in the asm statement are not allowed in the global scope. I
+thought they were necessary for LTO, but I the commit to this file that
+added them predates my work on setting up LTO for GCC.
+
+Change-Id: Id98140e1c2f0426cabbefffd157e23e5ece67a49
+Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
+**BACKPORTED** for use in QT4 by Omar Padron <omar.padron@kitware.com>
+---
+ .../JavaScriptCore/jit/JITStubs.cpp           | 48 +++++++++----------
+ 1 file changed, 24 insertions(+), 24 deletions(-)
+
+diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
+index 1abdf8b..9f60761 100644
+--- a/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp	2019-05-30 10:25:30.712979194 -0400
++++ b/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp	2019-05-30 10:24:29.666340851 -0400
+@@ -116,7 +116,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x3c, JITStackFrame_s
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline);
+ 
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+@@ -138,7 +138,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -154,7 +154,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+     
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+@@ -179,7 +179,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_s
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x90, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_offset_matches_ctiTrampoline);
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+@@ -206,7 +206,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -222,7 +222,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+@@ -242,7 +242,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ #error "JIT_STUB_ARGUMENT_VA_LIST not supported on ARMv7."
+ #endif
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+@@ -269,7 +269,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "bx lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+@@ -287,7 +287,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "bx lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+@@ -305,7 +305,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ 
+ #elif COMPILER(GCC) && CPU(ARM_TRADITIONAL)
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+@@ -323,7 +323,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "mov pc, lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -418,7 +418,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
+ 
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+@@ -440,7 +440,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -456,7 +456,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+     
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+@@ -480,7 +480,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x48, JITStackFrame_code_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x78, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
+ 
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+@@ -515,7 +515,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -531,7 +531,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+@@ -551,7 +551,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ #error "JIT_STUB_ARGUMENT_VA_LIST not supported on ARMv7."
+ #endif
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+@@ -578,7 +578,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "bx lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+@@ -596,7 +596,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "bx lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+@@ -614,7 +614,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ 
+ #elif COMPILER(GCC) && CPU(ARM_TRADITIONAL)
+ 
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+@@ -632,7 +632,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "mov pc, lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -1024,7 +1024,7 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD
+     extern "C" { \
+         rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \
+     }; \
+-    asm volatile ( \
++    asm ( \
+         ".text" "\n" \
+         ".align 2" "\n" \
+         ".globl " SYMBOL_STRING(cti_##op) "\n" \
+@@ -1053,7 +1053,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, thunkReturnAddress) == THUNK_RETUR
+     extern "C" { \
+         rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \
+     }; \
+-    asm volatile ( \
++    asm ( \
+         ".globl " SYMBOL_STRING(cti_##op) "\n" \
+         HIDE_SYMBOL(cti_##op) "\n"             \
+         SYMBOL_STRING(cti_##op) ":" "\n" \
diff --git a/spack/packages/qt/qt4-configure-gcc.patch b/spack/packages/qt/qt4-configure-gcc.patch
new file mode 100644
index 000000000..38a1c350f
--- /dev/null
+++ b/spack/packages/qt/qt4-configure-gcc.patch
@@ -0,0 +1,20 @@
+--- a/configure.orig	2018-09-18 07:02:33.866633000 +1000
++++ b/configure	2018-09-18 07:05:21.935194000 +1000
+@@ -7708,7 +7708,7 @@
+ 
+ 	# Check gcc's version
+ 	case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in
+-	    4*)
++	    [4-8]*)
+ 		;;
+ 	    3.4*)
+ 		canBuildQtXmlPatterns="no"
+@@ -7729,7 +7729,7 @@
+     *-g++*)
+ 	# Check gcc's version
+ 	case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in
+-	    4*|3.4*)
++	    [4-8]*|3.4*)
+ 		;;
+             3.3*)
+                 canBuildWebKit="no"
diff --git a/spack/packages/qt/qt4-mac.patch b/spack/packages/qt/qt4-mac.patch
new file mode 100644
index 000000000..d163f4189
--- /dev/null
+++ b/spack/packages/qt/qt4-mac.patch
@@ -0,0 +1,631 @@
+diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp
+index 4aa0668..63b646d 100644
+--- a/src/gui/painting/qpaintengine_mac.cpp
++++ b/src/gui/painting/qpaintengine_mac.cpp
+@@ -340,13 +340,7 @@ CGColorSpaceRef QCoreGraphicsPaintEngine::macDisplayColorSpace(const QWidget *wi
+     }
+ 
+     // Get the color space from the display profile.
+-    CGColorSpaceRef colorSpace = 0;
+-    CMProfileRef displayProfile = 0;
+-    CMError err = CMGetProfileByAVID((CMDisplayIDType)displayID, &displayProfile);
+-    if (err == noErr) {
+-        colorSpace = CGColorSpaceCreateWithPlatformColorSpace(displayProfile);
+-        CMCloseProfile(displayProfile);
+-    }
++    CGColorSpaceRef colorSpace = CGDisplayCopyColorSpace(displayID);
+ 
+     // Fallback: use generic DeviceRGB
+     if (colorSpace == 0)
+diff -r -u a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
+--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm	2015-05-07 10:14:43.000000000 -0400
++++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm	2019-03-20 09:30:22.000000000 -0400
+@@ -73,6 +73,9 @@
+ **
+ ****************************************************************************/
+ 
++// Needed for macOS 10.13 (High Sierra)
++#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 1
++
+ #include <private/qcore_mac_p.h>
+ #include <qaction.h>
+ #include <qwidget.h>
+diff -r -u a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
+--- a/src/gui/text/qfontengine_coretext.mm	2015-05-07 10:14:43.000000000 -0400
++++ b/src/gui/text/qfontengine_coretext.mm	2019-03-20 09:30:22.000000000 -0400
+@@ -886,7 +886,7 @@
+ 
+ QFixed QCoreTextFontEngine::emSquareSize() const
+ {
+-    return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
++    return QFixed(int(CTFontGetUnitsPerEm(ctfont)));
+ }
+ 
+ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
+diff -r -u a/config.tests/unix/compile.test b/config.tests/unix/compile.test
+--- a/config.tests/unix/compile.test	2015-05-07 10:14:42.000000000 -0400
++++ b/config.tests/unix/compile.test	2019-03-20 09:30:21.000000000 -0400
+@@ -73,7 +73,7 @@
+ rm -f "$EXE" "${EXE}.exe"
+ 
+ echo "QT_BUILD_TREE = $OUTDIR" > "$OUTDIR/$TEST/.qmake.cache"
+-"$OUTDIR/bin/qmake" -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG-=debug_and_release" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile"
++"$OUTDIR/bin/qmake" -spec "$QMKSPEC" "CONFIG+=$QMAKE_CONFIG" "CONFIG-=debug_and_release app_bundle" "LIBS*=$LFLAGS" "LIBS+=$MAC_ARCH_LFLAGS" "INCLUDEPATH*=$INCLUDEPATH" "QMAKE_CFLAGS*=$CXXFLAGS" "QMAKE_CFLAGS+=$MAC_ARCH_CXXFLAGS" "QMAKE_OBJECTIVE_CFLAGS*=$CXXFLAGS" "QMAKE_OBJECTIVE_CFLAGS+=$MAC_ARCH_CXXFLAGS" "QMAKE_OBJECTIVE_CXXFLAGS*=$CXXFLAGS" "QMAKE_OBJECTIVE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "QMAKE_CXXFLAGS*=$CXXFLAGS" "QMAKE_CXXFLAGS+=$MAC_ARCH_CXXFLAGS" "$SRCDIR/$TEST/$EXE.pro" -o "$OUTDIR/$TEST/Makefile"
+ 
+ if [ "$VERBOSE" = "yes" ]; then
+     $MAKE
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/configure qt-everywhere-opensource-src-4.8.7/configure
+--- qt-everywhere-opensource-src-4.8.7.orig/configure	2019-04-04 15:44:58.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/configure	2019-04-04 16:50:38.000000000 -0400
+@@ -3472,9 +3472,8 @@
+ # auto-detect support for -Xarch on the mac
+ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" = "auto" ]; then
+     if "$mactests/xarch.test" "$TEST_COMPILER" "$OPT_VERBOSE" "$mactests" ; then
+-        CFG_MAC_XARCH=no
+-    else
+-        CFG_MAC_XARCH=yes
++      echo >&2 "error: -Xarch flag support is required to build on macOS."
++      exit 1
+     fi
+ fi
+ 
+@@ -5013,8 +5012,8 @@
+                 # Avoid overriding the default configuration settings when building with clang/libc++
+                 ;;
+             *)
+-                # For all other configurations require a minimum of 10.5
+-                echo "export MACOSX_DEPLOYMENT_TARGET = 10.5" >> "$mkfile"
++                # For all other configurations require a minimum of 10.13
++                echo "export MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@" >> "$mkfile"
+                 ;;
+             esac
+ 
+@@ -5025,20 +5024,11 @@
+             EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(CARBON_CFLAGS)"
+             EXTRA_OBJS="qsettings_mac.o qcore_mac.o"
+             EXTRA_SRCS="\"$relpath/src/corelib/io/qsettings_mac.cpp\" \"$relpath/src/corelib/kernel/qcore_mac.cpp\""
+-	    if echo "$CFG_MAC_ARCHS" | grep x86 > /dev/null 2>&1; then # matches both x86 and x86_64
+-		X86_CFLAGS="-arch i386"
+-		X86_LFLAGS="-arch i386"
+-		EXTRA_CFLAGS="$X86_CFLAGS $EXTRA_CFLAGS"
+-		EXTRA_CXXFLAGS="$X86_CFLAGS $EXTRA_CXXFLAGS"
+-                EXTRA_LFLAGS="$EXTRA_LFLAGS $X86_LFLAGS"
+-            fi
+-	    if echo "$CFG_MAC_ARCHS" | grep ppc > /dev/null 2>&1; then # matches both ppc and ppc64
+-		PPC_CFLAGS="-arch ppc"
+-		PPC_LFLAGS="-arch ppc"
+-		EXTRA_CFLAGS="$PPC_CFLAGS $EXTRA_CFLAGS"
+-		EXTRA_CXXFLAGS="$PPC_CFLAGS $EXTRA_CXXFLAGS"
+-                EXTRA_LFLAGS="$EXTRA_LFLAGS $PPC_LFLAGS"
+-            fi
++            ARCH_CFLAGS="-arch x86_64"
++            ARCH_LFLAGS="-arch x86_64"
++            EXTRA_CFLAGS="$ARCH_CFLAGS $EXTRA_CFLAGS"
++            EXTRA_CXXFLAGS="$ARCH_CFLAGS $EXTRA_CXXFLAGS"
++            EXTRA_LFLAGS="$EXTRA_LFLAGS $ARCH_LFLAGS"
+ 	    if [ '!' -z "$CFG_SDK" ]; then
+ 		echo "SDK_LFLAGS =-Wl,-syslibroot,$CFG_SDK" >>"$mkfile"
+ 		echo "SDK_CFLAGS =-isysroot $CFG_SDK" >>"$mkfile"
+@@ -7224,19 +7214,7 @@
+ 
+ # set the global Mac deployment target. This is overridden on an arch-by-arch basis
+ # in some cases, see code further down
+-case "$PLATFORM,$CFG_MAC_COCOA" in
+-*macx-clang-libc++,yes)
+-    # Avoid overriding the default configuration setting when building with clang/libc++
+-    ;;
+-macx*,yes)
+-    # Cocoa
+-    QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.5
+-    ;;
+-macx*,no)
+-    # gcc, Carbon
+-    QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.4
+-    ;;
+-esac
++QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET @MACOSX_DEPLOYMENT_TARGET@
+ 
+ # disable Qt 3 support on VxWorks, Symbian and INTEGRITY
+ case "$XPLATFORM" in
+@@ -7515,7 +7493,6 @@
+     QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GUI"
+ fi
+ 
+-
+ if [ "x$PLATFORM_MAC" = "xyes" ] && [ "$XPLATFORM_MINGW" != "yes" ] && [ "$XPLATFORM_SYMBIAN" != "yes" ]; then
+     #On Mac we implicitly link against libz, so we
+     #never use the 3rdparty stuff.
+@@ -7975,39 +7952,19 @@
+     QMAKE_CONFIG="$QMAKE_CONFIG exceptions_off"
+ fi
+ 
+-# On Mac, set the minimum deployment target for the different architechtures 
+-# using the Xarch compiler option when supported (10.5 and up).  On 10.4 the
+-# deployment version is set to 10.4 globally using the QMAKE_MACOSX_DEPLOYMENT_TARGET
+-# env. variable.
++# On Mac, set the minimum deployment target for the different architectures 
+ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_MAC_XARCH" != "no" ]; then
+     case "$PLATFORM" in
+     *macx-clang-libc++)
+         # Avoid overriding the default settings when building clang/libc++.
+         ;;
+     *)
+-        if echo "$CFG_MAC_ARCHS" | grep '\<x86\>' > /dev/null 2>&1; then
+-            QMakeVar add QMAKE_CFLAGS "-Xarch_i386 -mmacosx-version-min=10.4"
+-            QMakeVar add QMAKE_CXXFLAGS "-Xarch_i386 -mmacosx-version-min=10.4"
+-            QMakeVar add QMAKE_LFLAGS "-Xarch_i386 -mmacosx-version-min=10.4"
+-            QMakeVar add QMAKE_OBJECTIVE_CFLAGS_X86 "-arch i386 -Xarch_i386 -mmacosx-version-min=10.4"
+-        fi
+-        if echo "$CFG_MAC_ARCHS" | grep '\<ppc\>' > /dev/null 2>&1; then
+-            QMakeVar add QMAKE_CFLAGS "-Xarch_ppc -mmacosx-version-min=10.4"
+-            QMakeVar add QMAKE_CXXFLAGS "-Xarch_ppc -mmacosx-version-min=10.4"
+-            QMakeVar add QMAKE_LFLAGS "-Xarch_ppc -mmacosx-version-min=10.4"
+-            QMakeVar add QMAKE_OBJECTIVE_CFLAGS_PPC "-arch ppc -Xarch_ppc -mmacosx-version-min=10.4"
+-        fi
+         if echo "$CFG_MAC_ARCHS" | grep '\<x86_64\>' > /dev/null 2>&1; then
+-            QMakeVar add QMAKE_CFLAGS "-Xarch_x86_64 -mmacosx-version-min=10.5"
+-            QMakeVar add QMAKE_CXXFLAGS "-Xarch_x86_64 -mmacosx-version-min=10.5"
+-            QMakeVar add QMAKE_LFLAGS "-Xarch_x86_64 -mmacosx-version-min=10.5"
+-            QMakeVar add QMAKE_OBJECTIVE_CFLAGS_X86_64 "-arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5"
+-        fi
+-        if echo "$CFG_MAC_ARCHS" | grep '\<ppc64\>' > /dev/null 2>&1; then
+-            QMakeVar add QMAKE_CFLAGS "-Xarch_ppc64 -mmacosx-version-min=10.5"
+-            QMakeVar add QMAKE_CXXFLAGS "-Xarch_ppc64 -mmacosx-version-min=10.5"
+-            QMakeVar add QMAKE_LFLAGS "-Xarch_ppc64 -mmacosx-version-min=10.5"
+-            QMakeVar add QMAKE_OBJECTIVE_CFLAGS_PPC_64 "-arch ppc64 -Xarch_ppc64 -mmacosx-version-min=10.5"
++            QMakeVar add QMAKE_CFLAGS "-Xarch_x86_64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
++            QMakeVar add QMAKE_CXXFLAGS "-Xarch_x86_64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
++            QMakeVar add QMAKE_OBJECTIVE_CFLAGS_X86_64 "-arch x86_64 -Xarch_x86_64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
++            QMakeVar add QMAKE_OBJECTIVE_CXXFLAGS_X86_64 "-arch x86_64 -Xarch_x86_64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
++            QMakeVar add QMAKE_LFLAGS "-Xarch_x86_64 -mmacosx-version-min=@MACOSX_DEPLOYMENT_TARGET@"
+         fi
+         ;;
+     esac
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/clang.conf qt-everywhere-opensource-src-4.8.7/mkspecs/common/clang.conf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/clang.conf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/common/clang.conf	2019-04-04 15:59:33.000000000 -0400
+@@ -2,8 +2,8 @@
+ # Qmake configuration for Clang on Linux and Mac
+ #
+ 
+-QMAKE_CC  = clang
+-QMAKE_CXX = clang++
++QMAKE_CC  = cc
++QMAKE_CXX = c++
+ 
+ QMAKE_LINK       = $$QMAKE_CXX
+ QMAKE_LINK_SHLIB = $$QMAKE_CXX
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/g++-base.conf qt-everywhere-opensource-src-4.8.7/mkspecs/common/g++-base.conf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/g++-base.conf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/common/g++-base.conf	2019-04-04 15:59:15.000000000 -0400
+@@ -8,14 +8,14 @@
+ # you can use the manual test in tests/manual/mkspecs.
+ #
+ 
+-QMAKE_CC = gcc
++QMAKE_CC = cc
+ 
+ QMAKE_LINK_C       = $$QMAKE_CC
+ QMAKE_LINK_C_SHLIB = $$QMAKE_CC
+ 
+ QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -g
+ 
+-QMAKE_CXX = g++
++QMAKE_CXX = c++
+ 
+ QMAKE_LINK       = $$QMAKE_CXX
+ QMAKE_LINK_SHLIB = $$QMAKE_CXX
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/gcc-base-macx.conf qt-everywhere-opensource-src-4.8.7/mkspecs/common/gcc-base-macx.conf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/gcc-base-macx.conf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/common/gcc-base-macx.conf	2019-04-04 15:47:55.000000000 -0400
+@@ -29,12 +29,21 @@
+ QMAKE_OBJECTIVE_CFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
+ QMAKE_OBJECTIVE_CFLAGS_DEBUG    = $$QMAKE_CFLAGS_DEBUG
+ QMAKE_OBJECTIVE_CFLAGS_RELEASE  = $$QMAKE_CFLAGS_RELEASE
+-QMAKE_OBJECTIVE_CFLAGS_HIDESYMS = $$QMAKE_CXXFLAGS_HIDESYMS
++QMAKE_OBJECTIVE_CFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS
+ QMAKE_OBJECTIVE_CFLAGS_X86      = $$QMAKE_CFLAGS_X86
+ QMAKE_OBJECTIVE_CFLAGS_X86_64   = $$QMAKE_CFLAGS_X86_64
+ QMAKE_OBJECTIVE_CFLAGS_PPC      = $$QMAKE_CFLAGS_PPC
+ QMAKE_OBJECTIVE_CFLAGS_PPC_64   = $$QMAKE_CFLAGS_PPC_64
+ 
++QMAKE_OBJECTIVE_CXXFLAGS          = $$QMAKE_CXXFLAGS
++QMAKE_OBJECTIVE_CXXFLAGS_WARN_ON  = $$QMAKE_CXXFLAGS_WARN_ON
++QMAKE_OBJECTIVE_CXXFLAGS_WARN_OFF = $$QMAKE_CXXFLAGS_WARN_OFF
++QMAKE_OBJECTIVE_CXXFLAGS_DEBUG    = $$QMAKE_CXXFLAGS_DEBUG
++QMAKE_OBJECTIVE_CXXFLAGS_RELEASE  = $$QMAKE_CXXFLAGS_RELEASE
++QMAKE_OBJECTIVE_CXXFLAGS_HIDESYMS = $$QMAKE_CXXFLAGS_HIDESYMS
++QMAKE_OBJECTIVE_CXXFLAGS_X86      = $$QMAKE_CXXFLAGS_X86
++QMAKE_OBJECTIVE_CXXFLAGS_X86_64   = $$QMAKE_CXXFLAGS_X86_64
++
+ QMAKE_LFLAGS_X86    += $$QMAKE_CFLAGS_X86
+ QMAKE_LFLAGS_X86_64 += $$QMAKE_CFLAGS_X86_64
+ QMAKE_LFLAGS_PPC    += $$QMAKE_CFLAGS_PPC
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/gcc-base.conf qt-everywhere-opensource-src-4.8.7/mkspecs/common/gcc-base.conf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/gcc-base.conf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/common/gcc-base.conf	2019-04-04 16:00:32.000000000 -0400
+@@ -42,7 +42,7 @@
+ QMAKE_CFLAGS_YACC           += -Wno-unused -Wno-parentheses
+ QMAKE_CFLAGS_HIDESYMS       += -fvisibility=hidden
+ 
+-QMAKE_CXXFLAGS            += $$QMAKE_CFLAGS
++QMAKE_CXXFLAGS            += -std=gnu++98 $$QMAKE_CFLAGS
+ QMAKE_CXXFLAGS_DEPS       += $$QMAKE_CFLAGS_DEPS
+ QMAKE_CXXFLAGS_WARN_ON    += $$QMAKE_CFLAGS_WARN_ON
+ QMAKE_CXXFLAGS_WARN_OFF   += $$QMAKE_CFLAGS_WARN_OFF
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/mac.conf qt-everywhere-opensource-src-4.8.7/mkspecs/common/mac.conf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/common/mac.conf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/common/mac.conf	2019-04-04 15:50:20.000000000 -0400
+@@ -9,15 +9,14 @@
+ QMAKE_LIBDIR		=
+ QMAKE_INCDIR_QT		= $$[QT_INSTALL_HEADERS]
+ QMAKE_LIBDIR_QT		= $$[QT_INSTALL_LIBS]
+-QMAKE_INCDIR_OPENGL	= /System/Library/Frameworks/OpenGL.framework/Headers \
+-	/System/Library/Frameworks/AGL.framework/Headers/
++QMAKE_INCDIR_OPENGL	= @OPENGL_INCDIR@
+ 
+ QMAKE_FIX_RPATH         = install_name_tool -id 
+ 
+ QMAKE_LFLAGS_RPATH	=
+ 
+ QMAKE_LIBS_DYNLOAD	=
+-QMAKE_LIBS_OPENGL	= -framework OpenGL -framework AGL
++QMAKE_LIBS_OPENGL	= @OPENGL_LIBS@
+ QMAKE_LIBS_OPENGL_QT	= $$QMAKE_LIBS_OPENGL
+ QMAKE_LIBS_THREAD	=
+ 
+@@ -38,7 +37,6 @@
+ QMAKE_DEL_DIR		= rmdir
+ QMAKE_CHK_DIR_EXISTS	= test -d
+ QMAKE_MKDIR		= mkdir -p
+-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 # overridden to 10.5 for Cocoa on the compiler command line
+-
++QMAKE_MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
+ 
+ include(unix.conf)
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/debug.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/debug.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/debug.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/debug.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -3,6 +3,7 @@
+ QMAKE_CFLAGS += $$QMAKE_CFLAGS_DEBUG
+ QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_DEBUG
+ QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS_DEBUG
++QMAKE_OBJECTIVE_CXXFLAGS += $$QMAKE_OBJECTIVE_CXXFLAGS_DEBUG
+ QMAKE_LFLAGS += $$QMAKE_LFLAGS_DEBUG
+ QMAKE_LIBFLAGS += $$QMAKE_LIBFLAGS_DEBUG
+ !debug_and_release:fix_output_dirs:fixExclusiveOutputDirs(debug, release)
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/default_post.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/default_post.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/default_post.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/default_post.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -1,5 +1,5 @@
+ load(default_post)
+-!no_objective_c:CONFIG += objective_c
++!no_objective_c:CONFIG += split_sources objective_c objective_cxx
+ 
+ # Pick a suitable default architecture for qmake-based applications.
+ # If the Qt package contains one of x86 and x86_64, pick that one. If it
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/objective_c.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/objective_c.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/objective_c.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/objective_c.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -1,23 +1,18 @@
+-
+-for(source, SOURCES) {
+-    contains(source,.*\\.mm?$) {
+-        warning(Objective-C source \'$$source\' found in SOURCES but should be in OBJECTIVE_SOURCES)
+-        SOURCES -= $$source
+-        OBJECTIVE_SOURCES += $$source
+-    }
+-}
++# Add compiler directives for Objective C (.m) only
++#
++# OBJECTIVE_C_SOURCES has already been set in "split_sources"
+ 
+ isEmpty(QMAKE_OBJECTIVE_CC):QMAKE_OBJECTIVE_CC = $$QMAKE_CC
+ 
+ OBJECTIVE_C_OBJECTS_DIR = $$OBJECTS_DIR
+ isEmpty(OBJECTIVE_C_OBJECTS_DIR):OBJECTIVE_C_OBJECTS_DIR = .
+-isEmpty(QMAKE_EXT_OBJECTIVE_C):QMAKE_EXT_OBJECTIVE_C = .mm .m
++isEmpty(QMAKE_EXT_OBJECTIVE_C):QMAKE_EXT_OBJECTIVE_C = .m
+ 
+ objective_c.dependency_type = TYPE_C
+ objective_c.variables = QMAKE_OBJECTIVE_CFLAGS
+-objective_c.commands = $$QMAKE_OBJECTIVE_CC -c $(QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS) $(DEFINES) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
++objective_c.commands = $$QMAKE_OBJECTIVE_CC -c $(QMAKE_COMP_QMAKE_OBJECTIVE_CFLAGS) $(DEFINES) $(INCPATH) -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
+ objective_c.output = $$OBJECTIVE_C_OBJECTS_DIR/${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+-objective_c.input = OBJECTIVE_SOURCES
++objective_c.input = OBJECTIVE_C_SOURCES
+ objective_c.name = Compile ${QMAKE_FILE_IN}
+ silent:objective_c.commands = @echo objective-c ${QMAKE_FILE_IN} && $$objective_c.commands
+ QMAKE_EXTRA_COMPILERS += objective_c
+diff -N -r -u qt-orig/mkspecs/features/mac/objective_cxx.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/objective_cxx.prf
+--- qt-orig/mkspecs/features/mac/objective_cxx.prf	1969-12-31 19:00:00.000000000 -0500
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/objective_cxx.prf	2019-03-29 09:52:51.000000000 -0400
+@@ -0,0 +1,18 @@
++# Add compiler directives for Objective C (.mm) only
++#
++# OBJECTIVE_CXX_SOURCES has already been set in "split_sources"
++
++isEmpty(QMAKE_OBJECTIVE_CXX):QMAKE_OBJECTIVE_CXX = $$QMAKE_CC
++
++OBJECTIVE_CXX_OBJECTS_DIR = $$OBJECTS_DIR
++isEmpty(OBJECTIVE_CXX_OBJECTS_DIR):OBJECTIVE_CXX_OBJECTS_DIR = .
++isEmpty(QMAKE_EXT_OBJECTIVE_CXX):QMAKE_EXT_OBJECTIVE_CXX = .mm
++
++objective_cxx.dependency_type = TYPE_C
++objective_cxx.variables = QMAKE_OBJECTIVE_CXXFLAGS
++objective_cxx.commands = $$QMAKE_OBJECTIVE_CXX -c $(QMAKE_COMP_QMAKE_OBJECTIVE_CXXFLAGS) $(DEFINES) $(INCPATH) -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
++objective_cxx.output = $$OBJECTIVE_CXX_OBJECTS_DIR/${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
++objective_cxx.input = OBJECTIVE_CXX_SOURCES
++objective_cxx.name = Compile ${QMAKE_FILE_IN}
++silent:objective_cxx.commands = @echo objective-cxx ${QMAKE_FILE_IN} && $$objective_cxx.commands
++QMAKE_EXTRA_COMPILERS += objective_cxx
+diff -N -r -u qt-orig/mkspecs/features/mac/split_sources.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/split_sources.prf
+--- qt-orig/mkspecs/features/mac/split_sources.prf	1969-12-31 19:00:00.000000000 -0500
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/split_sources.prf	2019-03-29 09:52:51.000000000 -0400
+@@ -0,0 +1,52 @@
++# move Objective C and C++ files from SOURCES to OBJECTIVE_SOURCES
++
++for(source, SOURCES) {
++    contains(source,.*\\.m$) {
++        warning(Objective-C source \'$$source\' found in SOURCES but should be in OBJECTIVE_SOURCES)
++        SOURCES -= $$source
++        OBJECTIVE_SOURCES += $$source
++    } else {
++        contains(source,.*\\.mm$) {
++            warning(Objective-C++ source \'$$source\' found in SOURCES but should be in OBJECTIVE_SOURCES)
++            SOURCES -= $$source
++            OBJECTIVE_SOURCES += $$source
++ 	}
++    }
++}
++
++# move C and C++ files from OBJECTIVE_SOURCES to SOURCES
++
++for(source, OBJECTIVE_SOURCES) {
++    contains(source,.*\\.c$) {
++        warning(C source \'$$source\' found in SOURCES but should be in SOURCES)
++        OBJECTIVE_SOURCES -= $$source
++        SOURCES += $$source
++    } else {
++      	contains(source,.*\\.cc$) {
++            warning(C++ source \'$$source\' found in SOURCES but should be in SOURCES)
++            OBJECTIVE_SOURCES -= $$source
++            SOURCES += $$source
++        } else {
++    	    contains(source,.*\\.cpp$) {
++	        warning(C++ source \'$$source\' found in SOURCES but should be in SOURCES)
++		OBJECTIVE_SOURCES -= $$source
++		SOURCES += $$source
++            }
++        }
++    }
++}
++
++# split Objective C and C++ sources into their own variables
++
++for(source, OBJECTIVE_SOURCES) {
++    contains(source,.*\\.mm$) {
++        OBJECTIVE_CXX_SOURCES += $$source
++    } else {
++        contains(source,.*\\.m$) {
++            OBJECTIVE_C_SOURCES += $$source
++        } else {
++            warning(Source \'$$source\' was found in OBJECTIVE_SOURCES but its file extension is not a typical objective C (\'.m\') or C++ (\'.mm\') extension; assuming Objective C.)
++            OBJECTIVE_C_SOURCES += $$source
++	}
++    }
++}
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/sdk.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/sdk.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/sdk.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/sdk.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -2,6 +2,7 @@
+     !macx-xcode:!macx-pbuilder {
+         QMAKE_CFLAGS += -isysroot $$QMAKE_MAC_SDK
+         QMAKE_OBJECTIVE_CFLAGS += -isysroot $$QMAKE_MAC_SDK
++        QMAKE_OBJECTIVE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK
+         QMAKE_CXXFLAGS += -isysroot $$QMAKE_MAC_SDK
+         QMAKE_LFLAGS += -Wl,-syslibroot,$$QMAKE_MAC_SDK
+     }
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/x86.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/x86.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/x86.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/x86.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -2,6 +2,7 @@
+ } else {
+    QMAKE_CFLAGS += $$QMAKE_CFLAGS_X86
+    QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS_X86
++   QMAKE_OBJECTIVE_CXXFLAGS += $$QMAKE_OBJECTIVE_CXXFLAGS_X86
+    QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_X86
+    QMAKE_LFLAGS += $$QMAKE_LFLAGS_X86
+ }
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/x86_64.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/x86_64.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/mac/x86_64.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/mac/x86_64.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -2,6 +2,7 @@
+ } else {
+    QMAKE_CFLAGS += $$QMAKE_CFLAGS_X86_64
+    QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS_X86_64
++   QMAKE_OBJECTIVE_CXXFLAGS += $$QMAKE_OBJECTIVE_CXXFLAGS_X86_64
+    QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_X86_64
+    QMAKE_LFLAGS += $$QMAKE_LFLAGS_X86_64
+ }
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/release.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/release.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/release.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/release.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -2,6 +2,7 @@
+ QMAKE_CFLAGS += $$QMAKE_CFLAGS_RELEASE
+ QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_RELEASE
+ QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS_RELEASE
++QMAKE_OBJECTIVE_CXXFLAGS += $$QMAKE_OBJECTIVE_CXXFLAGS_RELEASE
+ QMAKE_LFLAGS += $$QMAKE_LFLAGS_RELEASE
+ QMAKE_LIBFLAGS += $$QMAKE_LIBFLAGS_RELEASE
+-!debug_and_release:fix_output_dirs:fixExclusiveOutputDirs(release, debug)
+\ No newline at end of file
++!debug_and_release:fix_output_dirs:fixExclusiveOutputDirs(release, debug)
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/unix/hide_symbols.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/unix/hide_symbols.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/unix/hide_symbols.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/unix/hide_symbols.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -1,4 +1,5 @@
+ QMAKE_CFLAGS += $$QMAKE_CFLAGS_HIDESYMS
+ QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_HIDESYMS
+ QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS_HIDESYMS
++QMAKE_OBJECTIVE_CXXFLAGS += $$QMAKE_OBJECTIVE_CXXFLAGS_HIDESYMS
+ QMAKE_LFLAGS += $$QMAKE_LFLAGS_HIDESYMS
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/warn_off.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/warn_off.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/warn_off.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/warn_off.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -1,4 +1,5 @@
+ CONFIG -= warn_on
+ QMAKE_CFLAGS += $$QMAKE_CFLAGS_WARN_OFF
+ QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_WARN_OFF
+-QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS_WARN_OFF
+\ No newline at end of file
++QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS_WARN_OFF
++QMAKE_OBJECTIVE_CXXFLAGS += $$QMAKE_OBJECTIVE_CXXFLAGS_WARN_OFF
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/warn_on.prf qt-everywhere-opensource-src-4.8.7/mkspecs/features/warn_on.prf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/features/warn_on.prf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/features/warn_on.prf	2019-04-04 15:47:55.000000000 -0400
+@@ -2,4 +2,4 @@
+ QMAKE_CFLAGS += $$QMAKE_CFLAGS_WARN_ON
+ QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_WARN_ON
+ QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS_WARN_ON
+-
++QMAKE_OBJECTIVE_CXXFLAGS += $$QMAKE_OBJECTIVE_CXXFLAGS_WARN_ON
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/unsupported/macx-clang/qmake.conf qt-everywhere-opensource-src-4.8.7/mkspecs/unsupported/macx-clang/qmake.conf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/unsupported/macx-clang/qmake.conf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/unsupported/macx-clang/qmake.conf	2019-04-04 16:10:40.000000000 -0400
+@@ -13,6 +13,13 @@
+ include(../../common/gcc-base-macx.conf)
+ include(../../common/clang.conf)
+ 
++QMAKE_MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
++
++QMAKE_CFLAGS += -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
++QMAKE_CXXFLAGS += -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
++QMAKE_OBJECTIVE_CXXFLAGS += -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
++QMAKE_LFLAGS += -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
++
+ QMAKE_OBJCFLAGS_PRECOMPILE       = -x objective-c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
+ QMAKE_OBJCFLAGS_USE_PRECOMPILE   = $$QMAKE_CFLAGS_USE_PRECOMPILE
+ QMAKE_OBJCXXFLAGS_PRECOMPILE     = -x objective-c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/mkspecs/unsupported/macx-clang-libc++/qmake.conf qt-everywhere-opensource-src-4.8.7/mkspecs/unsupported/macx-clang-libc++/qmake.conf
+--- qt-everywhere-opensource-src-4.8.7.orig/mkspecs/unsupported/macx-clang-libc++/qmake.conf	2015-05-07 10:14:42.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/mkspecs/unsupported/macx-clang-libc++/qmake.conf	2019-04-04 16:10:36.000000000 -0400
+@@ -13,10 +13,11 @@
+ include(../../common/gcc-base-macx.conf)
+ include(../../common/clang.conf)
+ 
+-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 # Libc++ is available from 10.7 onwards
++QMAKE_MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
+ 
+ QMAKE_CFLAGS += -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
+ QMAKE_CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
++QMAKE_OBJECTIVE_CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
+ QMAKE_LFLAGS += -stdlib=libc++ -mmacosx-version-min=$$QMAKE_MACOSX_DEPLOYMENT_TARGET
+ 
+ QMAKE_OBJCFLAGS_PRECOMPILE       = -x objective-c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/qmake/qmake.pri qt-everywhere-opensource-src-4.8.7/qmake/qmake.pri
+--- qt-everywhere-opensource-src-4.8.7.orig/qmake/qmake.pri	2019-04-04 15:46:06.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/qmake/qmake.pri	2019-04-04 15:47:55.000000000 -0400
+@@ -135,7 +135,7 @@
+         SOURCES += qfilesystemengine_unix.cpp qfilesystemiterator_unix.cpp qfsfileengine_unix.cpp
+         mac {
+           SOURCES += qcore_mac.cpp qsettings_mac.cpp
+-          QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported)
++          QMAKE_MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
+           LIBS += -framework ApplicationServices
+         }
+     } else:win32 {
+diff -r -u qt-everywhere-opensource-src-4.8.7.orig/src/tools/bootstrap/bootstrap.pro qt-everywhere-opensource-src-4.8.7/src/tools/bootstrap/bootstrap.pro
+--- qt-everywhere-opensource-src-4.8.7.orig/src/tools/bootstrap/bootstrap.pro	2019-04-04 16:54:09.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.7/src/tools/bootstrap/bootstrap.pro	2019-04-04 16:54:16.000000000 -0400
+@@ -103,7 +103,7 @@
+ else:win32:SOURCES += ../../corelib/tools/qlocale_win.cpp
+ 
+ macx: {
+-   QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported)
++   QMAKE_MACOSX_DEPLOYMENT_TARGET = @QMAKE_MACOSX_DEPLOYMENT_TARGET@
+    SOURCES += ../../corelib/kernel/qcore_mac.cpp
+    LIBS += -framework CoreServices -framework ApplicationServices
+ }
+diff -r -u a/tools/macdeployqt/shared/shared.cpp b/tools/macdeployqt/shared/shared.cpp
+--- a/tools/macdeployqt/shared/shared.cpp	2015-05-07 10:14:40.000000000 -0400
++++ b/tools/macdeployqt/shared/shared.cpp	2019-03-20 09:30:21.000000000 -0400
+@@ -141,7 +141,7 @@
+                 state = DylibName;
+                 continue;
+             } else if (part < parts.count() && parts.at(part).endsWith(".framework")) {
+-                info.installName += "/" + (qtPath + "lib/").simplified();
++                info.installName += "/" + (qtPath + "Frameworks/").simplified();
+                 info.frameworkDirectory = info.installName;
+                 state = FrameworkName;
+                 continue;
+diff -r -u a/tools/qtconfig/main.cpp b/tools/qtconfig/main.cpp
+--- a/tools/qtconfig/main.cpp	2015-05-07 10:14:41.000000000 -0400
++++ b/tools/qtconfig/main.cpp	2019-03-20 09:30:22.000000000 -0400
+@@ -51,6 +51,13 @@
+ {
+     Q_INIT_RESOURCE(qtconfig);
+ 
++    const QByteArray graphicsSystem = qgetenv("QT_GRAPHICSSYSTEM");
++    if (graphicsSystem.isNull() || graphicsSystem.isEmpty()) {
++        // force native graphics mode unless the user set one via QT_GRAPHICSSYSTEM.
++        // We have to use QT_GRAPHICSSYSTEM because that will override any previous
++        // settings stored in our own settings store.
++        qputenv("QT_GRAPHICSSYSTEM", "Native");
++    }
+     QApplication app(argc, argv);
+ 
+     QTranslator translator;
+diff -r -u a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp
+--- a/tools/qtconfig/mainwindow.cpp	2015-05-07 10:14:41.000000000 -0400
++++ b/tools/qtconfig/mainwindow.cpp	2019-03-20 09:30:22.000000000 -0400
+@@ -227,6 +227,7 @@
+     connect(ui->rtlExtensionsCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified()));
+     connect(ui->inputStyleCombo, SIGNAL(activated(int)), SLOT(somethingModified()));
+     connect(ui->inputMethodCombo, SIGNAL(activated(int)), SLOT(somethingModified()));
++    connect(ui->graphicsSystemCombo, SIGNAL(activated(int)), SLOT(somethingModified()));
+     connect(ui->guiStyleCombo, SIGNAL(activated(QString)), SLOT(styleSelected(QString)));
+     connect(ui->familySubstitutionCombo, SIGNAL(activated(QString)), SLOT(substituteSelected(QString)));
+     connect(ui->tunePaletteButton, SIGNAL(clicked()), SLOT(tunePalette()));
+@@ -416,7 +417,26 @@
+     ui->inputMethodCombo->hide();
+     ui->inputMethodLabel->hide();
+ #endif
+-
++#ifdef Q_OS_MAC
++    ui->graphicsSystemCombo->setToolTip(tr("Select the graphicsssystem to be used by default.\n"
++        "Native: use native CoreGraphics rendering\n"
++        "Raster: use raster graphics\n"
++        "OpenGL: use OpenGL (experimental!)\n"
++        "Raster mode is the preferred default except on Mac OS 10.14 and newer where it causes flickering.\n"
++        "Use Native rendering on those newer OS versions (or if you experience other graphics glitches).\n"
++        "Note that Raster mode is not compatible with certain built-in widget styles like CDE or Plastique."));
++    QStringList graphicsSystems;
++    QString defaultGraphicsSystem = settings.value(QLatin1String("DefaultGraphicsSystem"), QLatin1String("(unset)")).toString();
++
++    graphicsSystems << "(unset)" << "Native" << "Raster" << "OpenGL";
++    ui->graphicsSystemCombo->addItems(graphicsSystems);
++    if (!defaultGraphicsSystem.isNull() && !defaultGraphicsSystem.isEmpty()) {
++        ui->graphicsSystemCombo->setCurrentIndex(graphicsSystems.indexOf(QRegExp(defaultGraphicsSystem, Qt::CaseInsensitive)));
++    }
++#else
++    ui->graphicsSystemLabel->hide();
++    ui->graphicsSystemCombo->hide();
++#endif
+     ui->fontEmbeddingCheckBox->setChecked(settings.value(QLatin1String("embedFonts"), true)
+                                           .toBool());
+     fontpaths = settings.value(QLatin1String("fontPath")).toStringList();
+@@ -573,6 +593,13 @@
+ #if defined(Q_WS_X11) && !defined(QT_NO_XIM)
+         settings.setValue(QLatin1String("DefaultInputMethod"), ui->inputMethodCombo->currentText());
+ #endif
++#ifdef Q_OS_MAC
++        if (ui->graphicsSystemCombo->currentIndex() > 0) {
++            settings.setValue(QLatin1String("DefaultGraphicsSystem"), ui->graphicsSystemCombo->currentText());
++        } else {
++            settings.remove(QLatin1String("DefaultGraphicsSystem"));
++        }
++#endif
+ 
+         QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString();
+         QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString();
diff --git a/spack/packages/qt/qt4-pcre.patch b/spack/packages/qt/qt4-pcre.patch
new file mode 100644
index 000000000..854e564bf
--- /dev/null
+++ b/spack/packages/qt/qt4-pcre.patch
@@ -0,0 +1,16 @@
+diff -U5 -Nru qt-everywhere-opensource-src-4.8.6/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.h qt-everywhere-opensource-src-4.8.6.pcre/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.h
+--- qt-everywhere-opensource-src-4.8.6/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.h	2014-04-10 14:37:12.000000000 -0400
++++ qt-everywhere-opensource-src-4.8.6.pcre/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.h	2016-08-29 15:30:02.216546252 -0400
+@@ -32,11 +32,11 @@
+ 
+ #include "MacroAssembler.h"
+ #include "RegexPattern.h"
+ #include <UString.h>
+ 
+-#include <pcre.h>
++#include <pcre/pcre.h>
+ struct JSRegExp; // temporary, remove when fallback is removed.
+ 
+ #if CPU(X86) && !COMPILER(MSVC)
+ #define YARR_CALL __attribute__ ((regparm (3)))
+ #else
diff --git a/spack/packages/qt/qt4-qforeach.patch b/spack/packages/qt/qt4-qforeach.patch
new file mode 100644
index 000000000..ae54cdbc1
--- /dev/null
+++ b/spack/packages/qt/qt4-qforeach.patch
@@ -0,0 +1,64 @@
+From c35a3f519007af44c3b364b9af86f6a336f6411b Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Tue, 11 Feb 2014 16:17:46 -0800
+Subject: [PATCH] Redo the Q_FOREACH loop control without GCC statement
+ expressions
+
+It's possible to do without them, which probably makes the number of
+supported compilers a lot bigger: they just need to support decltype()
+or __typeof__.
+
+That includes the Intel compiler. The old code was also apparently
+working, but no one had realized the old workaround for some old version
+was still in place.
+
+The loop overhead is more or less the same. I have not done benchmarks,
+but inspection of the generated assembly shows more or less the same
+number of instructions.
+
+Change-Id: I32d499c84a6ddd19d994b49f17a469acb5c3a3f1
+Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
+Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
+
+Backported to Qt 4
+
+--- a/src/corelib/global/qglobal.h
++++ b/src/corelib/global/qglobal.h
+@@ -2482,22 +2482,32 @@ typedef uint Flags;
+ 
+ #endif /* Q_NO_TYPESAFE_FLAGS */
+ 
+-#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
++#if (defined(Q_CC_GNU) && !defined(Q_CC_RVCT))
+ /* make use of typeof-extension */
+ template <typename T>
+ class QForeachContainer {
+ public:
+-    inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
++    inline QForeachContainer(const T& t) : c(t), i(c.begin()), e(c.end()), control(1) { }
+     const T c;
+     int brk;
+     typename T::const_iterator i, e;
++    int control;
+ };
+ 
++// Explanation of the control word:
++//  - it's initialized to 1
++//  - that means both the inner and outer loops start
++//  - if there were no breaks, at the end of the inner loop, it's set to 0, which
++//    causes it to exit (the inner loop is run exactly once)
++//  - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing
++//    the outer loop to continue executing
++//  - if there was a break inside the inner loop, it will exit with control still
++//    set to 1; in that case, the outer loop will invert it to 0 and will exit too
+ #define Q_FOREACH(variable, container)                                \
+ for (QForeachContainer<__typeof__(container)> _container_(container); \
+-     !_container_.brk && _container_.i != _container_.e;              \
+-     __extension__  ({ ++_container_.brk; ++_container_.i; }))                       \
+-    for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
++     _container_.control && _container_.i != _container_.e;         \
++     ++_container_.i, _container_.control ^= 1)                     \
++    for (variable = *_container_.i; _container_.control; _container_.control = 0)
+ 
+ #else
+ 
diff --git a/spack/packages/qt/qt4-tools.patch b/spack/packages/qt/qt4-tools.patch
new file mode 100644
index 000000000..39ccff297
--- /dev/null
+++ b/spack/packages/qt/qt4-tools.patch
@@ -0,0 +1,12 @@
+diff -r -u a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp
+--- a/tools/linguist/linguist/messagemodel.cpp	2015-05-07 10:14:39.000000000 -0400
++++ b/tools/linguist/linguist/messagemodel.cpp	2019-03-20 09:30:21.000000000 -0400
+@@ -183,7 +183,7 @@
+         if (ContextItem *c = one->findContext(oc->context())) {
+             for (int j = 0; j < oc->messageCount(); ++j) {
+                 MessageItem *m = oc->messageItem(j);
+-                if (c->findMessage(m->text(), m->comment()) >= 0)
++                if (c->findMessage(m->text(), m->comment()))
+                     ++inBoth;
+             }
+         }
diff --git a/spack/packages/qt/qt5-11-intel-overflow.patch b/spack/packages/qt/qt5-11-intel-overflow.patch
new file mode 100644
index 000000000..5bb0b1e03
--- /dev/null
+++ b/spack/packages/qt/qt5-11-intel-overflow.patch
@@ -0,0 +1,11 @@
+--- a/qtbase/src/corelib/global/qnumeric_p.h	2018-11-25 06:51:11.000000000 -0600
++++ b/qtbase/src/corelib/global/qnumeric_p.h	2020-01-07 14:13:12.103818264 -0600
+@@ -168,7 +168,7 @@
+ // size_t. Implementations for 8- and 16-bit types will work but may not be as
+ // efficient. Implementations for 64-bit may be missing on 32-bit platforms.
+ 
+-#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || QT_HAS_BUILTIN(__builtin_add_overflowx)
++#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) && !defined(Q_CC_INTEL) || (defined(Q_CC_INTEL) && (Q_CC_INTEL >= 1800) && (Q_CC_GNU >= 500) && !defined(Q_OS_WIN))) || QT_HAS_BUILTIN(__builtin_add_overflowx)
+ // GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows
+ 
+ template <typename T> inline
diff --git a/spack/packages/qt/qt5-12-configure.patch b/spack/packages/qt/qt5-12-configure.patch
new file mode 100644
index 000000000..42681a162
--- /dev/null
+++ b/spack/packages/qt/qt5-12-configure.patch
@@ -0,0 +1,13 @@
+diff --git a/qtbase/src/corelib/tools/qsimd_p.h b/qtbase/src/corelib/tools/qsimd_p.h
+index 2130a1f..3a14715 100644
+--- a/qtbase/src/corelib/tools/qsimd_p.h
++++ b/qtbase/src/corelib/tools/qsimd_p.h
+@@ -346,7 +346,7 @@ extern Q_CORE_EXPORT QBasicAtomicInteger<unsigned> qt_cpu_features[2];
+ #endif
+ Q_CORE_EXPORT void qDetectCpuFeatures();
+ 
+-#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND)
++#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND) && !defined(QT_BOOTSTRAPPED)
+ Q_CORE_EXPORT qsizetype qRandomCpu(void *, qsizetype) Q_DECL_NOTHROW;
+ #else
+ static inline qsizetype qRandomCpu(void *, qsizetype) Q_DECL_NOTHROW
diff --git a/spack/packages/qt/qt5-12-intel-overflow.patch b/spack/packages/qt/qt5-12-intel-overflow.patch
new file mode 100644
index 000000000..bfe5c8e4f
--- /dev/null
+++ b/spack/packages/qt/qt5-12-intel-overflow.patch
@@ -0,0 +1,11 @@
+--- a/qtbase/src/corelib/global/qnumeric_p.h	2019-08-31 03:29:31.000000000 -0500
++++ b/qtbase/src/corelib/global/qnumeric_p.h	2020-01-06 14:23:40.719851927 -0600
+@@ -231,7 +231,7 @@
+ // size_t. Implementations for 8- and 16-bit types will work but may not be as
+ // efficient. Implementations for 64-bit may be missing on 32-bit platforms.
+ 
+-#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) || (defined(Q_CC_INTEL) && !defined(Q_OS_WIN))) || QT_HAS_BUILTIN(__builtin_add_overflow)
++#if (defined(Q_CC_GNU) && (Q_CC_GNU >= 500) && !defined(Q_CC_INTEL) || (defined(Q_CC_INTEL) && (Q_CC_INTEL >= 1800) && (Q_CC_GNU >= 500) && !defined(Q_OS_WIN))) || QT_HAS_BUILTIN(__builtin_add_overflow)
+ // GCC 5, ICC 18, and Clang 3.8 have builtins to detect overflows
+ 
+ template <typename T> inline
diff --git a/spack/packages/qt/qt5-8-framework.patch b/spack/packages/qt/qt5-8-framework.patch
new file mode 100644
index 000000000..b1ba47fa0
--- /dev/null
+++ b/spack/packages/qt/qt5-8-framework.patch
@@ -0,0 +1,17 @@
+diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf
+index f6cbf99..ec31e45 100644
+--- a/qtbase/mkspecs/features/qt_module.prf
++++ b/qtbase/mkspecs/features/qt_module.prf
+@@ -68,9 +68,9 @@ load(qt_build_paths)
+ 
+ header_module {
+     TEMPLATE     = aux
+-    CONFIG      += \
+-        force_qt \  # Needed for the headers_clean tests.
+-        qt_no_install_library
++    CONFIG      += force_qt  # Needed for the headers_clean tests.
++    !lib_bundle: \
++        CONFIG  += qt_no_install_library
+ } else {
+     TEMPLATE     = lib
+ }
diff --git a/spack/packages/qt/qt5-8-freetype.patch b/spack/packages/qt/qt5-8-freetype.patch
new file mode 100644
index 000000000..c8d71105a
--- /dev/null
+++ b/spack/packages/qt/qt5-8-freetype.patch
@@ -0,0 +1,12 @@
+diff --git a/qtbase/src/3rdparty/freetype/freetype.pro b/qtbase/src/3rdparty/freetype/freetype.pro
+index 5b1eb92..390a6da 100644
+--- a/qtbase/src/3rdparty/freetype/freetype.pro
++++ b/qtbase/src/3rdparty/freetype/freetype.pro
+@@ -69,6 +69,7 @@ DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB
+ include(../zlib_dependency.pri)
+
+ DEFINES += FT_CONFIG_OPTION_USE_PNG
++include($$OUT_PWD/../../gui/qtgui-config.pri)
+ QMAKE_USE_PRIVATE += libpng
+
+ DEFINES += TT_CONFIG_OPTION_SUBPIXEL_HINTING
diff --git a/spack/packages/qt/qt5-asm-volatile.patch b/spack/packages/qt/qt5-asm-volatile.patch
new file mode 100644
index 000000000..c49fe3f34
--- /dev/null
+++ b/spack/packages/qt/qt5-asm-volatile.patch
@@ -0,0 +1,235 @@
+From 97ec1d1882a83c23c91f0f7daea48e05858d8c32 Mon Sep 17 00:00:00 2001
+From: Thiago Macieira <thiago.macieira@intel.com>
+Date: Mon, 28 Jan 2019 14:33:12 -0800
+Subject: [PATCH] Fix build with GCC 8.3
+
+Qualifiers in the asm statement are not allowed in the global scope. I
+thought they were necessary for LTO, but I the commit to this file that
+added them predates my work on setting up LTO for GCC.
+
+Change-Id: Id98140e1c2f0426cabbefffd157e23e5ece67a49
+Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
+---
+ .../JavaScriptCore/jit/JITStubs.cpp           | 48 +++++++++----------
+ 1 file changed, 24 insertions(+), 24 deletions(-)
+
+diff --git a/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp b/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
+index 1abdf8b..9f60761 100644
+--- a/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
++++ b/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp
+@@ -116,7 +116,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x3c, JITStackFrame_s
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline);
+ 
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+@@ -138,7 +138,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -154,7 +154,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+     
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+@@ -179,7 +179,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_s
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x90, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_offset_matches_ctiTrampoline);
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+@@ -206,7 +206,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -222,7 +222,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+@@ -242,7 +242,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ #error "JIT_STUB_ARGUMENT_VA_LIST not supported on ARMv7."
+ #endif
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+@@ -269,7 +269,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "bx lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+@@ -287,7 +287,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "bx lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+@@ -305,7 +305,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ 
+ #elif COMPILER(GCC) && CPU(ARM_TRADITIONAL)
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+@@ -323,7 +323,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "mov pc, lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -418,7 +418,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
+ 
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+@@ -440,7 +440,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -456,7 +456,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+     
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+@@ -480,7 +480,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x48, JITStackFrame_code_offset_matches_ctiTrampoline);
+ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x78, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
+ 
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+@@ -515,7 +515,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -531,7 +531,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "ret" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+ HIDE_SYMBOL(ctiOpThrowNotCaught) "\n"
+ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+@@ -551,7 +551,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ #error "JIT_STUB_ARGUMENT_VA_LIST not supported on ARMv7."
+ #endif
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+@@ -578,7 +578,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "bx lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+@@ -596,7 +596,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+     "bx lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".text" "\n"
+ ".align 2" "\n"
+ ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
+@@ -614,7 +614,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
+ 
+ #elif COMPILER(GCC) && CPU(ARM_TRADITIONAL)
+ 
+-asm volatile (
++asm (
+ ".text\n"
+ ".globl " SYMBOL_STRING(ctiTrampoline) "\n"
+ HIDE_SYMBOL(ctiTrampoline) "\n"
+@@ -632,7 +632,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n"
+     "mov pc, lr" "\n"
+ );
+ 
+-asm volatile (
++asm (
+ ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
+ HIDE_SYMBOL(ctiVMThrowTrampoline) "\n"
+ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
+@@ -1024,7 +1024,7 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD
+     extern "C" { \
+         rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \
+     }; \
+-    asm volatile ( \
++    asm ( \
+         ".text" "\n" \
+         ".align 2" "\n" \
+         ".globl " SYMBOL_STRING(cti_##op) "\n" \
+@@ -1053,7 +1053,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, thunkReturnAddress) == THUNK_RETUR
+     extern "C" { \
+         rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \
+     }; \
+-    asm volatile ( \
++    asm ( \
+         ".globl " SYMBOL_STRING(cti_##op) "\n" \
+         HIDE_SYMBOL(cti_##op) "\n"             \
+         SYMBOL_STRING(cti_##op) ":" "\n" \
diff --git a/spack/packages/qt/qt5-btn_trigger_happy.patch b/spack/packages/qt/qt5-btn_trigger_happy.patch
new file mode 100644
index 000000000..e6a27d5fa
--- /dev/null
+++ b/spack/packages/qt/qt5-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/spack/packages/qt/qt5-pcre.patch b/spack/packages/qt/qt5-pcre.patch
new file mode 100644
index 000000000..8fdf25661
--- /dev/null
+++ b/spack/packages/qt/qt5-pcre.patch
@@ -0,0 +1,33 @@
+--- a/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExp.cpp	2016-09-17 20:55:14.000000000 +0000
++++ b/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExp.cpp	2017-05-17 01:55:10.000000000 +0000
+@@ -44,7 +44,7 @@
+ #include "JIT.h"
+ #include "WRECGenerator.h"
+ #endif
+-#include <pcre/pcre.h>
++#include "../pcre/pcre.h"
+ 
+ #endif
+ 
+--- a/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.cpp	2016-09-17 20:55:14.000000000 +0000
++++ b/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.cpp	2017-05-17 01:55:51.000000000 +0000
+@@ -32,7 +32,7 @@
+ #include "MacroAssembler.h"
+ #include "RegexCompiler.h"
+ 
+-#include "pcre.h" // temporary, remove when fallback is removed.
++#include "../pcre/pcre.h" // temporary, remove when fallback is removed.
+ 
+ #if ENABLE(YARR_JIT)
+ 
+--- a/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.h	2016-09-17 20:55:14.000000000 +0000
++++ b/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.h	2017-05-17 01:55:36.000000000 +0000
+@@ -34,7 +34,7 @@
+ #include "RegexPattern.h"
+ #include <UString.h>
+ 
+-#include <pcre.h>
++#include "../pcre/pcre.h"
+ struct JSRegExp; // temporary, remove when fallback is removed.
+ 
+ #if CPU(X86) && !COMPILER(MSVC)
diff --git a/spack/packages/qt/qt5-restore-pc-files.patch b/spack/packages/qt/qt5-restore-pc-files.patch
new file mode 100644
index 000000000..35fbaddd4
--- /dev/null
+++ b/spack/packages/qt/qt5-restore-pc-files.patch
@@ -0,0 +1,15 @@
+Partially reverts <https://codereview.qt-project.org/#/c/140954/>.
+
+diff --git i/qtbase/mkspecs/features/qt_module.prf w/qtbase/mkspecs/features/qt_module.prf
+index bb28af97..36bb6483 100644
+--- i/qtbase/mkspecs/features/qt_module.prf
++++ w/qtbase/mkspecs/features/qt_module.prf
+@@ -245,7 +245,7 @@ load(qt_installs)
+ load(qt_targets)
+
+ # this builds on top of qt_common
+-!internal_module:!lib_bundle:if(unix|mingw) {
++!internal_module:if(unix|mingw) {
+     CONFIG += create_pc
+     QMAKE_PKGCONFIG_DESTDIR = pkgconfig
+     host_build: \
diff --git a/spack/packages/root/find-mysql.patch b/spack/packages/root/find-mysql.patch
new file mode 100644
index 000000000..230da73d7
--- /dev/null
+++ b/spack/packages/root/find-mysql.patch
@@ -0,0 +1,60 @@
+diff --git a/cmake/modules/FindMySQL.cmake b/cmake/modules/FindMySQL.cmake
+index c818f5a..755da92 100644
+--- a/cmake/modules/FindMySQL.cmake
++++ b/cmake/modules/FindMySQL.cmake
+@@ -10,11 +10,18 @@ if(MYSQL_INCLUDE_DIR OR MYSQL_)
+ endif()
+ 
+ if(NOT WIN32)
+-  find_program(MYSQL_CONFIG_EXECUTABLE mysql_config
+-    /usr/bin/
+-    /usr/local/bin
+-    ${MYSQL_DIR}/bin $ENV{MYSQL_DIR}/bin
+-  )
++  # Split into two find_program invocations to avoid user-specified
++  # mariadb_config being overridden by system mysql_config.
++  find_program(MYSQL_CONFIG_EXECUTABLE NAMES mysql_config mariadb_config
++    PATH_SUFFIXES bin
++    NO_DEFAULT_PATH
++    HINTS ${MYSQL_DIR} $ENV{MYSQL_DIR}
++    )
++  # Will not overwrite if MYSQL_CONFIG_EXECUTABLE is already set.
++  find_program(MYSQL_CONFIG_EXECUTABLE NAMES mysql_config mariadb_config
++    PATH_SUFFIXES bin
++    PATHS /usr/local /usr
++    )
+ endif()
+ 
+ if(MYSQL_CONFIG_EXECUTABLE)
+@@ -26,17 +33,22 @@ if(MYSQL_CONFIG_EXECUTABLE)
+   execute_process(COMMAND ${MYSQL_CONFIG_EXECUTABLE} --libs OUTPUT_VARIABLE MYSQL_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)
+ else()
+   find_path(MYSQL_INCLUDE_DIR mysql.h
+-    /usr/local/mysql/include
+-    /usr/local/include/mysql
+-    /usr/local/include
+-    /usr/include/mysql
+-    /usr/include
+-    /usr/mysql/include
+-    $ENV{MYSQL_DIR}/include
+-  )
++    PATH_SUFFIXES include/mysql include/mariadb
++    HINTS ${MYSQL_DIR} $ENV{MYSQL_DIR}
++    NO_DEFAULT_PATH
++    )
++  if (NOT MYSQL_INCLUDE_DIR)
++    find_path(MYSQL_INCLUDE_DIR mysql.h
++      PATH_SUFFIXES include/mysql include/mariadb
++      PATHS /usr/local/mysql /usr/local /usr
++      )
++  endif()
+   set(MYSQL_NAMES mysqlclient mysqlclient_r)
+   find_library(MYSQL_LIBRARY NAMES ${MYSQL_NAMES}
+-    PATHS /usr/local/mysql/lib /usr/local/lib /usr/lib $ENV{MYSQL_DIR}/lib $ENV{MYSQL_DIR}/lib/opt
++    PATH_SUFFIXES lib lib/mariadb lib/mysql
++    lib/opt lib/opt/mariadb lib/opt/mysql
++    HINTS ${MYSQL_DIR} $ENV{MYSQL_DIR}
++    PATHS /usr/local/mysql /usr/local /usr
+   )
+   set(MYSQL_LIBRARIES ${MYSQL_LIBRARY})
+ endif()
diff --git a/spack/packages/root/format-stringbuf-size.patch b/spack/packages/root/format-stringbuf-size.patch
new file mode 100644
index 000000000..5cb507ab2
--- /dev/null
+++ b/spack/packages/root/format-stringbuf-size.patch
@@ -0,0 +1,14 @@
+diff -Naur core/base/src/TString.cxx core/base/src/TString.cxx
+--- core/base/src/TString.cxx	2016-02-03 03:15:51.000000000 -0600
++++ core/base/src/TString.cxx	2016-02-22 16:51:35.283316959 -0600
+@@ -2397,8 +2397,8 @@
+ 
+ static char *Format(const char *format, va_list ap)
+ {
+-   static const int cb_size  = 4096;
+-   static const int fld_size = 2048;
++   static const int cb_size  = 3*4096;
++   static const int fld_size = 3*2048;
+ 
+    // a circular formating buffer
+    TTHREAD_TLS_ARRAY(char,cb_size,gFormbuf); // gFormbuf[cb_size]; // some slob for form overflow
diff --git a/spack/packages/root/honor-unuran-switch.patch b/spack/packages/root/honor-unuran-switch.patch
new file mode 100644
index 000000000..1ea73d80b
--- /dev/null
+++ b/spack/packages/root/honor-unuran-switch.patch
@@ -0,0 +1,26 @@
+From 20be628aeb0e2548693966b560fdde3e8d19c2d0 Mon Sep 17 00:00:00 2001
+From: Guilherme Amadio <amadio@cern.ch>
+Date: Tue, 8 May 2018 15:12:55 +0200
+Subject: [PATCH] Do not search for unuran or enable builtin_unuran if
+ unuran=OFF
+
+---
+ cmake/modules/SearchInstalledSoftware.cmake | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake
+index f69158e..b47ba34 100644
+--- a/cmake/modules/SearchInstalledSoftware.cmake
++++ b/cmake/modules/SearchInstalledSoftware.cmake
+@@ -60,7 +60,7 @@ if(builtin_zlib)
+ endif()
+ 
+ #---Check for Unuran ------------------------------------------------------------------
+-if(NOT builtin_unuran)
++if(unuran AND NOT builtin_unuran)
+   message(STATUS "Looking for Unuran")
+   find_Package(Unuran)
+   if(NOT UNURAN_FOUND)
+-- 
+1.8.3.1
+
diff --git a/spack/packages/root/math_uint.patch b/spack/packages/root/math_uint.patch
new file mode 100644
index 000000000..ff4a38b91
--- /dev/null
+++ b/spack/packages/root/math_uint.patch
@@ -0,0 +1,115 @@
+From 5f3faffdd869bce5e254ae70f69290e4651a061d Mon Sep 17 00:00:00 2001
+From: Lorenzo Moneta <Lorenzo.Moneta@cern.ch>
+Date: Mon, 4 Jan 2016 15:38:23 +0100
+Subject: [PATCH] Fix ROOT-7886. Use unsigned int instead of uint
+
+---
+ math/mathcore/inc/Math/Delaunay2D.h |  2 +-
+ math/mathcore/src/Delaunay2D.cxx    | 30 +++++++++++++++---------------
+ 2 files changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/math/mathcore/inc/Math/Delaunay2D.h b/math/mathcore/inc/Math/Delaunay2D.h
+index 6255e78..472bded 100644
+--- a/math/mathcore/inc/Math/Delaunay2D.h
++++ b/math/mathcore/inc/Math/Delaunay2D.h
+@@ -273,7 +273,7 @@ class Delaunay2D  {
+    double fYCellStep; //! inverse denominator to calculate X cell = fNCells / (fYNmax - fYNmin)
+    std::set<UInt_t> fCells[(fNCells+1)*(fNCells+1)]; //! grid cells with containing triangles
+ 
+-   inline unsigned int Cell(uint x, uint y) const {
++   inline unsigned int Cell(UInt_t x, UInt_t y) const {
+ 	   return x*(fNCells+1) + y;
+    }
+ 
+diff --git a/math/mathcore/src/Delaunay2D.cxx b/math/mathcore/src/Delaunay2D.cxx
+index c4d4680..9a82858 100644
+--- a/math/mathcore/src/Delaunay2D.cxx
++++ b/math/mathcore/src/Delaunay2D.cxx
+@@ -190,7 +190,7 @@ void Delaunay2D::DoFindTriangles() {
+ 
+ 				Triangle tri;
+ 
+-				auto transform = [&] (const uint i) {
++				auto transform = [&] (const unsigned int i) {
+ 					tri.x[i] = face.vertex(i)->point().x();
+ 					tri.y[i] = face.vertex(i)->point().y();
+ 					tri.idx[i] = face.vertex(i)->info();
+@@ -326,7 +326,7 @@ void Delaunay2D::DoFindTriangles() {
+ 	for(int t = 0; t < out.numberoftriangles; ++t){
+ 		Triangle tri;
+ 
+-		auto transform = [&] (const uint v) {
++		auto transform = [&] (const unsigned int v) {
+ 			//each triangle as numberofcorners vertices ( = 3)
+ 			tri.idx[v] = out.trianglelist[t*out.numberofcorners + v];
+ 
+@@ -354,14 +354,14 @@ void Delaunay2D::DoFindTriangles() {
+ 		auto bx = std::minmax({tri.x[0], tri.x[1], tri.x[2]});
+ 		auto by = std::minmax({tri.y[0], tri.y[1], tri.y[2]});
+ 
+-		uint cellXmin = CellX(bx.first);
+-		uint cellXmax = CellX(bx.second);
++		unsigned int cellXmin = CellX(bx.first);
++		unsigned int cellXmax = CellX(bx.second);
+ 
+-		uint cellYmin = CellY(by.first);
+-		uint cellYmax = CellY(by.second);
++		unsigned int cellYmin = CellY(by.first);
++		unsigned int cellYmax = CellY(by.second);
+ 
+-		for(uint i = cellXmin; i <= cellXmax; ++i)
+-			for(uint j = cellYmin; j <= cellYmax; ++j){
++		for(unsigned int i = cellXmin; i <= cellXmax; ++i)
++			for(unsigned int j = cellYmin; j <= cellYmax; ++j){
+ 				//printf("(%u,%u) = %u\n", i, j, Cell(i,j));
+ 				fCells[Cell(i,j)].insert(t);
+ 			}
+@@ -382,7 +382,7 @@ double Delaunay2D::DoInterpolateNormalized(double xx, double yy)
+    ///  FindAllTriangles();
+ 
+     //see comment in header for CGAL fallback section
+-    auto bayCoords = [&] (const uint t) -> std::tuple<double, double, double> {
++    auto bayCoords = [&] (const unsigned int t) -> std::tuple<double, double, double> {
+     	double la = ( (fTriangles[t].y[1] - fTriangles[t].y[2])*(xx - fTriangles[t].x[2])
+     					 + (fTriangles[t].x[2] - fTriangles[t].x[1])*(yy - fTriangles[t].y[2]) ) * fTriangles[t].invDenom;
+     	double lb = ( (fTriangles[t].y[2] - fTriangles[t].y[0])*(xx - fTriangles[t].x[2])
+@@ -401,7 +401,7 @@ double Delaunay2D::DoInterpolateNormalized(double xx, double yy)
+ 	if(cX < 0 || cX > fNCells || cY < 0 || cY > fNCells)
+ 		return fZout; //TODO some more fancy interpolation here
+ 
+-    for(uint t : fCells[Cell(cX, cY)]){
++    for(unsigned int t : fCells[Cell(cX, cY)]){
+     	auto coords = bayCoords(t);
+ 
+     	if(inTriangle(coords)){
+@@ -415,7 +415,7 @@ double Delaunay2D::DoInterpolateNormalized(double xx, double yy)
+ 
+     //debugging
+ 
+-    /*for(uint t = 0; t < fNdt; ++t){
++    /*for(unsigned int t = 0; t < fNdt; ++t){
+     	auto coords = bayCoords(t);
+ 
+     	if(inTriangle(coords)){
+@@ -423,17 +423,17 @@ double Delaunay2D::DoInterpolateNormalized(double xx, double yy)
+     		//brute force found a triangle -> grid not
+     		printf("Found triangle %u for (%f,%f) -> (%u,%u)\n", t, xx,yy, cX, cY);
+     		printf("Triangles in grid cell: ");
+-    		for(uint x : fCells[Cell(cX, cY)])
++    		for(unsigned int x : fCells[Cell(cX, cY)])
+     			printf("%u ", x);
+     		printf("\n");
+ 
+     		printf("Triangle %u is in cells: ", t);
+-    		for(uint i = 0; i <= fNCells; ++i)
+-    			for(uint j = 0; j <= fNCells; ++j)
++    		for(unsigned int i = 0; i <= fNCells; ++i)
++    			for(unsigned int j = 0; j <= fNCells; ++j)
+     				if(fCells[Cell(i,j)].count(t))
+     					printf("(%u,%u) ", i, j);
+     		printf("\n");
+-    		for(uint i = 0; i < 3; ++i)
++    		for(unsigned int i = 0; i < 3; ++i)
+     			printf("\tpoint %u (%u): (%f,%f) -> (%u,%u)\n", i, fTriangles[t].idx[i], fTriangles[t].x[i], fTriangles[t].y[i], CellX(fTriangles[t].x[i]), CellY(fTriangles[t].y[i]));
+ 
+     		//we found the triangle -> interpolate using the barycentric interpolation
diff --git a/spack/packages/root/package.py b/spack/packages/root/package.py
new file mode 100644
index 000000000..8f5e505c3
--- /dev/null
+++ b/spack/packages/root/package.py
@@ -0,0 +1,505 @@
+# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+
+from spack import *
+from spack.util.environment import is_system_path
+import sys
+
+
+class Root(CMakePackage):
+    """ROOT is a data analysis framework."""
+
+    homepage = "https://root.cern.ch"
+    url      = "https://root.cern/download/root_v6.16.00.source.tar.gz"
+
+    maintainers = ['chissg', 'HadrienG2', 'drbenmorgan', 'vvolkl']
+
+    # ###################### Versions ##########################
+
+    # Master branch
+    version('master', git="https://github.com/root-project/root.git",
+            branch='master')
+
+    # Development version (when more recent than production).
+
+    # Production version
+    version('6.22.00', sha256='efd961211c0f9cd76cf4a486e4f89badbcf1d08e7535bba556862b3c1a80beed')
+    version('6.20.08', sha256='d02f224b4908c814a99648782b927c353d44db79dea2cadea86138c1afc23ae9',
+            preferred=True)
+    version('6.20.06', sha256='9a734758a91598d8a58a3d64d7d606aeb17bdf6fd8214e33f5c4d9947d391951')
+    version('6.20.04', sha256='1f8c76ccdb550e64e6ddb092b4a7e9d0a10655ef80044828cba12d5e7c874472')
+    version('6.20.02', sha256='0997586bf097c0afbc6f08edbffcebf5eb6a4237262216114ba3f5c8087dcba6')
+    version('6.20.00', sha256='68421eb0434b38b66346fa8ea6053a0fdc9a6d254e4a72019f4e3633ae118bf0')
+    version('6.18.04', sha256='315a85fc8363f8eb1bffa0decbf126121258f79bd273513ed64795675485cfa4')
+
+    # Old versions
+    version('6.18.02', sha256='50ffffdbf2585a536c77a03f54aa631926138275ffeee02e5a16dde87e978c1d')
+    version('6.18.00', sha256='e6698d6cfe585f186490b667163db65e7d1b92a2447658d77fa831096383ea71')
+    version('6.16.00', sha256='2a45055c6091adaa72b977c512f84da8ef92723c30837c7e2643eecc9c5ce4d8')
+    version('6.14.08', sha256='1b63b51cfb4dc20f1f5749faac6bbd1098eccab777f8b49911257d77186c73c4')
+    version('6.14.06', sha256='0fb943b61396f282b289e35c455a9ab60126229be1bd3f04a8f00b37c13ab432')
+    version('6.14.04', sha256='463ec20692332a422cfb5f38c78bedab1c40ab4d81be18e99b50cf9f53f596cf')
+    version('6.14.02', sha256='93816519523e87ac75924178d87112d1573eaa108fc65691aea9a9dd5bc05b3e')
+    version('6.14.00', sha256='7946430373489310c2791ff7a3520e393dc059db1371272bcd9d9cf0df347a0b')
+    version('6.12.06', sha256='aedcfd2257806e425b9f61b483e25ba600eb0ea606e21262eafaa9dc745aa794')
+    version('6.10.08', sha256='2cd276d2ac365403c66f08edd1be62fe932a0334f76349b24d8c737c0d6dad8a')
+    version('6.08.06', sha256='ea31b047ba6fc04b0b312667349eaf1498a254ccacd212144f15ffcb3f5c0592')
+    version('6.06.08', sha256='7cb836282014cce822ef589cad27811eb7a86d7fad45a871fa6b0e6319ec201a')
+    version('6.06.06', sha256='0a7d702a130a260c72cb6ea754359eaee49a8c4531b31f23de0bfcafe3ce466b')
+    version('6.06.04', sha256='ab86dcc80cbd8e704099af0789e23f49469932ac4936d2291602301a7aa8795b')
+    version('6.06.02', sha256='18a4ce42ee19e1a810d5351f74ec9550e6e422b13b5c58e0c3db740cdbc569d1')
+
+    # ###################### Patches ##########################
+
+    # Widely used patch (CMS, FNAL) to increase the size of static
+    # buffers used to improve the operation of TString.
+    patch('format-stringbuf-size.patch', level=0)
+    # Support use of `mariadb-c-client` and `mariadb` to provide the
+    # MySQL API _cf_
+    # https://github.com/root-project/root/commit/9c0fa8c554a569c971185249f9acfff4418c0c13.
+    patch('find-mysql.patch', level=1, when='@:6.16.00')
+    # Some ROOT versions did not honor the option to avoid building an
+    # internal version of unuran, _cf_
+    # https://github.com/root-project/ROOT/commit/3e60764f133218b6938e5aa4986de760e8f058d9.
+    patch('honor-unuran-switch.patch', level=1, when='@6.08.06:6.13.99')
+    # 6.16.00 fails to handle particular build option combinations, _cf_
+    # https://github.com/root-project/ROOT/commit/e0ae0483985d90a71a6cabd10d3622dfd1c15611.
+    patch('root7-webgui.patch', level=1, when='@6.16.00')
+
+    if sys.platform == 'darwin':
+        # Resolve non-standard use of uint, _cf_
+        # https://sft.its.cern.ch/jira/browse/ROOT-7886.
+        patch('math_uint.patch', when='@6.06.02')
+        # Resolve circular dependency, _cf_
+        # https://sft.its.cern.ch/jira/browse/ROOT-8226.
+        patch('root6-60606-mathmore.patch', when='@6.06.06')
+
+    # ###################### Variants ##########################
+    # See README.md for specific notes about what ROOT configuration
+    # options are or are not supported, and why.
+
+    variant('aqua', default=False,
+            description='Enable Aqua interface')
+    variant('davix', default=True,
+            description='Compile with external Davix')
+    variant('emacs', default=False,
+            description='Enable Emacs support')
+    variant('examples', default=True,
+            description='Install examples')
+    variant('fftw', default=False,
+            description='Enable Fast Fourier Transform support')
+    variant('fits', default=False,
+            description='Enable support for images and data from FITS files')
+    variant('fortran', default=False,
+            description='Enable the Fortran components of ROOT')
+    variant('graphviz', default=False,
+            description='Enable graphviz support')
+    variant('gdml', default=True,
+            description='Enable GDML writer and reader')
+    variant('gminimal', default=True,
+            description='Ignore most of Root\'s feature defaults except for '
+            'basic graphic options')
+    variant('gsl', default=True,
+            description='Enable linking against shared libraries for GSL')
+    variant('http', default=False,
+            description='Enable HTTP server support')
+    variant('jemalloc', default=False,
+            description='Enable using the jemalloc allocator')
+    variant('math', default=True,
+            description='Build the new libMathMore extended math library')
+    variant('memstat', default=False,
+            description='Enable a memory stats utility to detect memory leaks')
+    # Minuit must not be installed as a dependency of root
+    # otherwise it crashes with the internal minuit library
+    variant('minuit', default=True,
+            description='Automatically search for support libraries')
+    variant('mlp', default=False,
+            description="Enable support for TMultilayerPerceptron "
+            "classes' federation")
+    variant('mysql', default=False)
+    variant('opengl', default=True,
+            description='Enable OpenGL support')
+    variant('postgres', default=False,
+            description='Enable postgres support')
+    variant('pythia6', default=False,
+            description='Enable pythia6 support')
+    variant('pythia8', default=False,
+            description='Enable pythia8 support')
+    variant('python', default=True,
+            description='Enable Python ROOT bindings')
+    variant('qt4', default=False,
+            description='Enable Qt graphics backend')
+    variant('r', default=False,
+            description='Enable R ROOT bindings')
+    variant('rpath', default=True,
+            description='Enable RPATH')
+    variant('rootfit', default=True,
+            description='Build the libRooFit advanced fitting package')
+    variant('root7', default=False,
+            description='Enable ROOT 7 support')
+    variant('shadow', default=False,
+            description='Enable shadow password support')
+    variant('sqlite', default=False,
+            description='Enable SQLite support')
+    variant('ssl', default=False,
+            description='Enable SSL encryption support')
+    variant('table', default=False,
+            description='Build libTable contrib library')
+    variant('tbb', default=True,
+            description='TBB multi-threading support')
+    variant('threads', default=True,
+            description='Enable using thread library')
+    variant('tmva', default=False,
+            description='Build TMVA multi variate analysis library')
+    variant('unuran', default=True,
+            description='Use UNURAN for random number generation')
+    variant('vc', default=False,
+            description='Enable Vc for adding new types for SIMD programming')
+    variant('vdt', default=True,
+            description='Enable set of fast and vectorisable math functions')
+    variant('vmc', default=False,
+            description='Enable the Virtual Monte Carlo interface')
+    variant('x', default=True,
+            description='Enable set of graphical options')
+    variant('xml', default=True,
+            description='Enable XML parser interface')
+    variant('xrootd', default=False,
+            description='Build xrootd file server and its client')
+
+    # ###################### Compiler variants ########################
+
+    variant('cxxstd',
+            default='11',
+            values=('11', '14', '17'),
+            multi=False,
+            description='Use the specified C++ standard when building.')
+
+    # ###################### Dependencies ######################
+
+    depends_on('cmake@3.4.3:', type='build', when='@:6.16.99')
+    depends_on('cmake@3.9:', type='build', when='@6.18.00:')
+    depends_on('pkgconfig', type='build')
+
+    depends_on('blas')
+    depends_on('freetype')
+    depends_on('jpeg')
+    depends_on('libice')
+    depends_on('libpng')
+    depends_on('lz4', when='@6.13.02:')  # See cmake_args, below.
+    depends_on('ncurses')
+    depends_on('pcre')
+    depends_on('xxhash', when='@6.13.02:')  # See cmake_args, below.
+    depends_on('xz')
+    depends_on('zlib')
+    depends_on('zstd', when='@6.20:')
+
+    # X-Graphics
+    depends_on('libx11',  when="+x")
+    depends_on('libxext', when="+x")
+    depends_on('libxft',  when="+x")
+    depends_on('libxpm',  when="+x")
+    depends_on('libsm',   when="+x")
+
+    # OpenGL
+    depends_on('ftgl@2.4.0:',  when="+x+opengl")
+    depends_on('glew',  when="+x+opengl")
+    depends_on('gl',    when="+x+opengl")
+    depends_on('glu',   when="+x+opengl")
+    depends_on('gl2ps', when="+x+opengl")
+
+    # Qt4
+    depends_on('qt@:4.999', when='+qt4')
+
+    # Python
+    depends_on('python@2.7:', when='+python', type=('build', 'run'))
+    depends_on('py-numpy', type=('build', 'run'), when='+tmva')
+    # This numpy dependency was not intended and will hopefully
+    # be fixed in 6.20.06.
+    # See: https://sft.its.cern.ch/jira/browse/ROOT-10626
+    depends_on('py-numpy', type=('build', 'run'),
+               when='@6.20.00:6.20.05 +python')
+
+    # Optional dependencies
+    depends_on('davix @0.7.1:', when='+davix')
+    depends_on('cfitsio',   when='+fits')
+    depends_on('fftw',      when='+fftw')
+    depends_on('graphviz',  when='+graphviz')
+    depends_on('gsl',       when='+gsl')
+    depends_on('jemalloc',  when='+jemalloc')
+    depends_on('mysql-client',   when='+mysql')
+    depends_on('openssl',   when='+ssl')
+    depends_on('openssl',   when='+davix')  # Also with davix
+    depends_on('postgresql', when='+postgres')
+    depends_on('pythia6+root', when='+pythia6')
+    depends_on('pythia8',   when='+pythia8')
+    depends_on('r',         when='+r', type=('build', 'run'))
+    depends_on('r-rcpp',    when='+r', type=('build', 'run'))
+    depends_on('r-rinside', when='+r', type=('build', 'run'))
+    depends_on('readline',  when='+r')
+    depends_on('shadow',    when='+shadow')
+    depends_on('sqlite',    when='+sqlite')
+    depends_on('tbb',       when='+tbb')
+    depends_on('unuran',    when='+unuran')
+    depends_on('vc',        when='+vc')
+    depends_on('vdt',       when='+vdt')
+    depends_on('libxml2',   when='+xml')
+    depends_on('xrootd@:4.99.99',    when='+xrootd')
+
+    # ###################### Conflicts ######################
+
+    # I was unable to build root with any Intel compiler
+    # See https://sft.its.cern.ch/jira/browse/ROOT-7517
+    conflicts('%intel')
+
+    # ROOT <6.08 was incompatible with the GCC 5+ ABI
+    conflicts('%gcc@5.0.0:', when='@:6.07.99')
+
+    # The version of Clang featured in ROOT <6.12 fails to build with
+    # GCC 9.2.1, which we can safely extrapolate to the GCC 9 series.
+    conflicts('%gcc@9.0.0:', when='@:6.11.99')
+
+    # ROOT <6.14 was incompatible with Python 3.7+
+    conflicts('^python@3.7:', when='@:6.13.99 +python')
+
+    # See README.md
+    ## S. Joosten --> commented out, this is not an issue when building in
+    ##                a container
+    #conflicts('+http',
+    #          msg='HTTP server currently unsupported due to dependency issues')
+
+    # Incompatible variants
+    conflicts('+opengl', when='~x', msg='OpenGL requires X')
+    conflicts('+tmva', when='~gsl', msg='TVMA requires GSL')
+    conflicts('+tmva', when='~mlp', msg='TVMA requires MLP')
+    conflicts('cxxstd=11', when='+root7', msg='root7 requires at least C++14')
+
+    # Feature removed in 6.18:
+    for pkg in ('memstat', 'qt4', 'table'):
+        conflicts('+' + pkg, when='@6.18.00:',
+                  msg='Obsolete option +{0} selected.'.format(pkg))
+
+    def cmake_args(self):
+        spec = self.spec
+        define = self.define
+        define_from_variant = self.define_from_variant
+        options = []
+
+        # ###################### Boolean Options ######################
+        # For option list format see _process_opts(), below.
+
+        # Options controlling gross build / config behavior.
+        options += [
+            define('cxxmodules', False),
+            define('exceptions', True),
+            define('explicitlink', True),
+            define('fail-on-missing', True),
+            define_from_variant('fortran'),
+            define_from_variant('gminimal'),
+            define('gnuinstall', False),
+            define('libcxx', False),
+            define('pch', True),
+            define('roottest', False),
+            define_from_variant('rpath'),
+            define('runtime_cxxmodules', False),
+            define('shared', True),
+            define('soversion', True),
+            define('testing', self.run_tests),
+            define_from_variant('thread', 'threads')
+        ]
+
+        # Options related to ROOT's ability to download and build its own
+        # dependencies. Per Spack convention, this should generally be avoided.
+        options += [
+            define('builtin_afterimage', True),
+            define('builtin_cfitsio', False),
+            define('builtin_davix', False),
+            define('builtin_fftw3', False),
+            define('builtin_freetype', False),
+            define('builtin_ftgl', False),
+            define('builtin_gl2ps', False),
+            define('builtin_glew', False),
+            define('builtin_gsl', False),
+            define('builtin_llvm', True),
+            define('builtin_lz4', self.spec.satisfies('@6.12.02:6.12.99')),
+            define('builtin_lzma', False),
+            define('builtin_openssl', False),
+            define('builtin_pcre', False),
+            define('builtin_tbb', False),
+            define('builtin_unuran', False),
+            define('builtin_vc', False),
+            define('builtin_vdt', False),
+            define('builtin_veccore', False),
+            define('builtin_xrootd', False),
+            define('builtin_xxhash', self.spec.satisfies('@6.12.02:6.12.99')),
+            define('builtin_zlib', False)
+        ]
+
+        # Features
+        options += [
+            define('afdsmrgd', False),
+            define('afs', False),
+            define('alien', False),
+            define('arrow', False),
+            define('asimage', True),
+            define('astiff', True),
+            define('bonjour', False),
+            define('castor', False),
+            define('ccache', False),
+            define('chirp', False),
+            define('cling', True),
+            define_from_variant('cocoa', 'aqua'),
+            define('dataframe', True),
+            define_from_variant('davix'),
+            define('dcache', False),
+            define_from_variant('fftw3', 'fftw'),
+            define_from_variant('fitsio', 'fits'),
+            define_from_variant('ftgl', 'opengl'),
+            define_from_variant('gdml'),
+            define_from_variant('genvector', 'math'),
+            define('geocad', False),
+            define('gfal', False),
+            define_from_variant('gl2ps', 'opengl'),
+            define('glite', False),
+            define('globus', False),
+            define_from_variant('gsl_shared', 'gsl'),
+            define_from_variant('gviz', 'graphviz'),
+            define('hdfs', False),
+            define_from_variant('http'),  # See conflicts
+            define_from_variant('imt', 'tbb'),
+            define_from_variant('jemalloc'),
+            define('krb5', False),
+            define('ldap', False),
+            define_from_variant('mathmore', 'math'),
+            define_from_variant('memstat'),  # See conflicts
+            define('minimal', False),
+            define_from_variant('minuit'),
+            define_from_variant('minuit2', 'minuit'),
+            define_from_variant('mlp'),
+            define('monalisa', False),
+            define_from_variant('mysql'),
+            define('odbc', False),
+            define_from_variant('opengl'),
+            define('oracle', False),
+            define_from_variant('pgsql', 'postgres'),
+            define_from_variant('pythia6'),
+            define_from_variant('pythia8'),
+            define_from_variant('qt', 'qt4'),  # See conflicts
+            define_from_variant('qtgsi', 'qt4'),  # See conflicts
+            define_from_variant('r'),
+            define('rfio', False),
+            define('roofit', False),
+            define_from_variant('root7'),  # See conflicts
+            define('ruby', False),
+            define('sapdb', False),
+            define_from_variant('shadowpw', 'shadow'),
+            define_from_variant('sqlite'),
+            define('srp', False),
+            define_from_variant('ssl'),
+            define_from_variant('table'),
+            define_from_variant('tbb'),
+            define('tcmalloc', False),
+            define_from_variant('tmva'),
+            define_from_variant('unuran'),
+            define_from_variant('vc'),
+            define_from_variant('vdt'),
+            define('veccore', False),
+            define_from_variant('vmc'),
+            define_from_variant('webui', 'root7'),  # requires root7
+            define_from_variant('x11', 'x'),
+            define_from_variant('xft', 'x'),
+            define_from_variant('xml'),
+            define_from_variant('xrootd')
+        ]
+
+        # Some special features
+        if self.spec.satisfies('@6.20:'):
+            options.append(define_from_variant('pyroot', 'python'))
+        else:
+            options.append(define_from_variant('python'))
+
+        # #################### Compiler options ####################
+
+        if sys.platform == 'darwin' and self.compiler.cc == 'gcc':
+            cflags = '-D__builtin_unreachable=__builtin_trap'
+            options.extend([
+                define('CMAKE_C_FLAGS', cflags),
+                define('CMAKE_CXX_FLAGS', cflags),
+            ])
+
+        # Method for selecting C++ standard depends on ROOT version
+        if self.spec.satisfies('@6.18.00:'):
+            options.append(define_from_variant('CMAKE_CXX_STANDARD', 'cxxstd'))
+        else:
+            options.append(define('cxx' + self.spec.variants['cxxstd'].value,
+                                  True))
+
+        if '+x+opengl' in self.spec:
+            ftgl_prefix = self.spec['ftgl'].prefix
+            options.append(define('FTGL_ROOT_DIR', ftgl_prefix))
+            options.append(define('FTGL_INCLUDE_DIR', ftgl_prefix.include))
+        if '+python' in self.spec:
+            # See https://github.com/spack/spack/pull/11579
+            options.append(define('PYTHON_EXECUTABLE',
+                                  spec['python'].command.path))
+
+        return options
+
+    def setup_build_environment(self, env):
+        spec = self.spec
+
+        if 'lz4' in spec:
+            env.append_path('CMAKE_PREFIX_PATH', spec['lz4'].prefix)
+
+        # This hack is made necessary by a header name collision between
+        # asimage's "import.h" and Python's "import.h" headers...
+        env.set('SPACK_INCLUDE_DIRS', '', force=True)
+
+        # ...but it breaks header search for any ROOT dependency which does not
+        # use CMake. To resolve this, we must bring back those dependencies's
+        # include paths into SPACK_INCLUDE_DIRS.
+        #
+        # But in doing so, we must be careful not to inject system header paths
+        # into SPACK_INCLUDE_DIRS, even in a deprioritized form, because some
+        # system/compiler combinations don't like having -I/usr/include around.
+        def add_include_path(dep_name):
+            include_path = spec[dep_name].prefix.include
+            if not is_system_path(include_path):
+                env.append_path('SPACK_INCLUDE_DIRS', include_path)
+
+        # With that done, let's go fixing those deps
+        if spec.satisfies('@:6.12.99'):
+            add_include_path('zlib')
+        if '+x' in spec:
+            if spec.satisfies('@:6.08.99') or spec.satisfies('@6.22:'):
+                add_include_path('xextproto')
+            add_include_path('fontconfig')
+            add_include_path('libx11')
+            add_include_path('xproto')
+        if '+opengl' in spec:
+            add_include_path('glew')
+            add_include_path('mesa-glu')
+
+    def setup_run_environment(self, env):
+        env.set('ROOTSYS', self.prefix)
+        env.set('ROOT_VERSION', 'v{0}'.format(self.version.up_to(1)))
+        env.prepend_path('PYTHONPATH', self.prefix.lib)
+
+    def setup_dependent_build_environment(self, env, dependent_spec):
+        env.set('ROOTSYS', self.prefix)
+        env.set('ROOT_VERSION', 'v{0}'.format(self.version.up_to(1)))
+        env.prepend_path('PYTHONPATH', self.prefix.lib)
+        env.prepend_path('PATH', self.prefix.bin)
+        env.append_path('CMAKE_MODULE_PATH', self.prefix.cmake)
+        if "+rpath" not in self.spec:
+            env.prepend_path('LD_LIBRARY_PATH', self.prefix.lib)
+
+    def setup_dependent_run_environment(self, env, dependent_spec):
+        env.set('ROOTSYS', self.prefix)
+        env.set('ROOT_VERSION', 'v{0}'.format(self.version.up_to(1)))
+        env.prepend_path('PYTHONPATH', self.prefix.lib)
+        env.prepend_path('PATH', self.prefix.bin)
+        if "+rpath" not in self.spec:
+            env.prepend_path('LD_LIBRARY_PATH', self.prefix.lib)
diff --git a/spack/packages/root/root6-60606-mathmore.patch b/spack/packages/root/root6-60606-mathmore.patch
new file mode 100644
index 000000000..d009a5af0
--- /dev/null
+++ b/spack/packages/root/root6-60606-mathmore.patch
@@ -0,0 +1,29 @@
+diff --git a/math/mathmore/inc/Math/QuantFuncMathMore.h b/math/mathmore/inc/Math/QuantFuncMathMore.h
+index fd6679c..03ccc03 100644
+--- a/math/mathmore/inc/Math/QuantFuncMathMore.h
++++ b/math/mathmore/inc/Math/QuantFuncMathMore.h
+@@ -25,17 +25,6 @@
+   **********************************************************************/
+ 
+ 
+-#if defined(__CINT__) && !defined(__MAKECINT__)
+-// avoid to include header file when using CINT
+-#ifndef _WIN32
+-#include "../lib/libMathMore.so"
+-#else
+-#include "../bin/libMathMore.dll"
+-#endif
+-
+-#else
+-
+-
+ #ifndef ROOT_Math_QuantFuncMathMore
+ #define ROOT_Math_QuantFuncMathMore
+ 
+@@ -190,5 +179,3 @@ namespace MathMore {
+ 
+ 
+ #endif // ROOT_Math_QuantFuncMathMore
+-
+-#endif // if defined (__CINT__) && !defined(__MAKECINT__)
+
diff --git a/spack/packages/root/root7-webgui.patch b/spack/packages/root/root7-webgui.patch
new file mode 100644
index 000000000..61cf5150d
--- /dev/null
+++ b/spack/packages/root/root7-webgui.patch
@@ -0,0 +1,106 @@
+diff --git a/cmake/modules/CheckCompiler.cmake b/cmake/modules/CheckCompiler.cmake
+index 71f628f7f6..56d64fee43 100644
+--- a/cmake/modules/CheckCompiler.cmake
++++ b/cmake/modules/CheckCompiler.cmake
+@@ -130,10 +130,10 @@ if(cxx17)
+ endif()
+ if(root7)
+   if(cxx11)
+-    message(STATUS "ROOT7 interfaces require >= cxx14 which is disabled. Switching OFF root7 option")
+-    set(root7 OFF CACHE BOOL "" FORCE)
++    message(FATAL ERROR "ROOT 7 requires C++14 or higher")
++  elseif(NOT http)
++    set(http ON CACHE BOOL "(Enabled since it's needed by ROOT 7)" FORCE)
+   endif()
+-    set(http ON CACHE BOOL "" FORCE)
+ endif()
+ 
+ #---Check for libcxx option------------------------------------------------------------
+diff --git a/cmake/modules/RootBuildOptions.cmake b/cmake/modules/RootBuildOptions.cmake
+index f1e6237592..4406549367 100644
+--- a/cmake/modules/RootBuildOptions.cmake
++++ b/cmake/modules/RootBuildOptions.cmake
+@@ -156,6 +156,7 @@ ROOT_BUILD_OPTION(qt5web OFF "Enable support for Qt5 web-based display (requires
+ ROOT_BUILD_OPTION(r OFF "Enable support for R bindings (requires R, Rcpp, and RInside)")
+ ROOT_BUILD_OPTION(rfio OFF "Enable support for RFIO (Remote File IO) for CASTOR")
+ ROOT_BUILD_OPTION(roofit ON "Build RooFit advanced fitting package")
++ROOT_BUILD_OPTION(webui ON "Build Web-based UI components of ROOT (requires C++14 standard or higher)")
+ ROOT_BUILD_OPTION(root7 OFF "Build ROOT 7 components of ROOT (requires C++14 standard or higher)")
+ ROOT_BUILD_OPTION(rpath OFF "Link libraries with built-in RPATH (run-time search path)")
+ ROOT_BUILD_OPTION(runtime_cxxmodules OFF "Enable runtime support for C++ modules")
+@@ -317,6 +318,17 @@ endforeach()
+ #---Apply root7 versus language------------------------------------------------------------------
+ if(cxx14 OR cxx17 OR cxx14_defval OR cxx17_defval)
+   set(root7_defvalue ON)
++else()
++  set(root7_defvalue OFF)
++  set(webui_defvalue OFF)
++endif()
++
++if(webui)
++  if(cxx11)
++    message(FATAL_ERROR "WebUI requires C++14 or higher")
++  elseif(NOT http)
++    set(http ON CACHE BOOL "(Enabled since it's needed by webui)" FORCE)
++  endif()
+ endif()
+ 
+ #---roottest option implies testing
+diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake
+index 8273d5e382..7598ccaaeb 100644
+--- a/cmake/modules/SearchInstalledSoftware.cmake
++++ b/cmake/modules/SearchInstalledSoftware.cmake
+@@ -1599,14 +1599,16 @@ endif()
+ 
+ 
+ #------------------------------------------------------------------------------------
+-ExternalProject_Add(
+-   OPENUI5
+-   URL ${CMAKE_SOURCE_DIR}/net/http/openui5/openui5.tar.gz
+-   URL_HASH SHA256=32e50e3e8808295c67ecb7561ea9cd9beb76dd934263170fbbd05ff59b6d501d
+-   CONFIGURE_COMMAND ""
+-   BUILD_COMMAND ""
+-   INSTALL_COMMAND ""
+-   SOURCE_DIR ${CMAKE_BINARY_DIR}/etc/http/openui5dist)
++if(webui)
++  ExternalProject_Add(
++    OPENUI5
++    URL ${CMAKE_SOURCE_DIR}/net/http/openui5/openui5.tar.gz
++    URL_HASH SHA256=32e50e3e8808295c67ecb7561ea9cd9beb76dd934263170fbbd05ff59b6d501d
++    CONFIGURE_COMMAND ""
++    BUILD_COMMAND ""
++    INSTALL_COMMAND ""
++    SOURCE_DIR ${CMAKE_BINARY_DIR}/etc/http/openui5dist)
++endif()
+ 
+ #---Report removed options---------------------------------------------------
+ foreach(opt afs glite sapdb srp chirp ios)
+diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
+index 499c427180..38b73b29cd 100644
+--- a/gui/CMakeLists.txt
++++ b/gui/CMakeLists.txt
+@@ -6,7 +6,7 @@ add_subdirectory(guihtml)
+ add_subdirectory(recorder)
+ add_subdirectory(sessionviewer)
+ 
+-if(cxx14 OR cxx17 OR root7)
++if(webui)
+    add_subdirectory(webdisplay)
+    if(cefweb)
+       add_subdirectory(cefdisplay)
+@@ -15,11 +15,10 @@ if(cxx14 OR cxx17 OR root7)
+       add_subdirectory(qt5webdisplay)
+    endif()
+    add_subdirectory(webgui6)
+-endif()
+-
+-if(root7)
+-  add_subdirectory(canvaspainter)
+-  add_subdirectory(fitpanelv7)
++   if(root7)
++     add_subdirectory(canvaspainter)
++     add_subdirectory(fitpanelv7)
++   endif()
+ endif()
+ if(qtgsi)
+   add_subdirectory(qtgsi)
diff --git a/spack/repo.yaml b/spack/repo.yaml
new file mode 100644
index 000000000..6cde3b536
--- /dev/null
+++ b/spack/repo.yaml
@@ -0,0 +1,2 @@
+repo:
+  namespace: 'np-spack'
-- 
GitLab