# tesseract 5.5.0 — motor de OCR (libtesseract.so). Campaña KDE (ADR 0011): spectacle lo exige DURO —
# `pkg_check_modules(TESSERACT REQUIRED IMPORTED_TARGET tesseract)` en CMakeLists:111, sin option() para
# apagarlo (spectacle 6.7 hace OCR del texto de la captura).
#
# Wrapper zig PASS-THROUGH con "$@" (el clásico splitea args con espacios; ver opencv).
# Sólo la lib: sin training tools (piden pango/cairo/icu), sin tests. Dep dura: leptonica.
name    = "tesseract"
version = "5.5.0"
license = "Apache-2.0"

[source]
tarball = "https://github.com/tesseract-ocr/tesseract/archive/refs/tags/5.5.0.tar.gz"
sha256  = "f2fb34ca035b6d087a42875a35a7a5c4155fa9979c6132365b1e5a28ebc3fc11"

[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
exec /opt/zig/zig cc -mcpu=baseline "$@"
W
cat > "$ZW/cxx" <<'W'
#!/bin/sh
exec /opt/zig/zig c++ -mcpu=baseline "$@"
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 \
  -DBUILD_TRAINING_TOOLS=OFF -DBUILD_TESTS=OFF -DDISABLE_CURL=ON -DDISABLE_ARCHIVE=ON \
  -DUSE_SYSTEM_ICU=OFF -DGRAPHICS_DISABLED=ON -DOPENMP_BUILD=OFF
'''
compile = "cmake --build build"
install = "DESTDIR=/out cmake --install build"

[deps]
build = ["cmake", "samurai", "python3", "pkgconf", "leptonica", "zlib-shared", "libpng-shared",
  "libjpeg-turbo-shared"]
