File gcc14.spec of Package gcc14

%define realver  14.2.0

%bcond_with    test
%bcond_with    tmpfs

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

# See libgo/VERSION
%define libgo_ver       1.18
# See gcc/d/dmd/VERSION
%define d_ver           2.108.0

%define cc_so_ver        0
%define stdc_so_ver      6

%define atomic_so_ver    1
%define gfortran_so_ver  5
%define go_so_ver        23
%define gomp_so_ver      1
%define objc_so_ver      4
%define quadmath_so_ver  0

# Sanitizers
# See libsanitizer/*san/libtool-version
%define asan_so_ver      8
%define hwasan_so_ver    0
%define lsan_so_ver      0
%define tsan_so_ver      2
%define ubsan_so_ver     1

# D lang libs
# See grep libtool_VERSION libphobos/configure.ac
%define druntime_so_ver  5
%define phobos_so_ver    5

%define slibdir %{_libdir}

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

# Common info
Name:          gcc
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       GPL-3.0+
Group:         Development/Languages/C and C++
URL:           http://gcc.gnu.org/
Summary:       The GNU C compiler

# Install-time parameters
Requires:      gcc%{pkgsuff} cpp
Provides:      c_compiler
Provides:      gcc(major) = %{vermajor}

# Build-time parameters
#!BuildIgnore: kernel-debug-devel
BuildRequires: pkg-config xz
BuildRequires: cpp gcc gcc-c++ gdc libstdc++%{?suse_version:6} libstdc++-devel
BuildRequires: zip unzip
BuildRequires: bison flex
BuildRequires: zlib-devel
BuildRequires: libzstd-devel
BuildRequires: xz-devel
BuildRequires: isl-devel
BuildRequires: gmp-devel %{!?suse_version:lib}mpc-devel mpfr-devel >= 3.1.0
# Boehm-gc is required by objc
BuildRequires: libgc-devel
# Tests
%if %{with test}
BuildRequires: autogen
BuildRequires: procps%{?rhel:-ng}
%if 0%{?suse_version}
BuildRequires: timezone
%else
BuildRequires: tzdata
%endif
%endif
%if 0%{?suse_version}
BuildRequires: fdupes
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source:        http://ftp.gnu.org/pub/gnu/gcc/gcc-%{version}/gcc-%{version}.tar.xz

%description
The system GNU C Compiler.

%package -n gcc%{pkgsuff}
Group:         Development/Languages/C and C++
Summary:       GNU C Compiler
Provides:      libquadmath-devel = %{version}-%{release}
Obsoletes:     libquadmath-devel < %{version}-%{release}
Requires:      binutils glibc-devel cpp%{pkgsuff}
Requires:      libasan%{asan_so_ver}         = %{version}-%{release}
Requires:      libatomic%{atomic_so_ver}     = %{version}-%{release}
Requires:      libgomp%{gomp_so_ver}         = %{version}-%{release}
Requires:      libhwasan%{hwasan_so_ver}     = %{version}-%{release}
Requires:      liblsan%{lsan_so_ver}         = %{version}-%{release}
Requires:      libtsan%{tsan_so_ver}         = %{version}-%{release}
Requires:      libquadmath%{quadmath_so_ver} = %{version}-%{release}
Requires:      libubsan%{ubsan_so_ver}       = %{version}-%{release}
Conflicts:     gcc < %{version}-%{release}

%description -n gcc%{pkgsuff}
The system GNU C Compiler.

%package -n libgcc%{!?rhel:_s1}
Group:         System/Base
Summary:       C compiler runtime library
Provides:      libgcc%{?rhel:_s1} = %{version}-%{release}

%description -n libgcc%{!?rhel:_s1}
Libgcc is needed for dynamically linked C programs.

%package c++
Group:         Development/Languages/C and C++
Summary:       GNU C++ Compiler
Provides:      c++_compiler
Requires:      %{name} = %{version}-%{release}
Requires:      gcc%{pkgsuff}-c++ = %{version}-%{release}
Requires:      libstdc++-devel = %{version}-%{release}

%description c++
The system GNU C++ Compiler.

%package -n gcc%{pkgsuff}-c++
Group:         Development/Languages/C and C++
Summary:       GNU C++ Compiler
Requires:      gcc%{pkgsuff} = %{version}-%{release}
Requires:      libstdc++%{pkgsuff}-devel = %{version}-%{release}
Conflicts:     gcc-c++ < %{version}-%{release}

