description="Libraries for terminal-independent handling of character screens."
url="http://www.gnu.org/software/ncurses/ncurses.html"

packager="Grat-OS Team"
maintainer="Grat-OS Team"

name=ncurses
version=6.4
release=6

source=(http://ftp.gnu.org/gnu/$name/$name-$version.tar.gz)

build() {

  cd ncurses-$version

  sed -i 's@#! /bin/sh@#! /usr/bin/env bash@' configure
  sed -i 's@-/bin/sh}@-/usr/bin/bash}@' configure

  sed -i 's@#! /bin/sh@#! /usr/bin/env bash@' config.sub

  ./configure --prefix=/usr \
              --mandir=/usr/share/man \
              --without-normal \
              --with-shared \
              --without-debug \
              --with-pkg-config-libdir=/usr/lib/pkgconfig \
              --enable-pc-files \
              --enable-widec \
              --with-install-prefix=$PKG

  make
  make install

  for lib in ncurses form panel menu ; do \
    rm -vf                    $PKG/usr/lib/lib${lib}.so
    echo "INPUT(-l${lib}w)" > $PKG/usr/lib/lib${lib}.so
    ln -sfv ${lib}w.pc        $PKG/usr/lib/pkgconfig/${lib}.pc
  done

  rm -vf                     $PKG/usr/lib/libcursesw.so
  echo "INPUT(-lncursesw)" > $PKG/usr/lib/libcursesw.so
  ln -sfv libncurses.so      $PKG/usr/lib/libcurses.so

  mkdir -p $PKG/usr/share/doc/$name-$version
  cp -v -R doc -T $PKG/usr/share/doc/$name-$version

  make distclean

  ./configure --prefix=/usr         \
              --with-shared         \
              --without-normal      \
              --without-debug       \
              --without-cxx-binding \
              --with-abi-version=5

  make sources libs
  cp -av lib/lib*.so.5* $PKG/usr/lib
}
