name=readline
version=8.2
revision=1
tarball_url="https://ftp.gnu.org/gnu/readline/readline-${version}.tar.gz"
tarball_blake2b="7974322b9c092a756a79e537df08e8532f8e0fcb598f77732e28287c33ebec9e9837ed88b43334c310892d56a871b423903f0f564def2fbe700a1004f2ae7b18"
source_hostdeps="automake autoconf libtool pkg-config"
imagedeps="patchelf"
hostdeps="gcc autoconf automake libtool pkg-config"
deps="core-libs ncurses"

regenerate() {
    AUTOHEADER=true autoreconf -fvi
}

build() {
    autotools_configure \
        --enable-multibyte \
        --with-curses

    make SHLIB_LIBS="-lncursesw" -j${parallelism}
}

package() {
    make SHLIB_LIBS="-lncursesw" install DESTDIR="${dest_dir}"

    # libraries are created without soname... fix that
    for lib in libhistory.so.8 libreadline.so.8; do
        patchelf --set-soname $lib "${dest_dir}${prefix}/lib/$lib"
    done

    post_package_strip
}
