%define cross_arch riscv64 %define cross_triplet riscv64-none-elf %define cross_sysroot %{_prefix}/%{cross_triplet}/sys-root %global versionyear 2021 %global versionmonth 04 %global versionday 08 %global debug_package %{nil} Name: %{cross_triplet}-newlib Version: %{versionyear}%{versionmonth}%{versionday} Release: 1%{?dist} Summary: The newlib C Library (%{cross_triplet}) Group: Development/Libraries License: LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ URL: https://github.com/riscv/riscv-gnu-toolchain Source0: riscv-gnu-toolchain-%{versionyear}.%{versionmonth}.%{versionday}.tar.bz2 BuildRequires: %{cross_triplet}-gcc-first BuildRequires: gcc %description %prep %autosetup -n riscv-gnu-toolchain %build export CFLAGS_FOR_TARGET='-g -O2 -ffunction-sections -fdata-sections' cd %{_builddir}/riscv-gnu-toolchain mkdir -p newlib-build cd newlib-build ../riscv-newlib/configure \ --prefix=%{_prefix} \ --mandir=%{_mandir} \ --infodir=%{_infodir} \ --host=%{_target_platform} \ --build=%{_target_platform} \ --target=%{cross_triplet} \ --enable-newlib-io-long-long \ --enable-newlib-register-fini \ --disable-newlib-supplied-syscalls \ --disable-nls make %{?_smp_mflags} export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections' cd %{_builddir}/riscv-gnu-toolchain mkdir -p newlib-nano-build cd newlib-nano-build ../riscv-newlib/configure \ --prefix=%{_prefix} \ --mandir=%{_mandir} \ --infodir=%{_infodir} \ --host=%{_target_platform} \ --build=%{_target_platform} \ --target=%{cross_triplet} \ --disable-newlib-supplied-syscalls \ --enable-newlib-reent-small \ --disable-newlib-fvwrite-in-streamio \ --disable-newlib-fseek-optimization \ --disable-newlib-wide-orient \ --enable-newlib-nano-malloc \ --disable-newlib-unbuf-stream-opt \ --enable-lite-exit \ --enable-newlib-global-atexit \ --enable-newlib-nano-formatted-io \ --disable-nls make %{?_smp_mflags} %install cd %{_builddir}/riscv-gnu-toolchain/newlib-build make DESTDIR=%{buildroot} install cd %{_builddir}/riscv-gnu-toolchain/newlib-nano-build make DESTDIR=%{buildroot}/nano install pushd %{buildroot}/nano for t in `find . -name '*.a'`; do tt=`echo $t|sed -e s,.a$,_nano.a,`; mv $t ../$tt; done popd install -d %{buildroot}/usr/%{cross_triplet}/include/newlib-nano mv %{buildroot}/nano/usr/%{cross_triplet}/include/newlib.h %{buildroot}/usr/%{cross_triplet}/include/newlib-nano/ rm -rf %{buildroot}/nano # Don't any static archive - based on Fedora Project cross-gcc.spec %define __ar_no_strip %{_builddir}/riscv-gnu-toolchain/ar-no-strip %if 0%{?fedora} >= 33 cat > %{__ar_no_strip} << EOF #!/bin/sh args=""; hasfile=0; for arg in "\$@"; do if [[ \$arg != *%{cross_triplet}* ]]; then args="\$args \$arg" if [[ \$arg == *.o ]]; then hasfile=1 fi fi done echo "\$args" if [ \$hasfile -ne 0 ]; then /usr/bin/strip \$args fi EOF %else cat > %{__ar_no_strip} << EOF #!/bin/sh f=\$2 case \$(basename \$f) in *.a) ;; *) %{__strip} \$@ ;; esac EOF %endif chmod +x %{__ar_no_strip} %undefine __strip %define __strip %{__ar_no_strip} # epel cannot seem to handle globs like this: dir/*.{o,a,ld,specs} # this script converts to individual dir/*.ext lines # #!/usr/bin/perl # use warnings; # use strict; # while (<>) { # s|^(.*)/\*\.\{o,a,ld,specs\}\s*$|$1/*.o\n$1/*.a\n$1/*.ld\n$1/*.specs\n|; # print "$_"; # } %files %license riscv-newlib/COPYING riscv-newlib/COPYING.LIB riscv-newlib/COPYING.LIBGLOSS %license riscv-newlib/COPYING3 riscv-newlib/COPYING3.LIB riscv-newlib/COPYING.NEWLIB %doc riscv-newlib/ChangeLog riscv-newlib/MAINTAINERS riscv-newlib/README %dir %{_prefix}/%{cross_triplet} %dir %{_prefix}/%{cross_triplet}/include %dir %{_prefix}/%{cross_triplet}/include/bits %dir %{_prefix}/%{cross_triplet}/include/machine %dir %{_prefix}/%{cross_triplet}/include/newlib-nano %dir %{_prefix}/%{cross_triplet}/include/rpc %dir %{_prefix}/%{cross_triplet}/include/ssp %dir %{_prefix}/%{cross_triplet}/include/sys %dir %{_prefix}/%{cross_triplet}/lib %dir %{_prefix}/%{cross_triplet}/lib/rv32i %dir %{_prefix}/%{cross_triplet}/lib/rv32i/ilp32 %dir %{_prefix}/%{cross_triplet}/lib/rv32ic %dir %{_prefix}/%{cross_triplet}/lib/rv32ic/ilp32 %dir %{_prefix}/%{cross_triplet}/lib/rv32iac %dir %{_prefix}/%{cross_triplet}/lib/rv32iac/ilp32 %dir %{_prefix}/%{cross_triplet}/lib/rv32im %dir %{_prefix}/%{cross_triplet}/lib/rv32im/ilp32 %dir %{_prefix}/%{cross_triplet}/lib/rv32imc %dir %{_prefix}/%{cross_triplet}/lib/rv32imc/ilp32 %dir %{_prefix}/%{cross_triplet}/lib/rv32imac %dir %{_prefix}/%{cross_triplet}/lib/rv32imac/ilp32 %dir %{_prefix}/%{cross_triplet}/lib/rv32imafc %dir %{_prefix}/%{cross_triplet}/lib/rv32imafc/ilp32f %dir %{_prefix}/%{cross_triplet}/lib/rv64imac %dir %{_prefix}/%{cross_triplet}/lib/rv64imac/lp64 %dir %{_prefix}/%{cross_triplet}/lib/rv64imafdc %dir %{_prefix}/%{cross_triplet}/lib/rv64imafdc/lp64d %{_prefix}/%{cross_triplet}/include/*.h #{_prefix}/%{cross_triplet}/include/bits/*.h %{_prefix}/%{cross_triplet}/include/machine/*.h %{_prefix}/%{cross_triplet}/include/newlib-nano/*.h #{_prefix}/%{cross_triplet}/include/rpc/*.h %{_prefix}/%{cross_triplet}/include/ssp/*.h %{_prefix}/%{cross_triplet}/include/sys/*.h %{_prefix}/%{cross_triplet}/lib/*.o %{_prefix}/%{cross_triplet}/lib/*.a %{_prefix}/%{cross_triplet}/lib/*.specs %{_prefix}/%{cross_triplet}/lib/rv32i/ilp32/*.o %{_prefix}/%{cross_triplet}/lib/rv32i/ilp32/*.a %{_prefix}/%{cross_triplet}/lib/rv32i/ilp32/*.specs %{_prefix}/%{cross_triplet}/lib/rv32ic/ilp32/*.o %{_prefix}/%{cross_triplet}/lib/rv32ic/ilp32/*.a %{_prefix}/%{cross_triplet}/lib/rv32ic/ilp32/*.specs %{_prefix}/%{cross_triplet}/lib/rv32iac/ilp32/*.o %{_prefix}/%{cross_triplet}/lib/rv32iac/ilp32/*.a %{_prefix}/%{cross_triplet}/lib/rv32iac/ilp32/*.specs %{_prefix}/%{cross_triplet}/lib/rv32im/ilp32/*.o %{_prefix}/%{cross_triplet}/lib/rv32im/ilp32/*.a %{_prefix}/%{cross_triplet}/lib/rv32im/ilp32/*.specs %{_prefix}/%{cross_triplet}/lib/rv32imc/ilp32/*.o %{_prefix}/%{cross_triplet}/lib/rv32imc/ilp32/*.a %{_prefix}/%{cross_triplet}/lib/rv32imc/ilp32/*.specs %{_prefix}/%{cross_triplet}/lib/rv32imac/ilp32/*.o %{_prefix}/%{cross_triplet}/lib/rv32imac/ilp32/*.a %{_prefix}/%{cross_triplet}/lib/rv32imac/ilp32/*.specs %{_prefix}/%{cross_triplet}/lib/rv32imafc/ilp32f/*.o %{_prefix}/%{cross_triplet}/lib/rv32imafc/ilp32f/*.a %{_prefix}/%{cross_triplet}/lib/rv32imafc/ilp32f/*.specs %{_prefix}/%{cross_triplet}/lib/rv64imac/lp64/*.o %{_prefix}/%{cross_triplet}/lib/rv64imac/lp64/*.a %{_prefix}/%{cross_triplet}/lib/rv64imac/lp64/*.specs %{_prefix}/%{cross_triplet}/lib/rv64imafdc/lp64d/*.o %{_prefix}/%{cross_triplet}/lib/rv64imafdc/lp64d/*.a %{_prefix}/%{cross_triplet}/lib/rv64imafdc/lp64d/*.specs %changelog * Thu Apr 08 2021 Thomas Sailer - 20210408-1 - update