name=zlib
version=1.3.1
revision=1
tarball_url="https://github.com/madler/zlib/archive/refs/tags/v${version}.tar.gz"
tarball_blake2b="6d15d8f3c8feaf602043bb6e72316ee721c33ef24e110e3bf03fb12eac9703fd29e352268d202ecd2f18b526b4f1dbd90c8046e01ad8e64ddce3e55ad5db513e"
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
}