%description -n gcc%{pkgsuff}-c++
The system GNU C++ Compiler.

%package -n cpp
Group:         Development/Languages/C and C++
Summary:       GNU C/C++ Preprocessor
Requires:      cpp%{pkgsuff}

%description -n cpp
The system GNU C/C++ Preprocessor.

%package -n cpp%{pkgsuff}
Group:         Development/Languages/C and C++
Summary:       GNU C/C++ Preprocessor
Conflicts:     cpp < %{version}-%{release}

%description -n cpp%{pkgsuff}
The system GNU C/C++ Preprocessor.

%package -n gdc
Group:         Development/Languages/D
Summary:       The GNU D Compiler
Requires:      gdc%{pkgsuff}
Provides:      gcc-gdc = %{version}-%{release}
Provides:      gdc = %{d_ver}
%if 0%{?rhel}
Obsoletes:     gcc-gdc < %{version}-%{release}
%endif

%description -n gdc
GDC is a GPL implementation of the D compiler which integrates the open
source D front end with GCC.

%package -n gdc%{pkgsuff}
Group:         Development/Languages/D
Summary:       The GNU D Compiler
Provides:      gcc%{pkgsuff}-gdc
Requires:      libgphobos%{phobos_so_ver}
Requires:      libgdruntime%{druntime_so_ver}

%description -n gdc%{pkgsuff}
GDC is a GPL implementation of the D compiler which integrates the open
source D front end with GCC.

%package %{?rhel:g}fortran
Group:         Development/Languages/Fortran
Summary:       GNU Fortran compiler
Requires:      gcc%{pkgsuff}-%{?rhel:g}fortran

%description %{?rhel:g}fortran
The GNU Fortran compiler.

%package -n gcc%{pkgsuff}-%{?rhel:g}fortran
Group:         Development/Languages/Fortran
Summary:       GNU Fortran compiler
Requires:      gcc%{pkgsuff}
Requires:      libgfortran%{gfortran_so_ver}
Conflicts:     gcc-%{?rhel:g}fortran < %{version}-%{release}

%description -n gcc%{pkgsuff}-%{?rhel:g}fortran
The GNU Fortran compiler.

%package go
Group:         Development/Languages/Go
Summary:       Go front-end for GCC
Requires:      gcc%{pkgsuff}-go
Provides:      gccgo
Provides:      go = %{libgo_ver}

%description go
Go front-end for GNU Compiler Collection.

%package -n gcc%{pkgsuff}-go
Group:         Development/Languages/Go
Summary:       Go front-end for GCC
Requires:      gcc%{pkgsuff}
Conflicts:     gcc-go < %{version}-%{release}

%description -n gcc%{pkgsuff}-go
Go front-end for GNU Compiler Collection.

%package objc
Group:         Development/Languages/C and C++
Summary:       GNU Objective C compiler
Requires:      gcc%{pkgsuff}
Requires:      libobjc%{objc_so_ver}

%description objc
GNU Objective C compiler

This is a stub package only for the dependency

%package obj%{!?rhel:-}c++
Group:         Development/Languages/C and C++
Summary:       GNU Objective C++ compiler
Requires:      gcc%{pkgsuff}
Requires:      libobjc%{objc_so_ver}

%description obj%{!?rhel:-}c++
GNU Objective C++ compiler

This is a stub package only for the dependency

%package -n libstdc++%{?suse_version:%stdc_so_ver}
Group:         Development/Languages/C and C++
Summary:       The standard C++ shared library
Provides:      libstdc++%{pkgsuff} = %{version}-%{release}
%if 0%{?suse_version}
Provides:      libstdc++ = %{version}-%{release}
Obsoletes:     libstdc++ < %{version}-%{release}
%endif

%description -n libstdc++%{?suse_version:%stdc_so_ver}
The standard C++ library, needed for dynamically linked C++ programs.

%package -n libstdc++-devel
Group:         Development/Languages/C and C++
Summary:       Include Files and Libraries mandatory for Development
Requires:      libstdc++%{pkgsuff}-devel = %{version}-%{release}

%description -n libstdc++-devel
This package contains all the headers and libraries of the standard C++
library. It is needed for compiling C++ code.

