# poppler 25.02.0 — motor de renderizado PDF (libpoppler.so + libpoppler-qt6.so). Campaña KDE (ADR 0011):
# es el backend de okular (visor de documentos).
#
# CMake + wrapper zig, C++20. Recortado al frontend Qt6: sin QT5/glib/gobject/cpp/utils/tests. Cripto y
# formatos extra OFF por no tener las deps selladas: NSS3/GPGME (firma de PDF), LIBCURL (PDF remoto),
# LIBTIFF, LIBOPENJPEG=none (JPX/JPEG2000 — imágenes JPEG2000 dentro del PDF no renderizan; el resto sí).
# ENABLE_BOOST=OFF (sólo perf del backend Splash). Sustrato: freetype-shared + fontconfig-shared (las
# variantes .so/PIC nuevas; el .a canónico no enlaza en libpoppler.so) + lcms2 + libjpeg-turbo-shared
# (DCTDECODER) + libpng-shared + zlib-shared.
name    = "poppler"
version = "25.02.0"
license = "GPL-2.0-or-later"

[source]
tarball = "https://poppler.freedesktop.org/poppler-25.02.0.tar.xz"
sha256  = "21234cb2a9647d73c752ce4031e65a79d11a511a835f2798284c2497b8701dee"

[build]
compiler = "zig-cc"
target   = "x86_64-linux-musl"
link     = "dynamic"
flags    = []

[build.phases]
configure = '''
ZW="$PWD/.zwrap"; mkdir -p "$ZW"
cat > "$ZW/cc"  <<'W'
#!/bin/sh
a=""; for x in "$@"; do [ "$x" = "-Wl,--fatal-warnings" ] && continue; a="$a $x"; done
exec /opt/zig/zig cc -mcpu=baseline $a
W
cat > "$ZW/cxx" <<'W'
#!/bin/sh
a=""; for x in "$@"; do [ "$x" = "-Wl,--fatal-warnings" ] && continue; a="$a $x"; done
exec /opt/zig/zig c++ -mcpu=baseline $a
W
chmod +x "$ZW/cc" "$ZW/cxx"
cmake -B build -G Ninja -Wno-dev \
  -DCMAKE_C_COMPILER="$ZW/cc" -DCMAKE_CXX_COMPILER="$ZW/cxx" \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr \
  -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF -DBUILD_SHARED_LIBS=ON \
  -DENABLE_QT5=OFF -DENABLE_QT6=ON -DENABLE_GLIB=OFF -DENABLE_GOBJECT_INTROSPECTION=OFF \
  -DENABLE_CPP=OFF -DENABLE_UTILS=OFF -DENABLE_BOOST=OFF \
  -DENABLE_LIBOPENJPEG=none -DENABLE_DCTDECODER=libjpeg -DENABLE_LCMS=ON \
  -DENABLE_LIBCURL=OFF -DENABLE_LIBTIFF=OFF -DENABLE_NSS3=OFF -DENABLE_GPGME=OFF \
  -DBUILD_GTK_TESTS=OFF -DBUILD_QT5_TESTS=OFF -DBUILD_QT6_TESTS=OFF -DBUILD_CPP_TESTS=OFF \
  -DBUILD_MANUAL_TESTS=OFF
'''
compile = "cmake --build build"
install = "DESTDIR=/out cmake --install build"

[deps]
build = ["cmake", "samurai", "python3", "pkgconf", "qtbase", "extra-cmake-modules", "qttools",
  "gettext-tiny", "mesa", "libdrm", "libxkbcommon", "wayland", "dbus",
  "freetype-shared", "fontconfig-shared", "expat", "lcms2",
  "libjpeg-turbo-shared", "libpng-shared", "zlib-shared", "gperf",
  "libX11", "xorgproto", "libXau", "libXdmcp", "libXext", "libXrender", "libXfixes", "libXi",
  "libxcb", "xcb-util", "xcb-util-keysyms", "xcb-util-wm", "xcb-util-image", "xcb-util-renderutil"]
