# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Link Dupont <link@subpop.net>

_pkgname=dbus
pkgname=static-compat-$_pkgname
pkgver=1.14.4
pkgrel=1
pkgdesc="Freedesktop.org message bus system"
url="https://wiki.freedesktop.org/www/Software/dbus/"
arch=(x86_64)
license=(GPL custom)
depends=(static-compat-expat)
makedepends=(static-compat-configure xmlto python yelp-tools git autoconf-archive)
options=(!emptydirs staticlibs)
source=("git+https://gitlab.freedesktop.org/dbus/dbus.git?signed#tag=dbus-$pkgver"
        no-fatal-warnings.diff)
sha256sums=('SKIP'
            'c10395be67e1127a58d7173b587fbbf16f8a8b271c41293558fcf9e27c185478')
validpgpkeys=('DA98F25C0871C49A59EAFF2C4DE8FF2A63C7CC90') # Simon McVittie <simon.mcvittie@collabora.co.uk>

prepare() {
  source static-compat-environment
  cd dbus

  # Allow us to enable checks without them being fatal
  git apply -3 ../no-fatal-warnings.diff

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  source static-compat-environment
  cd dbus
  static-compat-configure \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir="$static_compat_prefix"/lib/dbus-1.0 \
    runstatedir=/run \
    --enable-inotify \
    --disable-audit \
    --disable-systemd \
    --enable-user-session \
    --disable-xml-docs \
    --disable-doxygen-docs \
    --disable-ducktype-docs \
    --disable-shared \
    --enable-static \
    --without-x
  make
}

check() {
  source static-compat-environment
  make -C dbus check
}

package() {
  source static-compat-environment
  DESTDIR="$pkgdir" make -C dbus install
  rm -r "$pkgdir"/{etc,var}
  rm -r "$pkgdir/$static_compat_prefix"/{bin,share/doc}

  # remove -DDBUS_STATIC_BUILD from pc file
  # note: Qt's build script adds this as compiler flag `-D-DDBUS_STATIC_BUILD` which breaks
  #       compilation. There's a patch to cope with the missing define anyways (taken from
  #       mingw-w64 variant) so this should be fine.
  sed -i 's|-DDBUS_STATIC_BUILD||g' "$pkgdir/$static_compat_prefix"/lib/pkgconfig/dbus-1.pc

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 dbus/COPYING
}

# vim:set sw=2 sts=-1 et:
