# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: kozec <kozec@kozec.com>
# Contributor: Limao Luo <luolimao+AUR@gmail.com>

pkgname=aegisub
pkgver=3.2.2
pkgrel=35
pkgdesc='A general-purpose subtitle editor with ASS/SSA support'
arch=(x86_64)
url=http://www.aegisub.org
license=(
  GPL
  BSD
)
depends=(
  alsa-lib
  boost-libs
  fftw
  fontconfig
  hunspell
  icu
  libass.so
  libffms2.so
  libgl
  libpulse
  wxgtk3
  zlib
)
makedepends=(
  boost
  git
  intltool
  mesa
)
source=(
  git+https://github.com/Aegisub/Aegisub.git#tag=v${pkgver}
  boost-1.68.patch
  icu59.patch
)
sha256sums=(
  SKIP
  aa1689a2204f6a617000f3380b8dea9c3dca4f500d0643e05172750c49cc5a21
  29d8cc91e73602d5e3c8517c977dcc77cb84af7d42787f510d487d0a6abf7fa6
)

prepare() {
  cd Aegisub

  patch -Np1 -i ../boost-1.68.patch
  sed 's|gil/gil_all.hpp|gil.hpp|g' -i src/*.cpp # boost 1.69
  sed 's/$(LIBS_BOOST) $(LIBS_ICU)/$(LIBS_BOOST) $(LIBS_ICU) -pthread/' -i tools/Makefile # missing link flag
  sed 's/^Exec=/Exec=env GDK_BACKEND=x11 /' -i packages/desktop/aegisub.desktop.template.in # fix running under wayland
  patch -Np1 -i ../icu59.patch

  ./autogen.sh
}

build() {
  cd Aegisub

  # http://site.icu-project.org/download/61#TOC-Migration-Issues
  CPPFLAGS+=' -DU_USING_ICU_NAMESPACE=1'

  ./configure \
    --prefix=/usr \
    --with-wx-config=/usr/bin/wx-config-gtk3 \
    --without-{portaudio,openal,oss} \
    --disable-update-checker
  make
}

package() {
  cd Aegisub

  make DESTDIR="${pkgdir}" install

  install -dm 755 "${pkgdir}"/usr/share/licenses/aegisub
  install -m 644 LICENCE "${pkgdir}"/usr/share/licenses/aegisub/LICENSE
}

# vim: ts=2 sw=2 et:
