name=gcc
from_source=gcc-host
revision=1
imagedeps="gcc"
hostdeps="autoconf-2.69 automake libtool pkg-config"
hostrundeps="binutils"
deps="mlibc-headers"

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

    mkdir build && cd build

        CXXFLAGS_FOR_TARGET="$CFLAGS" \
        CFLAGS_FOR_TARGET="$CFLAGS" \
    ../configure \
        --prefix="${prefix}" \
        --target=${OS_TRIPLET} \
        --with-sysroot="${sysroot_dir}" \
        --disable-nls \
        --enable-languages=c,c++,lto \
        --disable-multilib \
        --enable-initfini-array \
        --enable-shared \
        --enable-host-shared

    make -j${parallelism} all-gcc
}

package() {
    cd build
    DESTDIR="${dest_dir}" make install-gcc

    ln -s ${OS_TRIPLET}-gcc "${dest_dir}${prefix}/bin/${OS_TRIPLET}-cc"

        strip_command=strip \
    post_package_strip
}
