# Maintainer (Arch): David Runge <dave@archlinux.org>
# Contributor (Arch): Rob Til Freedmen <rob.til.freedman@gmail.com>
# Maintainer (Arch): Ray Rashif <schiv@archlinux.org>
# Contributor (Arch): tobias <tobias@archlinux.org>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor (Hyperbola): André Silva <emulatorman@hyperbola.info>

# parabola changes and rationale:
#  - removed drumkits recommendation

pkgname=hydrogen
pkgver=1.0.0beta2
_beta=beta2
pkgrel=1
pkgrel+=.parabola1
pkgdesc="An advanced drum machine"
pkgdesc+=", without nonfree drumkits recommendation"
arch=('x86_64')
arch+=('i686' 'armv7h')
license=('GPL2')
groups=('pro-audio')
url="http://www.hydrogen-music.org/"
depends=('gcc-libs' 'glibc' 'hicolor-icon-theme' 'qt5-base' 'qt5-xmlpatterns')
makedepends=('alsa-lib' 'cmake' 'jack' 'ladspa' 'libarchive' 'liblrdf'
'libpulse' 'libsndfile' 'portaudio' 'portmidi' 'python' 'qt5-tools')
checkdepends=('cppunit')
optdepends=('rubberband: Time stretch samples')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/${pkgname}-music/${pkgname}/archive/${pkgver/${_beta}/-${_beta}}.tar.gz")
sha512sums=('8712996adbc820909d1d38ff7d45a2a49ec64c15135d5a99b08b93ebd5a0c05139ce78a317c274059a538eb68031f0f42bb9d22988312c2b9f60fa53c539a242')

prepare() {
  # Change to list with free licensed drumkits only
  sed -i -e 's|www[.]hydrogen-music[.]org/feeds/drumkit_list[.]php|repo.parabola.nu/other/hydrogen-libre/feeds/drumkit_list.php|'\
  $(grep -rlI 'www[.]hydrogen-music[.]org/feeds/drumkit_list[.]php')

  mv -v "${pkgname}-${pkgver/${_beta}/-${_beta}}" "${pkgname}-${pkgver}"
}

build() {
  cd "${pkgname}-${pkgver}"
  cmake -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DWANT_DEBUG=OFF \
        -DWANT_CPPUNIT=ON \
        -DWANT_LRDF=ON \
        -DWANT_PORTAUDIO=ON \
        -DWANT_PORTMIDI=ON \
        -DWANT_PULSEAUDIO=ON \
        -B build \
        -S .
  make VERBOSE=1 -C build
  # update translations
  (
    cd data/i18n
    ./updateTranslations.sh
  )
}

package() {
  depends+=('libarchive.so' 'libasound.so' 'liblo.so' 'libjack.so' 'liblrdf.so'
  'libportaudio.so' 'libportmidi.so' 'libpulse.so' 'libsndfile.so')
  cd "${pkgname}-${pkgver}"
  make DESTDIR="$pkgdir" install -C build
  # docs
  install -vDm 644 {ChangeLog,DEVELOPERS,INSTALL.md,README.md} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim:set ts=2 sw=2 et:
