# Description: Lets users edit command lines as they are typed in
# URL: http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
# Maintainer: CRUX System Team, core-ports at crux dot nu
# Arch Maintainer: CRUX-ARM System Team, devel at crux-arm dot nu
# Depends on: ncurses

name=readline
version=6.3.8
release=2
source=(http://ftp.gnu.org/gnu/$name/$name-${version::3}.tar.gz \
        $name-$version.patch.gz inputrc $name-$version-wcwidth.patch)

build() {
  cd $name-${version::3}

  gunzip -c $SRC/$name-$version.patch.gz | patch -p0

  # Don't use rpath for linking the shared libs
  sed -i '117s/-Wl,-rpath,$(libdir)//' support/shobj-conf

   # Patch to avoid wcwidth tests
  patch -i $SRC/$name-$version-wcwidth.patch

  ./configure --build=$CHOST \
              --host=$CTARGET \
              --prefix=/usr
  make -j1 SHLIB_LIBS=-lncurses
  make -j1 DESTDIR=$PKG install

  install -d $PKG/lib
  mv $PKG/usr/lib/lib*.so.* $PKG/lib
  ln -sf ../../lib/libhistory.so.${version:0:3} $PKG/usr/lib/libhistory.so
  ln -sf ../../lib/libreadline.so.${version:0:3} $PKG/usr/lib/libreadline.so

  install -D -m 644 $SRC/inputrc $PKG/etc/inputrc
  rm -r $PKG/usr/share/{doc,info}
}