# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=sed
pkgver=4.9
pkgrel=1
pkgdesc="GNU stream editor"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/sed"
msys2_references=(
  "anitya: 4789"
  "cpe: cpe:/a:gnu:sed"
)
license=('GPL3')
depends=('libintl' 'sh')
makedepends=('gettext' 'gettext-devel' 'autotools' 'gcc')
source=(https://ftp.gnu.org/pub/gnu/sed/${pkgname}-${pkgver}.tar.xz{,.sig}
        sed-4.4-1.src.patch
        sed-4.4-msys-use-text-mode.patch)
sha256sums=('6e226b732e1cd739464ad6862bd1a1aba42d7982922da7a53519631d24975181'
            'SKIP'
            '12525e7bf4a1b57913d4047a2313f9127f29468193c2b583cfdfa128b4141032'
            'a6cf37f31c11f5fbc6d11fb379a3feabdcbe0606b69941d82449d106299ffbf6')
validpgpkeys=('155D3FC500C834486D1EEA677FD9FCCB000BEEEE')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  patch -p1 -i ${srcdir}/sed-4.4-msys-use-text-mode.patch
  autoreconf -fiv

  patch -p2 -i ${srcdir}/sed-4.4-1.src.patch
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}

  export gl_cv_have_weak=no

  ./configure \
    --prefix=/usr \
    --build=${CHOST}
  make all html
}

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

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
  rm -f ${pkgdir}/usr/lib/charset.alias
}
