# 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=6.00
pkgrel=2
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=(
  '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
        Remove_bsod.patch)
sha512sums=('7292bacf633137b5c0eb2de9a99dc238b2012a113e62c86d4be19fc2fd4fea7133bd950253ca2d3a4ab27af4b4dc9a40a857e8d3dc714946ccfa7efcd043ded6'
            '863c699479b2ec2775a0d1cba22e615929194a14af164b3513e46a0c04229da6547255a4da8f7f1bbb40906898c124ed3c9ec2436b76b62affcb62385af9783e'
            '1b63c91ae8ef74b9fe34ddf098620299fcf791140468240eeebbdc00a1d34f176d3a67ba90b942bfece0c76c2239eea02d86b5405e5397c7cff6e021c5bf72e3')
b2sums=('228f176915f0f62bc782d43b19c767bd58f72820665ed1c0602fc5f7de4b58898de2c087905fab6bca886452a996985c361e844854dfb864066699db9c4e7235'
        'cacb6ba39d6ecb8703ef5f5a7dc74de0ca805cce73b43a8b9b6b4c255c909aa9b5e692de76c2fbd4da26ce6efb5f2a46138c43b1b37f53cee6d20fd6ed41f4a9'
        '1152d9141f994bb1494a4583460529ff607d3cb1ab5b53e8f2fa65d1bf9c9552c4d8e246dc5ce28c6e63735b46234baad6768d89c85c159f0ff089da66cc319a')

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)
  patch -Nup1 hacks/Makefile.in ../Remove_bsod.patch
  rm -v hacks/bsod*
}

build() {
  cd ${pkgname}-${pkgver}
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib \
    --with-x-app-defaults=/usr/share/X11/app-defaults \
    --without-setuid-hacks \
    --without-setcap-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"
}
