# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor: Xu Fasheng <fasheng.xu[AT]gmail.com>

pkgname=deepin-wm
pkgver=1.9.38
pkgrel=2
pkgdesc='Deepin Window Manager'
arch=('x86_64')
url="https://github.com/linuxdeepin/deepin-wm"
license=('GPL3')
depends=('bamf' 'clutter-gtk' 'deepin-desktop-schemas' 'deepin-menu' 'granite' 'deepin-mutter'
         'gnome-desktop' 'libgee')
makedepends=('gnome-common' 'intltool' 'vala')
source=("$pkgname-$pkgver.tar.gz::https://github.com/linuxdeepin/deepin-wm/archive/$pkgver.tar.gz"
        vala-0.46.diff)
sha512sums=('3eb4e47856611e0dc257ab079eff3166ed643aa8b55686519c917c3184cd5f238d01c3c8960d715a81264ff1337aa5d7c809a6559eab82e9decb1b9b8a33917d'
            '408db4f180b241e2e5982e1945546d7e4c731d1c7a748b6949257175652048986b6dccfdadae49c82462e25e69e212b03b0af89ec2b370be60c0b64f2b0abe19')

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ../vala-0.46.diff
  sed -i 's#/usr/share/backgrounds/default_background.jpg#/usr/share/backgrounds/deepin/desktop.jpg#' src/Background/BackgroundSource.vala
}

build() {
  export CFLAGS="$CFLAGS -DWNCK_I_KNOW_THIS_IS_UNSTABLE"

  cd $pkgname-$pkgver
  ./autogen.sh \
    --prefix='/usr' \
    --disable-schemas-compile
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}
