NAME="webkitgtk"
DESC="Port of the portable web rendering engine WebKit to the GTK3 and GTK4 platforms"
VERSION="2.41.91"
FILES=("https://webkitgtk.org/releases/webkitgtk-$VERSION.tar.xz")
HASHES=("1140f86d9044fb76be974b65f71737d7")
DEPENDS=(
  "cairo" "gst-plugins-base" "gst-plugins-bad" 
  "gtk4" "gtk3" "icu" "lcms2" "libgudev" "libsecret" 
  "libsoup" "libtasn1" "mesa" "openjpeg" "ruby" 
  "sqlite" "unifdef" "which" "wpebackend-fdo"
  "bubblewrap" "enchant" "geoclue" "libwebp"
  "hicolor-icon-theme" "libavif" "xdg-dbus-proxy"
  "wayland" "harfbuzz" "woff2"
)

PACKAGE() {
  tar xf $NAME-$VERSION.tar.xz
  cd $NAME-$VERSION

  mkdir -vp build
  cd        build

  cmake -DCMAKE_BUILD_TYPE=Release   \
      -DCMAKE_INSTALL_PREFIX=/usr    \
      -DCMAKE_SKIP_RPATH=ON          \
      -DPORT=GTK                     \
      -DLIB_INSTALL_DIR=/usr/lib     \
      -DUSE_LIBHYPHEN=OFF            \
      -DENABLE_GAMEPAD=OFF           \
      -DENABLE_MINIBROWSER=ON        \
      -DENABLE_DOCUMENTATION=OFF     \
      -DUSE_WOFF2=ON                 \
      -DUSE_GTK4=ON                  \
      -DUSE_JPEGXL=OFF               \
      -DUSE_WPE_RENDERER=ON          \
      -DENABLE_BUBBLEWRAP_SANDBOX=ON \
      -Wno-dev -G Ninja ..
  ninja $MAKEFLAGS && DESTDIR="$ROOTDIR" ninja install

  install -vdm755 "$ROOTDIR"/usr/share/gtk-doc/html/{jsc-glib,webkit2gtk{,-web-extension}}-4.1
  install -vm644  ../Documentation/jsc-glib-4.1/*              \
                "$ROOTDIR"/usr/share/gtk-doc/html/jsc-glib-4.1
  install -vm644  ../Documentation/webkit2gtk-4.1/*            \
                "$ROOTDIR"/usr/share/gtk-doc/html/webkit2gtk-4.1
  install -vm644  ../Documentation/webkit2gtk-web-extension-4.1/* \
                "$ROOTDIR"/usr/share/gtk-doc/html/webkit2gtk-web-extension-4.1

  cd ../.. && rm -r $NAME-$VERSION
}
