# Maintainer (Arch): Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor (Arch): Eric Bélanger <eric@archlinux.org>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Contributor: freemor <freemor@freemor.ca>

# parabola changes and rationale:
#  removed nonfree asm files

pkgname=xscreensaver
pkgver=5.44
pkgrel=1
pkgrel+=.parabola1
pkgdesc='Screen saver and locker for the X Window System'
pkgdesc+=", without nonfree asm files"
url='https://www.jwz.org/xscreensaver/'
arch=('x86_64')
arch+=('i686' 'armv7h')
license=('BSD')
depends=('libglade' 'libxmu' 'glu' 'xorg-appres' 'perl-libwww' 'libsystemd.so')
makedepends=('bc' 'intltool' 'libxpm' 'gdm' 'systemd' 'systemd-libs')
optdepends=('gdm: for login manager support')
backup=('etc/pam.d/xscreensaver')
source=(https://www.jwz.org/xscreensaver/${pkgname}-${pkgver}.tar.gz
        LICENSE
        Remove_bsod.patch)
sha512sums=('9d9144dec6f075c2d6a1c3cd45123a98d6d0cd732d6c3e3389e97b3f802b8f8765a188d1e35f97f123ca0a64661ea616b7b710577063c311da3d99d8439f1dae'
            '863c699479b2ec2775a0d1cba22e615929194a14af164b3513e46a0c04229da6547255a4da8f7f1bbb40906898c124ed3c9ec2436b76b62affcb62385af9783e'
            '376370c40c959e4db022cc07382962b2e2f80925b4f9d3c29fbef1dd0788bfe3ab2741b85da52430566398be7430f9f5468fcf0471f79b72de96f451d51b2f90')
b2sums=('102025aa2f57672ed3547f0e9bab989566fb8e50ecae8b9e4078ec5ee5de3cad09fec107695335ef236ad9fe19b2638978366a180a998d77b0ce8a2a5d1ebde3'
        'cacb6ba39d6ecb8703ef5f5a7dc74de0ca805cce73b43a8b9b6b4c255c909aa9b5e692de76c2fbd4da26ce6efb5f2a46138c43b1b37f53cee6d20fd6ed41f4a9'
        '8b2b1986e06d3f07605b4c3fe325aede1b3473fbd22281ff7348584f80d00da8ef415d2730e2d93d565e28fd4a6b9824f290dfa36ea64ba67e95ae8d5df9ae00')

prepare() {
  cd ${pkgname}-${pkgver}
  # Deleting dmsc.asm file due which don't have source code supplied
  rm -v hacks/images/m6502/dmsc.asm
  # Remove BSOD for referneces to non-free (Issue #2391)
  patch -Nup1 hacks/Makefile.in ../Remove_bsod.patch
  rm -v hacks/bsod*
  sed 's|-std=c89||' -i configure.in
  autoreconf -fiv
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib \
    --with-x-app-defaults=/usr/share/X11/app-defaults \
    --with-pam \
    --with-login-manager \
    --with-gtk \
    --with-gl \
    --without-gle \
    --with-pixbuf \
    --with-jpeg
  make
}

package() {
  cd ${pkgname}-${pkgver}
  install -d "${pkgdir}/etc/pam.d"
  make install_prefix="${pkgdir}" install
  install -Dm 644 ../LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  # remove sticky bit
  chmod 755 "${pkgdir}/usr/bin/xscreensaver"
  echo "NotShowIn=KDE;GNOME;" >> "${pkgdir}/usr/share/applications/xscreensaver-properties.desktop"
}
