name=zlib
version=1.3
revision=1
tarball_url="https://github.com/madler/zlib/archive/refs/tags/v${version}.tar.gz"
tarball_blake2b="e663d8041a613b544d76313e61b6340adacb53322422d4b6392455627c80cbac430b9fd0fb4a69e59b0fa110f120d29a1e9513bb37888442cc1b9d5075f47ea6"
imagedeps="patchelf"
hostdeps="gcc pkg-config"
deps="core-libs"

build() {
        prefix="${prefix}" \
        CHOST="${OS_TRIPLET}" \
    ${source_dir}/configure

    make -j${parallelism}
}

package() {
    DESTDIR="${dest_dir}" make install
    # Remove static libraries
    rm -rf "${dest_dir}${prefix}"/lib/*.a

    # libz.so.${version} is created without soname... fix that
    patchelf --set-soname libz.so.${version} "${dest_dir}${prefix}/lib/libz.so.${version}"

    post_package_strip
}
