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

pkgname=nspr
pkgver=4.35
pkgrel=02
pkgdesc="Netscape Portable Runtime"
url="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR"
depends=(glibc sh)
#options=(debug)  # uncomment this line to produce the debug pkg
makedepends=(zip mercurial)
_revision=b563bfc16c887c48b038b7b441fcc4e40a126d3b
source=("hg+https://hg.mozilla.org/projects/nspr#revision=$_revision"
         0001-linux-prefer-GCC-provided-atomics-to-asssembly-imple.patch
         0002-configure.in-Remove-assembly-files-from-build.patch)

pkgver() {
  cd nspr
  hg id -t -r. | sed 's/^NSPR_//;s/_RTM$//;s/_/./g'
}

prepare() {
  cd nspr

  # https://bugzilla.mozilla.org/show_bug.cgi?id=1496426
  # https://gitlab.archlinux.org/archlinux/packaging/packages/nspr/-/merge_requests/1
  patch -Np1 -i ../0001-linux-prefer-GCC-provided-atomics-to-asssembly-imple.patch
  patch -Np1 -i ../0002-configure.in-Remove-assembly-files-from-build.patch

  autoreconf -fvi
}

build() {
  cd nspr
  ./configure \
      --prefix=/usr \
      --libdir=/usr/lib \
      --includedir=/usr/include/nspr \
      --enable-optimize \
      --disable-debug \
      --enable-64bit
  make ${SOURCE_DATE_EPOCH:+
    SH_NOW="${SOURCE_DATE_EPOCH}000000"
    SH_DATE="$(date --utc --date="@$SOURCE_DATE_EPOCH" '+%Y-%m-%d %T')"
  }
}

package() {
  cd nspr
  make DESTDIR="$pkgdir" install
  ln -s nspr.pc "$pkgdir/usr/lib/pkgconfig/mozilla-nspr.pc"

  rm -r "$pkgdir"/usr/include/nspr/md
  rm "$pkgdir"/usr/bin/{compile-et.pl,prerr.properties}
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=(MPL-2.0)

sha256sums=(SKIP
	289aa19bc09e1af9db51109c57f83e2052d348444445fefd4be7c51a5f24b755  # 0001-linux-prefer-GCC-provided-atomics-to-asssembly-imple.patch
	6f1603791f8fbf05afbfa1272c65dc7ebacc9453d234010d1dd105bf96e9efe4) # 0002-configure.in-Remove-assembly-files-from-build.patch

##  d6cc856fcedbb6237bae22c6b783e4fa7fcfb5627bd367dc2774e09b4aae385f  nspr-4.35-02-x86_64.pkg.tar.lz