%package -n libstdc++%{pkgsuff}-devel
Group:         Development/Languages/C and C++
Summary:       Include Files and Libraries mandatory for Development
Provides:      libstdc++%{?suse_version:%stdc_so_ver}-devel = %{version}-%{release}
Requires:      libstdc++%{?suse_version:%stdc_so_ver} = %{version}-%{release}

%description -n libstdc++%{pkgsuff}-devel
This package contains all the headers and libraries of the standard C++
library. It is needed for compiling C++ code.

%package -n libasan%{asan_so_ver}
Group:         Development/Languages/C and C++
URL:           https://github.com/google/sanitizers
Summary:       The Address Sanitizer for GNU Compiler Collection
Provides:      libasan = %{version}-%{release}

%description -n libasan%{asan_so_ver}
The Address Sanitizer for GNU Compiler Collection.

%package -n libatomic%{atomic_so_ver}
Group:         Development/Languages/C and C++
Summary:       GNU Atomic Library (libatomic)
Provides:      libatomic = %{version}-%{release}
%if 0%{?rhel}
Obsoletes:     libatomic < %{version}-%{release}
%endif

%description -n libatomic%{atomic_so_ver}
GNU Atomic Library (libatomic) from GNU Compiler Collection.

%package -n libcc1-%{cc_so_ver}
Group:         Development/Languages/C and C++
Summary:       The C preprocessing library
Provides:      libcc1 = %{version}-%{release}
Provides:      gcc-gdb-plugin = %{version}-%{release}
Obsoletes:     gcc-gdb-plugin < %{version}-%{release}

%description -n libcc1-%{cc_so_ver}
The C preprocessing library from GNU Compiler Collection.

%package -n libgdruntime%{druntime_so_ver}
License:       BSL-1.0
Group:         Development/Languages/Other
URL:           https://github.com/dlang/druntime/
Summary:       Runtime library for GNU D Programming Language
Provides:      libgdruntime = %{version}-%{release}

%description -n libgdruntime%{druntime_so_ver}
DRuntime is the low-level runtime library backing the D programming language.

%package -n libgfortran%{gfortran_so_ver}
Group:         Development/Languages/Fortran
Summary:       Runtime library for GNU Fortran
Provides:      libgfortran = %{version}-%{release}
%if 0%{?rhel}
Obsoletes:     libgfortran < %{version}-%{release}
%endif

%description -n libgfortran%{gfortran_so_ver}
Runtime library for GNU Fortran.

%package -n libgo%{go_so_ver}
Group:         Development/Languages/Go
Summary:       Go runtime library
Provides:      libgo = %{libgo_ver}

%description -n libgo%{go_so_ver}
Go runtime library.

%package -n libgomp%{gomp_so_ver}
Group:         Development/Languages/C and C++
Summary:       OpenMP runtime library
Provides:      libgomp = %{version}-%{release}
%if 0%{?rhel}
Obsoletes:     libgomp < %{version}-%{release}
%endif

%description -n libgomp%{gomp_so_ver}
OpenMP runtime library for GNU Compiler Collection.

%package -n libgphobos%{phobos_so_ver}
License:       BSL-1.0
Group:         Development/Languages/D
Summary:       D language runtime library
Provides:      libgphobos = %{version}-%{release}
Provides:      libgphobos%{phobos_so_ver} = %{d_ver}
Provides:      libgphobos = %{d_ver}

%description -n libgphobos%{phobos_so_ver}
Phobos is the standard runtime library that comes with the D language compiler.

%package -n libhwasan%{hwasan_so_ver}
Group:         Development/Languages/C and C++
URL:           https://github.com/google/sanitizers
Summary:       The Hardware-assisted Address Sanitizer for GNU Compiler Collection
Provides:      libhwasan = %{version}-%{release}

%description -n libhwasan%{hwasan_so_ver}
The Hardware-assisted Address Sanitizer for GNU Compiler Collection.

%package -n liblsan%{lsan_so_ver}
Group:         Development/Languages/C and C++
Summary:       The Leak Sanitizer for GNU Compiler Collection
Provides:      liblsan = %{version}-%{release}

%description -n liblsan%{lsan_so_ver}
The Leak Sanitizer for GNU Compiler Collection.

%package -n libtsan%{tsan_so_ver}
Group:         Development/Languages/C and C++
URL:           https://github.com/google/sanitizers
Summary:       The Thread Sanitizer for GNU Compiler Collection
Provides:      libtsan = %{version}-%{release}

%description -n libtsan%{tsan_so_ver}
The Thread Sanitizer for GNU Compiler Collection.

