--- wine.spec.orig	2016-06-15 19:18:09.000000000 -0500
+++ wine.spec	2016-06-23 15:42:20.609841617 -0500
@@ -14,8 +14,13 @@
 # uncomment to enable; comment-out to disable.
 %if 0%{?fedora}
 %global compholio 1
+%global nine 1
 %endif # 0%{?fedora}
 
+# https://aur.archlinux.org/cgit/aur.git/log/?h=wine-gaming-nine
+%global commit9 2b02d6b69e11c24f44bcec260938fb92fdb4e3ec
+%global shortcommit9 %(c=%{commit9}; echo ${c:0:7})
+
 # binfmt macros for RHEL
 %if 0%{?fedora} <= 20 || 0%{?rhel} == 7
 %global _binfmtdir /usr/lib/binfmt.d
@@ -26,7 +31,7 @@
 
 Name:           wine
 Version:        1.9.12
-Release:        1%{?dist}
+Release:        2%{?nine:.with_nine}%{?dist}
 Summary:        A compatibility layer for windows applications
 
 Group:          Applications/Emulators
@@ -79,6 +84,9 @@
 # pulseaudio-patch is covered by that patch-set, too.
 Source900: https://github.com/compholio/wine-compholio/archive/v%{version}.tar.gz#/wine-staging-%{version}.tar.gz
 
+# gallium nine patch
+Source999: https://aur.archlinux.org/cgit/aur.git/snapshot/aur-%{commit9}.tar.gz#/wine-gaming-nine-%{shortcommit9}.tar.gz
+
 %if !%{?no64bit}
 ExclusiveArch:  %{ix86} x86_64 %{arm}
 %else
@@ -152,6 +160,10 @@
 BuildRequires:  libva-devel
 %endif # 0%{?compholio}
 
+%if 0%{?nine}
+BuildRequires:  mesa-libd3d-devel
+%endif
+
 %if 0%{?fedora} >= 10 || 0%{?rhel} >= 6
 BuildRequires:  openal-soft-devel
 BuildRequires:  icoutils
@@ -262,6 +274,9 @@
 %if 0%{?compholio}
 Requires:       libva(x86-32)
 %endif
+%if 0%{?nine}
+Requires:       mesa-libd3d(x86-32)
+%endif
 %endif
 
 %ifarch x86_64
@@ -282,6 +297,9 @@
 %if 0%{?compholio}
 Requires:       libva(x86-64)
 %endif
+%if 0%{?nine}
+Requires:       mesa-libd3d(x86-64)
+%endif
 %endif
 
 %ifarch %{arm}
@@ -679,6 +697,30 @@
 
 %endif # 0%{?compholio}
 
+%if 0%{?nine}
+gzip -dc %{SOURCE999} | tar -xf - --strip-components=1
+
+#Additional patches:
+# -Gallium Nine support
+# -Mip-Map fix (see https://bugs.winehq.org/show_bug.cgi?id=34480 )
+# -Keybind patch reversion
+# -Heap allocation perfomance improvement patch
+# -Wbemprox videocontroller query fix v2 (see https://bugs.winehq.org/show_bug.cgi?id=38879 )
+# -Steam patch, Crossover Hack version (see https://bugs.winehq.org/show_bug.cgi?id=39403 )
+
+patch -p1 < ./nine-1.9.1.patch
+patch -p1 < ./steam.patch
+patch -p1 < ./mipmap.patch
+patch -p1 < ./heap_perf.patch
+patch -p1 < ./wbemprox_query_v2.patch
+
+patch -p1 -R < ./keybindings.patch
+
+autoreconf -f
+
+sed 's|OpenCL/opencl.h|CL/opencl.h|g' -i configure*
+%endif # 0%{?nine}
+
 %build
 
 # disable fortify as it breaks wine
@@ -695,6 +737,7 @@
  --enable-win64 \
 %endif
 %{?compholio: --with-xattr} \
+%{?nine: --with-d3dadapter} \
  --disable-tests
 
 %{__make} %{?_smp_mflags} TARGETFLAGS=""
@@ -1321,6 +1364,9 @@
 %{_libdir}/wine/ctapi32.dll.so
 %{_libdir}/wine/ctl3d32.dll.so
 %{_libdir}/wine/d2d1.dll.so
