# Maintainer: Martchus <martchus@gmx.net>
# includes the new Qt 5 based GUI

# All my PKGBUILDs are managed at https://github.com/Martchus/PKGBUILDs where
# you also find the URL of a binary repository.

pkgname='mkvtoolnix-git'
pkgver=8483.ee895f4
pkgrel=1
pkgdesc="Set of tools to create, edit and inspect Matroska files - includes the new Qt 5 GUI (instead of the old wxWidegts based)."
arch=('i686' 'x86_64')
license=('GPL')
url="http://www.bunkus.org/videotools/mkvtoolnix"
depends=('libmatroska' 'expat' 'flac' 'libvorbis' 'file' 'boost-libs' 'lzo' 'qt5-base' 'xdg-utils' 'desktop-file-utils')
makedepends=('boost' 'ruby' 'git')
provides=('mkvtoolnix' 'mkvtoolnix-cli' 'mkvtoolnix-gui')
conflicts=('mkvtoolnix')
source=("${pkgname}::git+https://github.com/mbunkus/mkvtoolnix.git")
md5sums=('SKIP')

pkgver() {
  cd "${srcdir}/${pkgname}"
  echo "$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${srcdir}/${pkgname}"

  # Disable automagic curl dep used for online update checking
  sed -i -e '/curl/d' configure.in
  export CURL_CFLAGS="" CURL_LIBS=""

  export CFLAGS="${CFLAGS} -DBOOST_FILESYSTEM_VERSION=3"
  export CXXFLAGS="${CXXFLAGS} -DBOOST_FILESYSTEM_VERSION=3"

  # Sets number of threads for a parallel build
  export DRAKETHREADS=4

  ./autogen.sh
}

build() {
  cd "${srcdir}/${pkgname}"
  # XXX: Temporary define to build against boost 1.58
  # https://github.com/mbunkus/mkvtoolnix/issues/1172
  CXXFLAGS+=' -DBOOST_CODECVT_DO_LENGTH_CONST=const'
  ./configure --prefix=/usr \
              --with-boost-libdir=/usr/lib
  ./drake
}

package() {
  cd "${srcdir}/${pkgname}"
  ./drake DESTDIR="${pkgdir}" install
}
