File cross-arm-none-eabi-newlib-bootstrap.spec of Package cross-arm-none-eabi-newlib-bootstrap

#
# spec file for package cross-arm-none-eabi-newlib
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%global target       arm-none-eabi
%global cross_target cross-%{target}
%define bootstrap 1

Name:           %{cross_target}-newlib
Version:        4.5.0
Release:        1
Summary:        C library intended for use on %{target} embedded systems
Group:          Development/Tools
# For a breakdown of the licensing, see NEWLIB-LICENSING 
License:        BSD-2-Clause and BSD-3-Clause and MIT and LGPL-2.0+ and ISC
URL:            http://sourceware.org/newlib/
Source0:        ftp://sourceware.org/pub/newlib/newlib-%{version}.tar.bz2
Source100:      newlib-rpmlintrc
BuildRequires:  %{target}-binutils
BuildRequires:  %{target}-gcc14
%if ! %{bootstrap}
BuildRequires:  %{target}-gcc-c++
%endif
BuildRequires:  texinfo
BuildArch:      noarch
Provides:       %{target}-newlib
Requires:		%{name}-devel = %{version}-%{release}

%description
Newlib is a C library intended for use on embedded systems. It is a
conglomeration of several library parts, all under free software licenses
that make them easily usable on embedded products.

%package nano
Summary:        C library intended for use on %{target} embedded systems
Group:          Development/Tools
Supplements:    %{name}-devel
Provides:       %{target}-newlib-nano
Requires:		%{name} = %{version}-%{release}

%description nano
Newlib is a C library intended for use on embedded systems. It is a
conglomeration of several library parts, all under free software licenses
that make them easily usable on embedded products.
This package contains the size optimised version of newlib.

%package devel
Summary:        Newlib Header Files
Group:          Development/Tools

%description devel
Newlib is a C library intended for use on embedded systems. It is a
conglomeration of several library parts, all under free software licenses
that make them easily usable on embedded products.
This package contains the header files to build libraries against newlib.

%prep
%setup -q -n newlib-cygwin

%build
mkdir build-{newlib,nano}

pushd build-nano
CFLAGS="-g -Os -ffunction-sections -fdata-sections" \
	../configure \
    --prefix=%{_prefix} \
    --libdir=%{_libdir} \
    --mandir=%{_mandir} \
    --infodir=%{_infodir} \
    --target=%{target} \
    --with-gnu-as \
    --with-gnu-ld \
    --enable-interwork \
    --enable-multilib \
    --enable-newlib-reent-small \
    --enable-newlib-nano-malloc \
    --enable-lite-exit \
    --enable-newlib-global-atexit \
    --enable-newlib-nano-formatted-io \
    --enable-newlib-io-c99-formats \
    --enable-target-optspace \
    --enable-libstdcxx \
    --disable-nls \
    --disable-libssp \
    --disable-newlib-fvwrite-in-streamio \
    --disable-newlib-fseek-optimization \
    --disable-newlib-wide-orient \
    --disable-newlib-unbuf-stream-opt \
    --disable-newlib-supplied-syscalls \
    --disable-newlib-atexit-dynamic-alloc \
    --disable-newlib-register-fini
%make_build
popd

pushd build-newlib
CFLAGS="-g -O2 -ffunction-sections -fdata-sections" \
	../configure \
    --prefix=%{_prefix} \
    --libdir=%{_libdir} \
    --mandir=%{_mandir} \
    --infodir=%{_infodir} \
    --target=%{target} \
    --with-gnu-as \
    --with-gnu-ld \
    --enable-interwork \
    --enable-multilib \
    --enable-newlib-io-long-long \
    --enable-newlib-register-fini \
    --enable-libstdcxx \
    --disable-nls \
    --disable-libssp \
    --disable-newlib-supplied-syscalls
%make_build
popd

%install
pushd build-nano
make DESTDIR=$RPM_BUILD_ROOT install-target
find "$RPM_BUILD_ROOT" -regex ".*/lib\(c\|g\|rdimon\)\.a" -exec rename .a _nano.a '{}' \;
find "$RPM_BUILD_ROOT%{_prefix}/%{target}/lib/" -regex ".*nano.*" > ../filelist_nano ||:
sed -i s,$RPM_BUILD_ROOT,,g ../filelist_nano
echo "=== NANO FILES ==="
cat ../filelist_nano
popd

pushd build-newlib
make DESTDIR=$RPM_BUILD_ROOT install-target
find "$RPM_BUILD_ROOT%{_prefix}/%{target}/lib/" -type f -not -regex ".*nano.*" > ../filelist_newlib ||:
# should not be necessary
sed -i '/nano/ d' ../filelist_newlib
sed -i s,$RPM_BUILD_ROOT,,g ../filelist_newlib
echo "=== NEWLIB FILES ==="
cat ../filelist_newlib
popd

find "$RPM_BUILD_ROOT%{_prefix}/%{target}/lib/" -type d > directories ||:
sed -i s,$RPM_BUILD_ROOT,"\%dir ",g directories ||:


find $RPM_BUILD_ROOT%{_prefix}/%{target}/lib \( -name "*.a" -or -name "*.o" \) -exec %{target}-objcopy -R \
.comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev \
-R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc '{}' \;

# we don't want these as we are a cross version
rm -r $RPM_BUILD_ROOT%{_infodir} ||:

%files -f filelist_newlib
%defattr(-,root,root,-)

%files nano -f filelist_nano
%defattr(-,root,root,-)

%files devel -f directories
%defattr(-,root,root,-)
%doc COPYING*
%dir %{_prefix}/%{target}
%dir %{_prefix}/%{target}/lib
%{_prefix}/%{target}/include/
openSUSE Build Service is sponsored by