+%if 0%{?nine}
+%{_libdir}/wine/d3d9-nine.dll.so
+%endif
 %{_libdir}/wine/d3d10.dll.so
 %{_libdir}/wine/d3d10_1.dll.so
 %{_libdir}/wine/d3d10core.dll.so
@@ -2038,30 +2084,51 @@
 %endif
 
 %changelog
+* Thu Jun 23 2016 Dylan Smith <dyskette@gmail.com> - 1.9.12-2.with_nine
+- Apply patches to 1.9.12
+
 * Wed Jun 15 2016 Michael Cronenworth <mike@cchtml.com> 1.9.12-1
 - version update
 
 * Tue Jun 07 2016 Michael Cronenworth <mike@cchtml.com> 1.9.11-1
 - version update
 
+* Fri May 27 2016 Dylan Smith <dyskette@gmail.com> - 1.9.10-4.with_nine
+- Apply patches to 1.9.10
+
 * Tue May 24 2016 Michael Cronenworth <mike@cchtml.com> 1.9.10-2
 - gecko update
 
 * Tue May 17 2016 Michael Cronenworth <mike@cchtml.com> 1.9.10-1
 - version upgrade
 
+* Tue May 03 2016 Dylan Smith <dyskette@gmail.com> - 1.9.9-2.with_nine
+- Apply patches to 1.9.9
+
 * Sun May 01 2016 Michael Cronenworth <mike@cchtml.com> 1.9.9-1
 - version upgrade
 
+* Tue Apr 19 2016 Dylan Smith <dyskette@gmail.com> - 1.9.8-2.with_nine
+- Apply patches to 1.9.8
+
 * Sun Apr 17 2016 Michael Cronenworth <mike@cchtml.com> 1.9.8-1
 - version upgrade
 
+* Sun Apr 17 2016 Dylan Smith <dyskette@gmail.com> - 1.9.7-2.with_nine
+- Apply patches to 1.9.7
+
 * Sun Apr 03 2016 Michael Cronenworth <mike@cchtml.com> 1.9.7-1
 - version upgrade
 
+* Sat Mar 26 2016 Dylan Smith <dyskette@gmail.com> - 1.9.6-2.with_nine
+- Apply patches to 1.9.6
+
 * Mon Mar 21 2016 Michael Cronenworth <mike@cchtml.com> 1.9.6-1
 - version upgrade
 
+* Wed Mar 16 2016 Dylan Smith <dyskette@gmail.com> - 1.9.5-3.with_nine
+- Apply patches to 1.9.5
+
 * Tue Mar 08 2016 Michael Cronenworth <mike@cchtml.com> 1.9.5-2
 - update mono requirement
 
@@ -2077,6 +2144,9 @@
 * Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.2-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
 
+* Sun Jan 31 2016 Dylan Smith <dyskette@gmail.com> - 1.9.2-2.with_nine
+- Use patches from AUR : wine-gaming-nine
+
 * Sun Jan 24 2016 Michael Cronenworth <mike@cchtml.com> 1.9.2-1
 - version upgrade
 - enable gstreamer support
@@ -2097,15 +2167,30 @@
 * Sun Dec 06 2015 Michael Cronenworth <mike@cchtml.com> 1.8-0.1
 - version upgrade, 1.8-rc3
 
+* Wed Nov 18 2015 Dylan Smith - 1.7.55-2.with_nine
+- Upgrade gallium nine patch
+
 * Sun Nov 15 2015 Michael Cronenworth <mike@cchtml.com> 1.7.55-1
 - version upgrade
 
 * Wed Nov 04 2015 Michael Cronenworth <mike@cchtml.com> 1.7.54-1
 - version upgrade
 
+* Tue Oct 27 2015 Dylan Smith - 1.7.53-2.with_nine
+- Upgrade gallium nine patch
+
 * Wed Oct 21 2015 Michael Cronenworth <mike@cchtml.com> 1.7.53-1
 - version upgrade
 
+* Wed Oct 14 2015 Dylan Smith - 1.7.52-4.with_nine
+- Fix dependency on mesa-libd3d
+
+* Wed Oct 14 2015 Dylan Smith - 1.7.52-3.with_nine
+- Add autoreconf
+
+* Mon Oct 12 2015 Dylan Smith <dyskette@gmail.com> - 1.7.52-2.with_nine
+- Add gallium nine patch
+
 * Sat Oct 03 2015 Michael Cronenworth <mike@cchtml.com> 1.7.52-1
 - version upgrade
 