%package -n libobjc%{objc_so_ver}
Group:         Development/Libraries/C and C++
Summary:       Runtime library for GNU ObjectiveC
Provides:      libobjc = %{version}-%{release}

%description -n libobjc%{objc_so_ver}
Runtime library for GNU ObjectiveC.

%package -n libquadmath%{quadmath_so_ver}
Group:         Development/Languages/C and C++
Summary:       The GCC Quad-Precision Math Library
Provides:      libquadmath = %{version}-%{release}
Obsoletes:     libquadmath < %{version}-%{release}

%description -n libquadmath%{quadmath_so_ver}
The GCC Quad-Precision Math Library.

%package -n libubsan%{ubsan_so_ver}
Group:         Development/Languages/C and C++
Summary:       The Undefined Behavior Sanitizer for GNU Compiler Collection
Provides:      libubsan = %{version}-%{release}

%description -n libubsan%{ubsan_so_ver}
UndefinedBehaviorSanitizer (ubsan), a fast undefined behavior detector, can be
enabled via -fsanitize=undefined. Various computations will be instrumented to
detect undefined behavior at runtime.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n gcc-%{version}
# libsanitizer doesn't support build with -fexceptions
sed -ri 's/(\$\(CXXFLAGS\))/\1 -fno-exceptions/' libsanitizer/Makefile.in
# Use shared libphobos
sed -ri 's/-static-libphobos/-shared-libphobos/' gcc/d/Make-lang.in

%build
_CFLAGS='%{optflags} -pthread -Wno-error=unused-variable'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -pthread -L/lib -L%{_prefix}/lib -ldl'
%if %{with tmpfs}
%{__mkdir} /dev/shm/build
ln -s /dev/shm/build
%else
%{__mkdir} build
%endif
SRCDIR=$(pwd -P)
cd build
$SRCDIR/configure \
 --prefix=%{_prefix} \
 --libdir=%{_libdir} \
 --libexecdir=%{_libdir} \
 --mandir=%{_mandir} \
 --infodir=%{_datadir}/info \
 \
 --program-suffix=-%{verminor} \
 \
 --build=%{_target_platform} \
 \
 --enable-bootstrap \
 --enable-lto \
 --enable-languages=c,c++,d,fortran,go,lto,objc \
 --enable-stage1-languages=c,c++ \
 --enable-objc-gc \
 --disable-stage1-checking \
 --enable-host-shared \
 \
 --enable-checking=release \
 --disable-multilib \
 --enable-__cxa_atexit \
 --enable-threads \
 --disable-werror \
 --disable-rpath \
 --enable-linker-build-id \
 --enable-plugin \
 --enable-default-pie \
 --with-gxx-include-dir=%{_includedir}/c++/%{verminor} \
 --with-system-zlib \
 \
 --disable-libssp \
 --disable-libitm \
 \
 --enable-libphobos \
 \
 --with-slibdir=%{slibdir} \
 --without-system-libunwind \
 \
 --with-target-system-zlib=yes \
 \
 CFLAGS="$_CFLAGS -fPIC" \
 CXXFLAGS="$_CFLAGS -fPIC" \
 LDFLAGS="$_LDFLAGS" \
 BOOT_CFLAGS="$_CFLAGS" \
 BOOT_CXXFLAGS="$_CFLAGS" \
 BOOT_LDFLAGS="$_LDFLAGS" \
 CFLAGS_FOR_TARGET="$_CFLAGS -fPIC" \
 CXXFLAGS_FOR_TARGET="$_CFLAGS -fPIC" \
 LDFLAGS_FOR_TARGET="$_LDFLAGS" \
 || cat config.log
if [ -f Makefile ]; then
  export LD_LIBRARY_PATH=$(pwd -P)/prev-%{_target_platform}/libphobos/src/.libs
  %{__make} %{?_smp_mflags} || exit 1
else
  exit 1
fi

