File 0002-Revert-Rework-detection-of-mupdf.patch of Package zathura-plugin-pdf-mupdf

From 30cce0de02460c8cb547b5fb5089f68bfc68aab5 Mon Sep 17 00:00:00 2001
From: Josh <jsmithfpv@disroot.org>
Date: Thu, 13 Jun 2024 02:07:06 -0400
Subject: [PATCH 2/2] mupdf-detection

---
 meson.build       | 28 +++++-----------------------
 meson_options.txt |  6 ++++++
 2 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/meson.build b/meson.build
index 85ccad7..9d30041 100644
--- a/meson.build
+++ b/meson.build
@@ -22,7 +22,7 @@ zathura = dependency('zathura', version: '>=0.5.2')
 girara = dependency('girara-gtk3')
 glib = dependency('glib-2.0')
 cairo = dependency('cairo')
-mupdf = dependency('mupdf', required: false, version: '>=@0@.@1@'.format(mupdf_required_version_major, mupdf_required_version_minor))
+mupdf = cc.find_library('mupdf')
 mupdfthird = cc.find_library('mupdf-third')
 
 build_dependencies = [
@@ -30,41 +30,23 @@ build_dependencies = [
   girara,
   glib,
   cairo,
+  mupdf,
+  mupdfthird
 ]
 
-if not mupdf.found()
-  # normal build of mupdf
-  mupdf = cc.find_library('mupdf', has_headers: ['mupdf/fitz/version.h', 'mupdf/fitz.h', 'mupdf/pdf.h'], required: true)
-  version_check = '''
-#include <mupdf/fitz/version.h>
-
-#if FZ_VERSION_MAJOR < @0@ || (FZ_VERSION_MAJOR == @0@ && FZ_VERSION_MINOR < @1@)
-#error "mupdf @0@.@1@ or newer is requried"
-#endif
-'''.format(mupdf_required_version_major, mupdf_required_version_minor)
-  if not cc.compiles(version_check, dependencies: [mupdf])
-    error('mupdf @0@.@1@ or newer is required'.format(mupdf_required_version_major, mupdf_required_version_minor))
-  endif
-
-  build_dependencies += [mupdf, mupdfthird]
-else
-  # build from Debian's libmupdf-dev
-  build_dependencies += [mupdf, mupdfthird]
-
+if get_option('link-external')
   libjpeg = dependency('libjpeg')
   libjbig2dec = cc.find_library('jbig2dec')
   libopenjp2 = dependency('libopenjp2')
   tesseract = dependency('tesseract')
   leptonica = dependency('lept')
-  mujs = dependency('mujs')
 
   build_dependencies += [
     libjpeg,
     libjbig2dec,
     libopenjp2,
     tesseract,
-    leptonica,
-    mujs
+    leptonica
   ]
 endif
 
diff --git a/meson_options.txt b/meson_options.txt
index c8df610..db9d0c5 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,3 +1,9 @@
+option('link-external',
+  type: 'boolean',
+  value: false,
+  description: 'Link external libraries required by mupdf.'
+)
+
 option('plugindir',
   type: 'string',
   value: '',
-- 
2.45.2

openSUSE Build Service is sponsored by