# HG changeset patch
# User Markus Mützel <markus.muetzel@gmx.de>
# Date 1594321768 -7200
#      Thu Jul 09 21:09:28 2020 +0200
# Node ID 03bacc64814e2de8284a78d16d4417f7aa579c5b
# Parent  f7b4b538fd39b4e35d43c7b52d15404d9afb0ef2
Update mesa to version 20.0.8 (bug #58689).

* src/mesa.mk: Update version and checksum. Add build-meson to dependecies.
Update cross build rule for Windows.
* src/mesa-1-meson.patch: Add new patch.
* src/mesa-1-fixes.patch: Remove old patch.
* dist-files.mk: Update file list.

diff -r f7b4b538fd39 -r 03bacc64814e dist-files.mk
--- a/dist-files.mk	Sun Jul 05 20:58:57 2020 +0200
+++ b/dist-files.mk	Thu Jul 09 21:09:28 2020 +0200
@@ -323,7 +323,7 @@
   lzo.mk \
   matio.mk \
   mdbtools.mk \
-  mesa-1-fixes.patch \
+  mesa-1-meson.patch \
   mesa-proto.mk \
   mesa.mk \
   mingw-blas-1-xerbla.patch \
diff -r f7b4b538fd39 -r 03bacc64814e src/mesa-1-fixes.patch
--- a/src/mesa-1-fixes.patch	Sun Jul 05 20:58:57 2020 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-diff -uNr a/scons/gallium.py b/scons/gallium.py
---- a/scons/gallium.py	2017-09-17 19:03:22.000000000 -0400
-+++ b/scons/gallium.py	2017-10-04 19:24:29.499373623 -0400
-@@ -580,9 +580,6 @@
-                 '-Wl,--dynamicbase', # ASLR
-             ]
-             # Avoid depending on gcc runtime DLLs
--            linkflags += ['-static-libgcc']
--            if 'w64' in env['CC'].split('-'):
--                linkflags += ['-static-libstdc++']
-             # Handle the @xx symbol munging of DLL exports
-             shlinkflags += ['-Wl,--enable-stdcall-fixup']
-             #shlinkflags += ['-Wl,--kill-at']
-diff -uNr a/scons/llvm.py b/scons/llvm.py
---- a/scons/llvm.py	2018-12-27 17:02:01.000000000 +0100
-+++ b/scons/llvm.py	2019-01-21 18:47:28.456846140 +0100
-@@ -122,10 +122,7 @@
-                 'LLVMIRReader', 'LLVMAsmParser',
-                 'LLVMDemangle', 'LLVMGlobalISel', 'LLVMDebugInfoMSF',
-                 'LLVMBinaryFormat',
-+                'version', 'uuid', 'ole32', 'oleaut32', 'z',
-             ])
--            if env['platform'] == 'windows' and env['crosscompile']:
--                # LLVM 5.0 requires MinGW w/ pthreads due to use of std::thread and friends.
--                assert env['gcc']
--                env['CXX'] = env['CXX'] + '-posix'
-         elif llvm_version >= distutils.version.LooseVersion('4.0'):
-             env.Prepend(LIBS = [
-
diff -r f7b4b538fd39 -r 03bacc64814e src/mesa-1-meson.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mesa-1-meson.patch	Thu Jul 09 21:09:28 2020 +0200
@@ -0,0 +1,15 @@
+Don't link to Win32 library libstdc++
+
+diff --git "a/meson.build" "b/meson.build"
+index eaaca7f..9b9d2d3 100644
+--- "a/meson.build"	
++++ "b/meson.build"
+@@ -1030,8 +1030,7 @@ if host_machine.system() == 'windows'
+     add_project_link_arguments(
+       '-Wl,--nxcompat',
+       '-Wl,--dynamicbase',
+       '-static-libgcc',
+-      '-static-libstdc++',
+       language : ['c', 'cpp'],
+     )
+   endif
diff -r f7b4b538fd39 -r 03bacc64814e src/mesa.mk
--- a/src/mesa.mk	Sun Jul 05 20:58:57 2020 +0200
+++ b/src/mesa.mk	Thu Jul 09 21:09:28 2020 +0200
@@ -2,17 +2,18 @@
 # See index.html for further information.
 
 PKG             := mesa
-$(PKG)_VERSION  := 19.0.8
-$(PKG)_CHECKSUM := 5fd340a6304f7501014e1bd7291e4cfa7a6efcdb
+$(PKG)_VERSION  := 20.0.8
+$(PKG)_CHECKSUM := 54be52b058b931212b5994e8974c417b4b6c3157
 $(PKG)_SUBDIR   := mesa-$($(PKG)_VERSION)
 $(PKG)_FILE     := mesa-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.freedesktop.org/pub/mesa/$($(PKG)_FILE)
-$(PKG)_DEPS     := build-mako expat zlib llvm s2tc
+$(PKG)_DEPS     := build-mako build-meson expat zlib llvm s2tc
 
 $(PKG)_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
 ifeq ($(MXE_WINDOWS_BUILD),yes)
   ifeq ($(USE_SYSTEM_OPENGL),no)
-    $(PKG)_SCONS_OPENGL_OPTIONS := libgl-gdi
+    # FIXME: How to change the build rule for USE_SYSTEM_OPENGL
+    # Maybe we shouldn't build mesa at all in that case?
   endif
 else
   ifeq ($(USE_SYSTEM_OPENGL),yes)
@@ -42,44 +43,20 @@
 endef
 
 ifeq ($(MXE_WINDOWS_BUILD),yes)
-  ifeq ($(ENABLE_WINDOWS_64),yes)
-    $(PKG)_MACHINE := x86_64
-  else
-    $(PKG)_MACHINE := x86
-  endif
-  define $(PKG)_BUILD
-    cd '$(1)' && LLVM=$(HOST_PREFIX) scons platform=windows toolchain=crossmingw machine=$($(PKG)_MACHINE) verbose=1 build=release $($(PKG)_SCONS_OPENGL_OPTIONS)
+  # FIXME: Should this be defined in the top-level Makefile?
+  MESON_CROSS_TOOLCHAIN_FILE = '$(HOST_PREFIX)/share/meson/cross/mxe-conf.ini'
 
-    ## Do the scons config files have useful install targets?
-    $(INSTALL) -d '$(3)$(HOST_INCDIR)/GL';
-    for f in '$(1)/include/GL/*.h' ; do \
-      $(INSTALL) -m 644 $$f '$(3)$(HOST_INCDIR)/GL'; \
-    done
-    $(INSTALL) -d '$(3)$(HOST_INCDIR)/KHR';
-    for f in '$(1)/include/KHR/*.h' ; do \
-      $(INSTALL) -m 644 $$f '$(3)$(HOST_INCDIR)/KHR'; \
-    done
+  $(PKG)_MESON_CROSS_FLAGS := --cross-file $(MESON_CROSS_TOOLCHAIN_FILE)
+endif
 
-    if [ -f '$(1)/build/windows-$($(PKG)_MACHINE)/gallium/targets/libgl-gdi/opengl32.dll' ]; then \
-      $(INSTALL) -d '$(3)$(HOST_BINDIR)'; \
-      $(INSTALL) -m 755 '$(1)/build/windows-$($(PKG)_MACHINE)/gallium/targets/libgl-gdi/opengl32.dll' '$(3)$(HOST_BINDIR)/opengl32.dll'; \
-    fi
-  endef
-else
-  define $(PKG)_BUILD
-    mkdir '$(1)/.build'
-    cd '$(1)' && autoreconf -fi  -I m4
-    cd '$(1)/.build' && $($(PKG)_CONFIGURE_ENV) '$(1)/configure' \
-        $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
-        $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
-        --prefix='$(HOST_PREFIX)' \
-        $($(PKG)_CONFIGURE_OPENGL_OPTIONS) \
-        --enable-autotools \
-        --disable-osmesa \
-        --disable-gbm \
-        --disable-xvmc \
-        && $(CONFIGURE_POST_HOOK)
+define $(PKG)_BUILD
+  cd '$(1)' && LLVM=$(HOST_PREFIX) \
+      meson $(1)/.build \
+      $($(PKG)_MESON_CROSS_FLAGS) \
+      -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
+      -Dprefix='$(HOST_PREFIX)' \
+      -Dshared-llvm=true
 
-    $(MAKE) -C '$(1)/.build' -j '$(JOBS)' install DESTDIR='$(3)'
-  endef
-endif
+  cd '$(1)/.build' && ninja
+endef
+
