File avr-libc.spec of Package avr-libc

#
# spec file for package avr-libc
#
# Copyright (c) 2025 SUSE LLC
#
# 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/
#


%define TBversion 2.1.0
%define tvers 2_1_0-release
%define doc_vers %{TBversion}

Name:           avr-libc
Version:        2.1.0
Release:        0
Summary:        The C Runtime Library for AVR Microcontrollers
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
URL:            http://savannah.nongnu.org/projects/avr-libc
Source:         http://savannah.nongnu.org/download/%{name}/%{name}-%{version}.tar.xz
Source2:        http://savannah.nongnu.org/download/%{name}/%{name}-manpages-%{doc_vers}.tar.bz2
Source4:        http://savannah.nongnu.org/download/%{name}/%{name}-user-manual-%{doc_vers}.tar.bz2
Source6:        http://savannah.nongnu.org/download/%{name}/%{name}-user-manual-%{doc_vers}.pdf.bz2
# from http://pgp.mit.edu/pks/lookup?op=vindex&search=0x7E9EADC3030D34EB (Joerg Wunsch)
Source8:        %{name}.keyring
# from ?? - poor man's logic analyzer by 'jw'
Source9:        logicp-1.02.tgz
Source100:      %{name}-rpmlintrc
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  cross-avr-binutils
BuildRequires:  cross-avr-gcc
BuildRequires:  doxygen
BuildRequires:  fdupes
BuildRequires:  findutils
BuildRequires:  libtool
BuildRequires:  netpbm
BuildRequires:  python
Recommends:     avr-example
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# does not depend on host arch. bnc#233520
BuildArch:      noarch

%description
The C runtime library for the AVR family of microcontrollers for use
with the GNU toolset (cross-avr-binutils, cross-avr-gcc, uisp, etc.).

%prep
# %%setup -q -a2 -a4 -b9 -n %{name}-%{name}-%{tvers}
%setup -q -a2 -a4 -b9
cp -a %{SOURCE6} .
bunzip2 %{name}-user-manual-%{doc_vers}.pdf.bz2
./bootstrap
./devtools/gen-avr-lib-tree.sh

%build
export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
./configure --prefix=%{cross_prefix} --host=avr
make %{?_smp_mflags} CC="avr-gcc -pipe" CCAS="avr-gcc -pipe"

%install
make DESTDIR=%{buildroot} install %{?_smp_mflags}

mkdir -p %{buildroot}%{_docdir}/%{name}
cp -pr AUTHORS LICENSE NEWS README.md *.pdf %{buildroot}%{_docdir}/%{name}
cp -pr %{name}-user-manual-%{doc_vers} %{buildroot}%{_docdir}/%{name}/user-manual-%{doc_vers}
# ln -s %{_docdir}/%{name}/user-manual-%{doc_vers} %{buildroot}/%{cross_prefix}/share/doc/%{name}-%{doc_vers}svn/user-manual
# ln -s %{cross_prefix}/share/doc/%{name}-%{doc_vers}svn/examples %{buildroot}%{_docdir}/%{name}
cat >> %{buildroot}%{_docdir}/%{name}/user-manual.html <<EOF
<head><meta http-equiv="Refresh" content="0; user-manual-%{doc_vers}/index.html"></head>
<a href="user-manual-%{doc_vers}/pages.html">user-manual-%{doc_vers}/index.html</a>
EOF

# not yet...
rm -rf %{buildroot}/%{cross_prefix}/share
rm -f %{buildroot}%{_docdir}/%{name}/examples

# do not run brp-strip-debug on our avr-elf objects.
export NO_BRP_STRIP_DEBUG=true

%fdupes %{buildroot}

%check
### selftest ###
cd ../logicp*
## how do we tell the linker that crt*.o is at a nonstandard location?
ln -s $RPM_BUILD_ROOT%cross_prefix/avr/lib/crtatt*.o .
ln -s $RPM_BUILD_ROOT%cross_prefix/avr/lib/avrtiny/crtatt*.o .
ln -s $RPM_BUILD_ROOT%cross_prefix/avr/lib/avr?/crtatm*.o .
make test CFLAGS="-Wall -g -Os -mint8 -I$RPM_BUILD_ROOT%cross_prefix/avr/include/ -L$RPM_BUILD_ROOT%cross_prefix/avr/lib/avr4" CPU=mega8 || true
make test CFLAGS="-Wall -g -Os -mint8 -I$RPM_BUILD_ROOT%cross_prefix/avr/include/ -L$RPM_BUILD_ROOT%cross_prefix/avr/lib/avr4" CPU=mega48 || true
make test CFLAGS="-Wall -g -Os -mint8 -I$RPM_BUILD_ROOT%cross_prefix/avr/include/ -L$RPM_BUILD_ROOT%cross_prefix/avr/lib/avr4" CPU=mega644 || true
make test CFLAGS="-Wall -g -Os -mint8 -I$RPM_BUILD_ROOT%cross_prefix/avr/include/ -L$RPM_BUILD_ROOT%cross_prefix/avr/lib"      CPU=tiny2313 || true
make test CFLAGS="-Wall -g -Os -mint8 -I$RPM_BUILD_ROOT%cross_prefix/avr/include/ -L$RPM_BUILD_ROOT%cross_prefix/avr/lib"      CPU=tiny4313 || true

%files
%defattr (-, root, root)
%doc %{_docdir}/%{name}
%if "%{cross_prefix}" != "/usr"
%dir %{cross_prefix}
%dir %{cross_prefix}/bin
%endif
%{cross_prefix}/avr
%{cross_prefix}/bin/avr-man

%changelog
openSUSE Build Service is sponsored by