#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=autogen
pkgver=5.18.16
pkgrel=05
pkgdesc="A tool designed to simplify the creation and maintenance of programs that contain large amounts of repetitious text"
arch=('x86_64')
url="https://www.gnu.org/software/autogen/"
depends=('guile' 'libxml2' 'perl')
makedepends=('autogen' 'chrpath')
source=(https://ftp.gnu.org/gnu/${pkgname}/rel${pkgver}/${pkgname}-${pkgver}.tar.xz{,.sig}
        guile-3.0.patch
        10_libopts_tarball_perms.diff)

prepare() {
  cd $pkgname-$pkgver
  patch -Np1 -i ${srcdir}/guile-3.0.patch
  # Reproducible man page generation
  export MAN_PAGE_DATE=$(LC_ALL=C date -u -d '@$(SOURCE_DATE_EPOCH)' +%Y-%m-%d)
  patch -Np1 -i ${srcdir}/10_libopts_tarball_perms.diff
  sed -i 's/ -Werror / /' configure
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --prefix=/usr --disable-dependency-tracking
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make check -j1
}

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

  # Remove unrequired RPATH from binaries
  for i in ${pkgdir}/usr/bin/*; do
    if chrpath --list "$i"; then
      chrpath --delete "$i";
    fi
  done
}

#---- license gpg-key sha256sums ----

license=('GPL3')

validpgpkeys=('44A088E295C3A722C450590EC9EF76DEB74EE762'
              '3EEE51D1355B8EC40D9F3122495143D05D0712D1') # Bruce Korb <bkorb@gnu.org>

sha256sums=(f8a13466b48faa3ba99fe17a069e71c9ab006d9b1cfabe699f8c60a47d5bb49a  # autogen-5.18.16.tar.xz
	ac5ce9851d4b925a3f0821d9b24ab40032853e7e30d038a0a0b99e43921ed35f  # autogen-5.18.16.tar.xz.sig
	b8ab403ba6d0bf6d3391fbb24e41ee996eb2161081058e03f53d3340d3e36885  # guile-3.0.patch
	d5fefc17ee1e44783b5340f424f9644d0dca4531b47f2be7c3e58645414729a3) # 10_libopts_tarball_perms.diff


