# Maintainer: Dan Printzell <arch@vild.io>
# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>
# Contributor: Severen Redwood <severen@shrike.me>
# Contributor: Robert Welin <robert.welin@gmail.com>
# Contributorr: dsboger <https://github.com/dsboger>

pkgname=gtkd
pkgver=3.9.0
pkgrel=13
pkgdesc='D bindings for GTK+ and related libraries.'
arch=('x86_64')
url='https://gtkd.org'
license=('LGPL')
depends=('liblphobos' 'gtk3')
makedepends=('ldc')
optdepends=('pango' 'atk' 'gdk-pixbuf2' 'gtksourceview3' 'gstreamer' 'vte3' 'libpeas')
source=("GtkD-$pkgver.tar.gz::https://github.com/gtkd-developers/GtkD/archive/v$pkgver.tar.gz"
        'https://github.com/FFY00/GtkD/commit/5a3aabfc7e253eef7ce727a47c3ea0801776a472.patch'
				'FixBuildingDemos.patch::https://github.com/gtkd-developers/GtkD/commit/323ff96c648882eaca2faee170bd9e90c6e1e9c3.patch')
sha512sums=('ea83322933958fa62883bc5f9d9c37fca78c369f6567b4fd62bd39d5d41b7caaab186752a836904b70c1dd70370d683bf35ae3e9201cac12410356ad4c020b90'
            '78a0e5c565562c0f1b1599909027f5a23202421f8c88155412abb49f7e94334bee6f2f6fdb1057ed091c43432d90ffa10afaf1a866d951a82e6975d096a20183'
            'fbc1836d77baa2051413c4f843370c911cec62de89bf0d263c1a9d7439583ad537cbe4d847eaefe7cee0d04e6c09adb083ef1a9db63a33b5b5a7d74212d1d514')

prepare() {
    cd GtkD-$pkgver

    # https://github.com/gtkd-developers/GtkD/pull/273
    # makefile: fix install path for pkconfig files
    patch -p1 < ../5a3aabfc7e253eef7ce727a47c3ea0801776a472.patch

    # https://github.com/gtkd-developers/GtkD/pull/332
    # Fix building demos with dmd v2.096.0
    patch -p1 < ../FixBuildingDemos.patch
}

build() {
    cd GtkD-$pkgver

    make \
    	DC='ldc' \
    	LDFLAGS="-L=\"$LDFLAGS\"" \
    	libdir='lib/' \
        shared-{gtkd,gtkdgl,sv,gstreamer,vte,peas}
}

check() {
    cd GtkD-$pkgver

    make LDFLAGS='' test
}

package() {
    cd GtkD-$pkgver

    make \
    	prefix='/usr' \
    	libdir='lib/' \
    	DESTDIR="$pkgdir" \
    	install-{shared,headers}-{gtkd,gtkdgl,gtkdsv,gstreamer,vte,peas}
}

