# Contributor Ricky Wu <rickleaf.wu@hotmail.com>
# Contributor Unai Martinez-Corral <unai.martinezcorral@ehu.eus>

_realname=gtkwave
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=3.3.124
pkgrel=1
pkgdesc='A wave viewer which reads LXT, LXT2, VZT, GHW and VCD/EVCD files (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://gtkwave.sourceforge.net/'
license=('spdx:GPL-2.0-or-later')
groups=("${MINGW_PACKAGE_PREFIX}-eda")
depends=(
  "${MINGW_PACKAGE_PREFIX}-adwaita-icon-theme"
  "${MINGW_PACKAGE_PREFIX}-bzip2"
  "${MINGW_PACKAGE_PREFIX}-cairo"
  "${MINGW_PACKAGE_PREFIX}-cc-libs"
  "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
  "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
  "${MINGW_PACKAGE_PREFIX}-glib2"
  "${MINGW_PACKAGE_PREFIX}-gtk3"
  "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache"
  "${MINGW_PACKAGE_PREFIX}-pango"
  "${MINGW_PACKAGE_PREFIX}-tcl"
  "${MINGW_PACKAGE_PREFIX}-tcllib"
  "${MINGW_PACKAGE_PREFIX}-tk"
  "${MINGW_PACKAGE_PREFIX}-tklib"
  "${MINGW_PACKAGE_PREFIX}-xz"
  "${MINGW_PACKAGE_PREFIX}-zlib"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-autotools"
  "${MINGW_PACKAGE_PREFIX}-gperf"
  'perlxml'
  'intltool'
)
source=("https://downloads.sourceforge.net/project/${_realname}/${_realname}-gtk3-${pkgver}/${_realname}-gtk3-${pkgver}.tar.gz")
sha256sums=('4b1590e05e3e3ae26e34fa80aff369254397379b2f970cfa99150b8b97e535cf')

build() {
  mkdir "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  CFLAGS+=" -std=gnu17" \
  "${srcdir}"/${_realname}-gtk3-${pkgver}/configure \
    --prefix="${MINGW_PREFIX}" \
    --with-tcl="${MINGW_PREFIX}"/lib \
    --with-tk="${MINGW_PREFIX}"/lib \
    --disable-mime-update \
    --enable-gtk3

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 "${srcdir}"/${_realname}-gtk3-${pkgver}/LICENSE.TXT \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE.TXT
}
