# Maintainer (arch): Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: 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:
#  - remove non-free asm files
#  - remove references to non-free software
#  - remove nag warnings


pkgname=xscreensaver
pkgver=6.04
pkgrel=1
pkgrel+=.parabola1
pkgdesc='Screen saver and locker for the X Window System'
url='https://www.jwz.org/xscreensaver/'
arch=('x86_64')
arch+=(armv7h i686)
license=('BSD')
depends=(
  'gtk2' 'glu' 'xorg-appres' 'libglvnd' 'libjpeg-turbo' 'libjpeg.so'
  'libsystemd.so' 'libx11' 'libxcrypt' 'libcrypt.so' 'libxext' 'libxft' 'libxi'
  'libxinerama' 'libxmu' 'libxrandr' 'libxt' 'libxxf86vm' 'perl-libwww' 'pam'
  'libpam.so' 'glibc' 'glib2' 'gdk-pixbuf2' 'gdk-pixbuf-xlib'
)
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)
source+=(remove_bsod.patch
         remove-nagging.patch)
sha512sums=('7e8f01853b3d9252ce0120894db7dd4fa3cd19114602a09aa770ec750e2f3742585ca4daf19b009e97386f8c0e3cc89330fe760148c6388f41de8cc1f48f8071'
            '863c699479b2ec2775a0d1cba22e615929194a14af164b3513e46a0c04229da6547255a4da8f7f1bbb40906898c124ed3c9ec2436b76b62affcb62385af9783e')
sha512sums+=('1b63c91ae8ef74b9fe34ddf098620299fcf791140468240eeebbdc00a1d34f176d3a67ba90b942bfece0c76c2239eea02d86b5405e5397c7cff6e021c5bf72e3'
             'da0d2dc10fda9e95950269367ff8b275c8262036e2d1302918c313a0bff79c35cacbb818c8f7b77b7b1f9d05aec91ecfaa78049d4dabb7c400aabeeb9af55b68')
b2sums=('42411d5f63a99d4aaccbc3bc34f8c31a1f25f1806eaf513a1ba59c2f24722e27fa2a7b1970c82a591502627224c4b4269176bda3475aba58bb945d5cd9a9464b'
        'cacb6ba39d6ecb8703ef5f5a7dc74de0ca805cce73b43a8b9b6b4c255c909aa9b5e692de76c2fbd4da26ce6efb5f2a46138c43b1b37f53cee6d20fd6ed41f4a9')
b2sums+=('1152d9141f994bb1494a4583460529ff607d3cb1ab5b53e8f2fa65d1bf9c9552c4d8e246dc5ce28c6e63735b46234baad6768d89c85c159f0ff089da66cc319a'
         '607040a87be8b1dbefb3fa4897de33f2f712946a68bf4e5af90888b1783bca40bfd2cf5365ec75bfc61e71c09abcb95b59406501e7659cebf12cdae29592e326')


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 references to non-free (Issue #2391)
  echo "applying remove_bsod.patch"
  patch -Nup1 hacks/Makefile.in ../remove_bsod.patch
  rm -v hacks/bsod*

  # remove annoying "this program is too old" messages
  echo "applying remove-nagging.patch"
  patch -Nup1 -i ../remove-nagging.patch
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib \
    --without-setuid-hacks \
    --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}"
  echo "NotShowIn=KDE;GNOME;" >> "${pkgdir}/usr/share/applications/xscreensaver-properties.desktop"
}
