pkgname=readline
_basever=8.3
#_patchlevel=13
#pkgver=${_basever}.${_patchlevel}
pkgver=${_basever}
pkgdesc='GNU readline library'
homepage='https://tiswww.case.edu/php/chet/readline/rltop.html'
license=('GPL-3.0-only')
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://ftp.gnu.org/gnu/readline/${sources[0]}")
md5sums=("25a73bfb2a3ad7146c5e9d4408d9f6cd")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  sed -i '/MV.*old/d' Makefile.in
  sed -i '/{OLDSUFF}/c:' support/shlib-install
  sed -i 's/-Wl,-rpath,[^ ]*//' support/shobj-conf
}

src_build() {
  ./configure --prefix=/usr  \
            --disable-static \
            --with-curses    \
            --docdir=/usr/share/doc/${pkgname}-${pkgver}
  make SHLIB_LIBS="-lncursesw"
}

src_install() {
  make SHLIB_LIBS="-lncursesw" DESTDIR="$pkgdir" install
  install -v -m644 doc/*.{ps,pdf,html,dvi} ${pkgdir}/usr/share/doc/${pkgname}-${pkgver}
}