%install
%{__make} -C build install DESTDIR=%{buildroot}
%{__ln_s} c++-%{verminor}            %{buildroot}%{_bindir}/c++
%{__ln_s} g++-%{verminor}            %{buildroot}%{_bindir}/g++
%{__ln_s} cpp-%{verminor}            %{buildroot}%{_bindir}/cpp
%{__ln_s} gcc-%{verminor}            %{buildroot}%{_bindir}/cc
%{__ln_s} gcc-%{verminor}            %{buildroot}%{_bindir}/gcc
%{__ln_s} gcc-ar-%{verminor}         %{buildroot}%{_bindir}/gcc-ar
%{__ln_s} gcc-nm-%{verminor}         %{buildroot}%{_bindir}/gcc-nm
%{__ln_s} gcc-ranlib-%{verminor}     %{buildroot}%{_bindir}/gcc-ranlib
%{__ln_s} gccgo-%{verminor}          %{buildroot}%{_bindir}/gccgo
%{__ln_s} gcov-%{verminor}           %{buildroot}%{_bindir}/gcov
%{__ln_s} gcov-dump-%{verminor}      %{buildroot}%{_bindir}/gcov-dump
%{__ln_s} gcov-tool-%{verminor}      %{buildroot}%{_bindir}/gcov-tool
%{__ln_s} gdc-%{verminor}            %{buildroot}%{_bindir}/gdc
%{__ln_s} gfortran-%{verminor}       %{buildroot}%{_bindir}/gfortran
%{__ln_s} lto-dump-%{verminor}       %{buildroot}%{_bindir}/lto-dump
# Delete broken symlinks
find -L %{buildroot} -type l -delete -print
# Add some new symlinks
%{__install} -d -m755 %{buildroot}%{_prefix}/lib/bfd-plugins
%{__ln_s} %{_libdir}/gcc/%{_target_platform}/%{version}/liblto_plugin.so %{buildroot}%{_prefix}/lib/bfd-plugins/
%{__ln_s} %{verminor} %{buildroot}%{_includedir}/c++/%{version}
# Go binaries will be chosen by update-alternatives
%{__install} -d -m755 %{buildroot}%{_sysconfdir}/alternatives/
touch %{buildroot}%{_sysconfdir}/alternatives/{go,gofmt}
%{__ln_s} -f %{_sysconfdir}/alternatives/{go,gofmt} %{buildroot}%{_bindir}/
%{__mv} -f %{buildroot}%{_includedir}/c++/%{verminor}/%{_target_platform}/bits/* %{buildroot}%{_includedir}/c++/%{verminor}/bits/
%find_lang %{name}
%find_lang cpplib    cpplib.lang
%find_lang libstdc++ libstdc++.lang
mkdir libstdc++-devel-README || :
echo "This is a dummy package to provide a dependency on the system compiler." > libstdc++-devel-README/README
for man in %{buildroot}%{_mandir}/man1/*-%{verminor}.1*; do
  gzip ${man}
  %{__ln_s} `basename ${man}`.gz ${man%%-%{verminor}.1}.1.gz
done
# Go manpages will be chosen by update-alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/{go,gofmt}.1.gz
%{__ln_s} -f %{_sysconfdir}/alternatives/{go,gofmt}.1.gz %{buildroot}%{_mandir}/man1/
%if 0%{?suse_version}
%fdupes %{buildroot}%{_includedir}
%endif
# Remove libtool descriptions
find %{buildroot} -name "*.la" | xargs -n20 rm -f
# Shared library should have execution bit enabled for correct dependency generation
%{__chmod} -c a+x %{buildroot}%{slibdir}/libgcc_s.so.*

%check
%if %{with test}
%{__make} -C build %{?_smp_mflags} -k check
%else
echo 'Testing skipped'
%endif

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

%files
%defattr(-,root,root)
%{_bindir}/cc
%{_bindir}/gcc
%{_bindir}/gcc-ar
%{_bindir}/gcc-nm
%{_bindir}/gcc-ranlib
%{_bindir}/gcov
%{_bindir}/gcov-dump
%{_bindir}/gcov-tool
%{_bindir}/lto-dump
%{_mandir}/man1/gcc.1*
%{_mandir}/man1/gcov.1*
%{_mandir}/man1/gcov-dump.1*
%{_mandir}/man1/gcov-tool.1*
%{_mandir}/man1/lto-dump.1*
%{_mandir}/man7/*

%files c++
%defattr(-,root,root)
%{_bindir}/c++
%{_bindir}/g++
%{_mandir}/man1/g++.1*

%files -n cpp
%defattr(-,root,root)
%{_bindir}/cpp
%{_mandir}/man1/cpp.1*

%files -n gdc
%defattr(-,root,root)
%{_bindir}/gdc
%{_mandir}/man1/gdc.1*

%files %{?rhel:g}fortran
%defattr(-,root,root)
%{_bindir}/gfortran
%doc %{_mandir}/man1/gfortran.1*

%files -n gcc%{pkgsuff} -f %{name}.lang
%defattr(-,root,root)
%doc COPYING* MAINTAINERS NEWS README
%{_bindir}/gcc-%{verminor}
%{_bindir}/gcc-ar-%{verminor}
%{_bindir}/gcc-nm-%{verminor}
%{_bindir}/gcc-ranlib-%{verminor}
%{_bindir}/gcov-%{verminor}
%{_bindir}/gcov-dump-%{verminor}
%{_bindir}/gcov-tool-%{verminor}
%{_bindir}/lto-dump-%{verminor}
%exclude %{_bindir}/%{_target_platform}-*
%dir %{_libdir}/gcc/%{_target_platform}/%{version}
%dir %{_libdir}/gcc/%{_target_platform}
%dir %{_libdir}/gcc
%{_libdir}/gcc/%{_target_platform}/%{version}/*
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/cc1
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/cc1plus
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/cgo
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/d21
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/go1
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/f951
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/test2json
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/vet
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/finclude
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/include/d
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/include/objc
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/plugin/include/d
%exclude %{_libdir}/gcc/%{_target_platform}/%{version}/plugin/include/objc
%doc %{_mandir}/man1/gcc-%{verminor}.1*
%doc %{_mandir}/man1/gcov-%{verminor}.1*
%doc %{_mandir}/man1/gcov-dump-%{verminor}.1*
%doc %{_mandir}/man1/gcov-tool-%{verminor}.1*
%doc %{_mandir}/man1/lto-dump-%{verminor}.1*
%exclude %{_mandir}/man7/*
%exclude %{_datadir}/info/*
%exclude %{_libdir}/*.a
%{_libdir}/libsupc++.a
%{_libdir}/*.so
%{_libdir}/*.o
%{_libdir}/*.spec
%{slibdir}/libgcc_s.so
%dir %{_prefix}/lib/bfd-plugins/
%{_prefix}/lib/bfd-plugins/liblto_plugin.so
%exclude %{_libdir}/libgo.*
%exclude %{_libdir}/libstdc++.so
%exclude %{_libdir}/*.so.*
%exclude %{_libdir}/libgphobos.spec

%files -n gcc%{pkgsuff}-c++
%defattr(-,root,root)
%{_bindir}/c++-%{verminor}
%{_bindir}/g++-%{verminor}
%dir %{_libdir}/gcc/%{_target_platform}/%{version}
%dir %{_libdir}/gcc/%{_target_platform}
%{_libdir}/gcc/%{_target_platform}/%{version}/cc1plus
%doc %{_mandir}/man1/g++-%{verminor}.1*

%files -n cpp%{pkgsuff}  -f cpplib.lang
%defattr(-,root,root)
%{_bindir}/cpp-%{verminor}
%{_libdir}/gcc/%{_target_platform}/%{version}/cc1
%dir %{_libdir}/gcc/%{_target_platform}/%{version}
%dir %{_libdir}/gcc/%{_target_platform}
%doc %{_mandir}/man1/cpp-%{verminor}.1*

%files -n gdc%{pkgsuff}
%defattr(-,root,root)
%{_bindir}/gdc-%{verminor}
%{_libdir}/gcc/%{_target_platform}/%{version}/d21
%{_libdir}/gcc/%{_target_platform}/%{version}/include/d/
%{_libdir}/gcc/%{_target_platform}/%{version}/plugin/include/d/
%doc %{_mandir}/man1/gdc-%{verminor}.1*

%files -n gcc%{pkgsuff}-%{?rhel:g}fortran
%defattr(-,root,root)
%{_bindir}/gfortran-%{verminor}
%{_libdir}/gcc/%{_target_platform}/%{version}/f951
%{_libdir}/gcc/%{_target_platform}/%{version}/finclude
%doc %{_mandir}/man1/gfortran-%{verminor}.1*

%files go
%defattr(-,root,root)
%{_bindir}/gccgo
%{_bindir}/go
%{_bindir}/gofmt
%ghost %{_sysconfdir}/alternatives/go
%ghost %{_sysconfdir}/alternatives/gofmt
%doc %ghost %{_sysconfdir}/alternatives/go.1.gz
%doc %ghost %{_sysconfdir}/alternatives/gofmt.1.gz
%doc %{_mandir}/man1/gccgo.1*
%doc %{_mandir}/man1/go.1*
%doc %{_mandir}/man1/gofmt.1*

%files -n gcc%{pkgsuff}-go
%defattr(-,root,root)
%{_bindir}/gccgo-%{verminor}
%{_bindir}/go-%{verminor}
%{_bindir}/gofmt-%{verminor}
%{_libdir}/go
%{_libdir}/libgo.so
%{_libdir}/libgobegin.a
%{_libdir}/libgolibbegin.a
%dir %{_libdir}/gcc/%{_target_platform}/%{version}
%dir %{_libdir}/gcc/%{_target_platform}
%{_libdir}/gcc/%{_target_platform}/%{version}/cgo
%{_libdir}/gcc/%{_target_platform}/%{version}/go1
%{_libdir}/gcc/%{_target_platform}/%{version}/test2json
%{_libdir}/gcc/%{_target_platform}/%{version}/vet
%doc %{_mandir}/man1/gccgo-%{verminor}.1*
%doc %{_mandir}/man1/go-%{verminor}.1*
%doc %{_mandir}/man1/gofmt-%{verminor}.1*

%files objc
%defattr(-,root,root)
%doc README
%{_libdir}/gcc/%{_target_platform}/%{version}/include/objc
%{_libdir}/gcc/%{_target_platform}/%{version}/plugin/include/objc

%files obj%{!?rhel:-}c++
%defattr(-,root,root)
# empty - only for the dependency
%doc README

%files -n libgcc%{!?rhel:_s1}
%defattr(-,root,root)
%attr(0755,root,root) %{slibdir}/libgcc_s.so.*

%files -n libstdc++%{?suse_version:%stdc_so_ver} -f libstdc++.lang
%defattr(-,root,root)
%{_libdir}/libstdc++.so.*
%exclude %{_libdir}/libstdc++.so.*.py*

%files -n libstdc++-devel
%defattr(-,root,root)
# empty - only for the dependency
%doc libstdc++-devel-README/README

%files -n libstdc++%{pkgsuff}-devel
%defattr(-,root,root)
%{_libdir}/libstdc++.so
%{_libdir}/libstdc++fs.a
%dir %{_includedir}/c++
%{_includedir}/c++/%{verminor}
%{_includedir}/c++/%{version}
%dir %{_datadir}/gcc-%{version}/python/libstdcxx/v6
%dir %{_datadir}/gcc-%{version}/python/libstdcxx
%dir %{_datadir}/gcc-%{version}/python
%dir %{_datadir}/gcc-%{version}
%{_datadir}/gcc-%{version}/python/libstdcxx/v6/*.py*
%{_datadir}/gcc-%{version}/python/libstdcxx/*.py*

%files -n libasan%{asan_so_ver}
%defattr(-,root,root)
%{_libdir}/libasan.so.%{asan_so_ver}*

%files -n libatomic%{atomic_so_ver}
%defattr(-,root,root)
%{_libdir}/libatomic.so.%{atomic_so_ver}*

%files -n libcc1-%{cc_so_ver}
%defattr(-,root,root)
%{_libdir}/libcc1.so.%{cc_so_ver}*

%files -n libgdruntime%{druntime_so_ver}
%defattr(-,root,root)
%license libphobos/libdruntime/LICENSE.txt
%{_libdir}/libgdruntime.so.%{druntime_so_ver}*

%files -n libgfortran%{gfortran_so_ver}
%defattr(-,root,root)
%{_libdir}/libgfortran.so.%{gfortran_so_ver}*

%files -n libgo%{go_so_ver}
%defattr(-,root,root)
%{_libdir}/libgo.so.%{go_so_ver}*

%files -n libgomp%{gomp_so_ver}
%defattr(-,root,root)
%{_libdir}/libgomp.so.%{gomp_so_ver}*

%files -n libgphobos%{phobos_so_ver}
%defattr(-,root,root)
%license libphobos/src/LICENSE_1_0.txt
%{_libdir}/libgphobos.so.%{phobos_so_ver}*
%{_libdir}/libgphobos.spec

%files -n libhwasan%{hwasan_so_ver}
%defattr(-,root,root)
%{_libdir}/libhwasan.so.%{hwasan_so_ver}*

%files -n liblsan%{lsan_so_ver}
%defattr(-,root,root)
%{_libdir}/liblsan.so.%{lsan_so_ver}*

%files -n libtsan%{tsan_so_ver}
%defattr(-,root,root)
%{_libdir}/libtsan.so.%{tsan_so_ver}*

%files -n libobjc%{objc_so_ver}
%defattr(-,root,root)
%{_libdir}/libobjc.so.%{objc_so_ver}*
%{_libdir}/libobjc_gc.so.%{objc_so_ver}*

%files -n libquadmath%{quadmath_so_ver}
%defattr(-,root,root)
%{_libdir}/libquadmath.so.%{quadmath_so_ver}*

%files -n libubsan%{ubsan_so_ver}
%defattr(-,root,root)
%{_libdir}/libubsan.so.%{ubsan_so_ver}*

%post   -n gcc%{pkgsuff} -p /sbin/ldconfig
%postun -n gcc%{pkgsuff} -p /sbin/ldconfig

%post   -n libgcc%{!?rhel:_s1} -p /sbin/ldconfig
%postun -n libgcc%{!?rhel:_s1} -p /sbin/ldconfig

%post   -n libstdc++%{?suse_version:%stdc_so_ver} -p /sbin/ldconfig
%postun -n libstdc++%{?suse_version:%stdc_so_ver} -p /sbin/ldconfig

%post   -n libasan%{asan_so_ver} -p /sbin/ldconfig
%postun -n libasan%{asan_so_ver} -p /sbin/ldconfig

%post   -n libatomic%{atomic_so_ver} -p /sbin/ldconfig
%postun -n libatomic%{atomic_so_ver} -p /sbin/ldconfig

%post   -n libcc1-%{cc_so_ver} -p /sbin/ldconfig
%postun -n libcc1-%{cc_so_ver} -p /sbin/ldconfig

%post   -n libgo%{go_so_ver} -p /sbin/ldconfig
%postun -n libgo%{go_so_ver} -p /sbin/ldconfig

%post   -n libgomp%{gomp_so_ver} -p /sbin/ldconfig
%postun -n libgomp%{gomp_so_ver} -p /sbin/ldconfig

%post   -n libgphobos%{phobos_so_ver} -p /sbin/ldconfig
%postun -n libgphobos%{phobos_so_ver} -p /sbin/ldconfig

%post   -n libhwasan%{hwasan_so_ver} -p /sbin/ldconfig
%postun -n libhwasan%{hwasan_so_ver} -p /sbin/ldconfig

%post   -n liblsan%{lsan_so_ver} -p /sbin/ldconfig
%postun -n liblsan%{lsan_so_ver} -p /sbin/ldconfig

%post   -n libtsan%{tsan_so_ver} -p /sbin/ldconfig
%postun -n libtsan%{tsan_so_ver} -p /sbin/ldconfig

%post   -n libquadmath%{quadmath_so_ver} -p /sbin/ldconfig
%postun -n libquadmath%{quadmath_so_ver} -p /sbin/ldconfig

%post   -n libubsan%{ubsan_so_ver} -p /sbin/ldconfig
%postun -n libubsan%{ubsan_so_ver} -p /sbin/ldconfig

%post   -n libgdruntime%{druntime_so_ver} -p /sbin/ldconfig
%postun -n libgdruntime%{druntime_so_ver} -p /sbin/ldconfig

%post   -n libgfortran%{gfortran_so_ver} -p /sbin/ldconfig
%postun -n libgfortran%{gfortran_so_ver} -p /sbin/ldconfig

%post   -n libobjc%{objc_so_ver} -p /sbin/ldconfig
%postun -n libobjc%{objc_so_ver} -p /sbin/ldconfig

%post go
if ! update-alternatives --list go | grep -q %{_bindir}/go-%{verminor}; then
  update-alternatives \
    --install %{_bindir}/go              go         %{_bindir}/go-%{verminor}              25 \
    --slave   %{_bindir}/gofmt           gofmt      %{_bindir}/gofmt-%{verminor}              \
    --slave   %{_mandir}/man1/go.1.gz    go.1.gz    %{_mandir}/man1/go-%{verminor}.1.gz       \
    --slave   %{_mandir}/man1/gofmt.1.gz gofmt.1.gz %{_mandir}/man1/gofmt-%{verminor}.1.gz
fi

%postun go
if [ ! -x %{_bindir}/go-%{verminor} ]; then
  update-alternatives --remove go %{_bindir}/go-%{verminor}
fi

%changelog
openSUSE Build Service is sponsored by