# Maintainer (arch): Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Andreas Radke <andyrtr@archlinux.org>
# Contributor: rabyte <rabyte@gmail.com>
# Contributor: Johannes Krampf <wuischke@amule.org>
# Contributor: Bartłomiej Piotrowski <barthalion@gmail.com>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>


# parabola changes and rationale:
#  - remove -privacy search engines
#  - add sodep on 'libjxl'
#  - use versioned source-ball rather than VCS


pkgname=midori
pkgver=9.0
pkgrel=6
pkgrel+=.parabola1
pkgdesc='Lightweight web browser'
pkgdesc+=', without non-privacy search engines'
arch=(x86_64)
arch+=(i686 armv7h)
url=https://astian.org/midori-browser/
license=(LGPL)
depends=(aria2 gcr libarchive libpeas libxss webkit2gtk zeitgeist)
depends+=(libjxl.so)
makedepends=(cmake git gobject-introspection intltool ninja vala)
makedepends=( ${makedepends[*]/git/} )
optdepends=('gst-plugins-base: HTML5 OGG videos support'
            'gst-plugins-good: HTML5 H264 and WebM videos support'
            'gst-libav: HTML5 H264 videos support')
options=(!emptydirs)
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/midori-browser/core/archive/refs/tags/v${pkgver}.tar.gz)
sha256sums=('913a7cba95ddcc3dc5f6b12d861e765d6fa990fe7d4efc3768d3a3567ea460db')

prepare() {
  # symlink VCS dir to source-ball dir - minimize diff
  ln -s core-${pkgver} ${pkgname}

  cd $pkgname

  # Remove non-privacy search engines
  sed -i 's|Duck Duck Go|DuckDuckGo HTML|
          s|duckduckgo[.]com|duckduckgo.com/html|
          \|Yahoo|d
          \|Google|d
         ' core/preferences.vala

  # Use DuckDuckGo HTML
  sed -i 's|duckduckgo[.]com|duckduckgo.com/html|g' core/settings.vala
}

build() {
  mkdir -p build
  cd build
  cmake ../$pkgname \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DCMAKE_C_FLAGS="$CFLAGS -fPIC -w" \
    -DVALA_CFLAGS="$CFLAGS -fPIC -w" \
    -G Ninja
  ninja
}

package() {
  DESTDIR="$pkgdir" ninja -C build install
}

