name=coreutils
version=9.5
revision=1
tarball_url="https://ftp.gnu.org/gnu/coreutils/coreutils-${version}.tar.xz"
tarball_blake2b="6fd3a77697c9e85f31415c6ad66559faf18acc7d346677a89d4a999c2027886551e78842a7283e7b3b44fe8ef2fde04ba2f88df32a7844d5f69d45bcb7a04b6f"
source_imagedeps="gcc gperf"
source_hostdeps="automake autoconf libtool pkg-config"
imagedeps="gcc gperf"
hostdeps="gcc automake autoconf libtool pkg-config"
deps="core-libs tzdata"

regenerate() {
    autotools_recursive_regen

    # Huge hack: coreutils does not compile the build-machine binary make-prime-list
    # using the build-machine compiler. Hence, build and invoke the binary manually here.
    mkdir tmp_build_dir
    cd tmp_build_dir

    ../configure
    make src/make-prime-list
    ./src/make-prime-list 5000 > ../src/primes.h

    cd ..
    rm -rf tmp_build_dir
}

build() {
    cp -rp "${source_dir}"/. ./

        configure_script_path=./configure \
        CFLAGS="-DSLOW_BUT_NO_HACKS $CFLAGS" \
    autotools_configure

    make -j${parallelism}
}

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

    post_package_strip
}
