File cross-avr-gcc.spec of Package cross-avr-gcc

%define realname gcc
%define realver  11.2.0

%define vermajor %(awk -F. '{printf "%i.%i", $1, $2}' <<< %{realver})
%define pkgsuff  %(awk -F. '{printf "%i%i", $1, $2}' <<< %{realver})

# turn off the generation of debuginfo rpm  (RH9) ??
%global debug_package %{nil}

%define prefix   %_prefix

%define cross_cpu    avr
%define cross_target %{cross_cpu}

%define build_target %{cross_target}
%define platform_dir %{prefix}/%{build_target}
%define platform_ld  %{build_target}-ld

# Common info
Name:          %{?cross_target:cross-%{cross_cpu}-}%{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       GPL-3.0+
Group:         Development/Languages/C and C++
URL:           http://gcc.gnu.org/
Summary:       GNU Compiler Collection for AVR microcontrollers

# Install-time parameters
Requires:      %{?cross_target:cross-%{cross_cpu}-}binutils

# Build-time parameters
#!BuildIgnore: kernel-debug-devel
BuildRequires: %{?cross_target:cross-%{cross_cpu}-}binutils
BuildRequires: pkg-config xz cpp gcc gcc-c++ libstdc++-devel
BuildRequires: zip unzip
BuildRequires: bison flex
BuildRequires: zlib-devel libzstd-devel
BuildRequires: isl-devel
BuildRequires: %{!?suse_version:lib}mpc-devel gmp-devel mpfr-devel
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       http://ftp.gnu.org/pub/gnu/gcc/gcc-%{version}/gcc-%{version}.tar.xz

%description
GNU Compiler Collection for AVR microcontrollers.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}

%build
_CFLAGS='%{optflags}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro'
mkdir build
cd build
../configure \
 --prefix=%{_prefix} \
 --exec-prefix=%{_exec_prefix} \
 --libdir=%{platform_dir}/%{_lib} \
 --libexecdir=%{platform_dir}/lib \
 \
 --program-prefix=%{build_target}- \
 --libdir=%{platform_dir}/%{_lib} \
 --target=%{build_target} \
 \
 --disable-multilib \
 --enable-threads \
 \
 --enable-lto \
 --enable-stage1-languages=c,c++ \
 --enable-languages=c,c++ \
 \
 --with-system-zlib \
 \
 --with-gxx-include-dir=%{_includedir}/c++/%{vermajor} \
 --with-zstd=%{_prefix} \
 \
 --disable-nls \
 \
 CFLAGS="$_CFLAGS" \
 CXXFLAGS="$_CFLAGS" \
 LDFLAGS="$_LDFLAGS" \
 CFLAGS_FOR_TARGET="-Os -DNDEBUG" \
 CXXFLAGS_FOR_TARGET="-Os -DNDEBUG" \
 LDFLAGS_FOR_TARGET="-Wl,--as-needed -Wl,--strip-all" \
 || cat config.log
test -f Makefile && %{__make} %{?_smp_mflags} || exit 1

%install
%{__make} -C build install DESTDIR=%{buildroot}
# Make symlinks
%{__install} -d -m0755 %{buildroot}%{platform_dir}/bin/
for binary in %{buildroot}%{_bindir}/*; do
    binname=${binary##*/}
    %{__ln_s} -fn ../../bin/$binname %{buildroot}%{platform_dir}/bin/${binname#%{build_target}-}
done

%clean
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

%files
%defattr(-,root,root)
%license COPYING*
%doc MAINTAINERS NEWS README
%{_bindir}/*
%{platform_dir}/
%doc %{_mandir}/man1/*
%exclude %{_mandir}/man7/
%exclude %{_datadir}/info/

%post   -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%changelog
openSUSE Build Service is sponsored by