File binutils.spec of Package binutils

%define realname binutils
%define realver  2.44
%define srcext   tar.xz

%define ctf_so_ver     0
%define sframe_so_ver  1
%define gprofng_so_ver 0

%define build_target %{_target_platform}
%define platform_dir %{_prefix}/%{build_target}
%define platform_ld  %{_target_platform}-ld

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

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       %{?extraver:0.}1%{?dist}
License:       GFDL-1.3 and GPL-3.0+
Group:         Development/Tools/Building
URL:           http://www.gnu.org/software/binutils/
Summary:       GNU binutils

# Install-time parameters
Requires:      info
Requires:      /usr/sbin/update-alternatives

# Build-time parameters
BuildRequires: pkg-config
BuildRequires: gcc-c++
BuildRequires: bison flex
BuildRequires: gettext
BuildRequires: zlib-devel
BuildRequires: pkgconfig(libzstd) >= 1.4.0
%if 0%{?suse_version}
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source:        http://ftp.gnu.org/gnu/binutils/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
These are the GNU binutils.  These are utilities of use when dealing
with binary files, either object files or executables.  These tools
consist of the linker (ld), the assembler (gas), and the profiler
(gprof) each of which have their own sub-directory named after them.
There is also a collection of other binary tools, including the
disassembler (objdump) in this directory.  These tools make use of a
pair of libraries (bfd and opcodes) and a common set of header files
(include).

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Requires:      %{name} = %{version}-%{release}
Requires:      libctf-nobfd%{?ctf_so_ver} = %{version}-%{release}
Requires:      libctf%{?ctf_so_ver} = %{version}-%{release}
Requires:      libgprofng%{?gprofng_so_ver} = %{version}-%{release}
Requires:      libsframe%{?sframe_so_ver} = %{version}-%{release}
Provides:      libctf-nobfd-devel = %{version}-%{release}
Provides:      libctf-nobfd%{?ctf_so_ver}-devel = %{version}-%{release}
Provides:      libctf-devel = %{version}-%{release}
Provides:      libctf%{?ctf_so_ver}-devel = %{version}-%{release}
Provides:      libgprofng-devel = %{version}-%{release}
Provides:      libgprofng%{?gprofng_so_ver}-devel = %{version}-%{release}
Provides:      libsframe-devel = %{version}-%{release}
Provides:      libsframe%{?sframe_so_ver}-devel = %{version}-%{release}

%description devel
Development files for %{name}

%package -n libctf%{?ctf_so_ver}
Group:         System/Libraries
Summary:       Compact C Type Format

%description -n libctf%{?ctf_so_ver}
The Compact C Type Format (CTF) is a way of representing information about
a binary program; it can be seen as a simpler alternative to the widely used
DWARF format.

This library provides CTF handling.

%package -n libctf-nobfd%{?ctf_so_ver}
Group:         System/Libraries
Summary:       Compact C Type Format (no BFD dependency)

%description -n libctf-nobfd%{?ctf_so_ver}
The Compact C Type Format (CTF) is a way of representing information about
a binary program; it can be seen as a simpler alternative to the widely used
DWARF format.

This library provides CTF handling without BFD dependency.

%package -n libgprofng%{?gprofng_so_ver}
Group:         System/Libraries
Summary:       The next generation GNU application profiling tool

%description -n libgprofng%{?gprofng_so_ver}
Gprofng is the GNU Next Generation profiler for analyzing the performance
of Linux applications. Gprofng allows you to:
  - Profile C / C++ / Java / Scala applications without needing to recompile
  - Profile multi-threaded applications
  - Analyze and compare multiple experiments.
  - Use time-based sampling and / or hardware event counters

%package -n libsframe%{?sframe_so_ver}
Group:         System/Libraries
Summary:       The Simple Frame format

%description -n libsframe%{?sframe_so_ver}
The SFrame unwind information is provided in a loaded section, known as
the '.sframe' section.  When available, the '.sframe' section appears in
a new segment of its own, PT_GNU_SFRAME.

The SFrame format is currently supported only for select ABIs,
namely, AMD64 and AAPCS64.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}
# Do copying instead of hardlinking
sed -i '/DESTDIR/ s/ln /cp /' binutils/Makefile.in
sed -i '/DESTDIR/ s/ln /cp /' gas/Makefile.in
sed -i '/DESTDIR/ s/ln /cp /' ld/Makefile.in

%build
_CFLAGS='%{optflags}'
#_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -pthread'
_LDFLAGS='-Wl,--strip-all -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -pthread'
%configure \
 --target=%{_target_platform} \
 --enable-shared \
 --disable-static \
 --enable-ld \
 --enable-lto \
 --enable-host-shared \
 --enable-objc-gc \
 --with-system-zlib \
 --with-zstd \
 \
 --enable-plugins \
 \
 --enable-threads \
 --with-lib-path=/%{_lib}:%{_libdir} \
 \
 --enable-multilib \
 \
 CFLAGS="$_CFLAGS" \
 CXXFLAGS="$_CFLAGS" \
 LDFLAGS="$_LDFLAGS" \
 || cat config.log
%{__make} %{?_smp_mflags}

%install
%{__make} install DESTDIR=%{buildroot} \
 target_header_dir=%{_includedir}
# Handle file duplicates
for binary in %{buildroot}%{platform_dir}/bin/*; do
    %{__ln_s} -fn ../../bin/${binary##*/} $binary
done
# Prepare alternatives
%{__install} -d -m755 %{buildroot}%{_sysconfdir}/alternatives/
touch %{buildroot}%{_sysconfdir}/alternatives/ld
touch %{buildroot}%{_sysconfdir}/alternatives/%{platform_ld}
%{__ln_s} -f %{_sysconfdir}/alternatives/ld             %{buildroot}%{_bindir}/ld
%{__ln_s} -f %{_sysconfdir}/alternatives/%{platform_ld} %{buildroot}%{platform_dir}/bin/ld
# Fix man(s)
LD_MAN=`find %{buildroot}%{_mandir}/man1/ -name "ld.1*"`
%{__ln_s} -f ${LD_MAN##*/} %{buildroot}%{_mandir}/man1/ld.bfd.1
# Localization
%find_lang %{name}
%find_lang bfd
%find_lang gas
%find_lang gprof
%find_lang ld
%find_lang opcodes
cat bfd.lang gas.lang gprof.lang ld.lang opcodes.lang >> %{name}.lang

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

%files -f %{name}.lang
%defattr(-,root,root)
%license COPYING*
%doc MAINTAINERS binutils/NEWS binutils/README
%config(noreplace)%{_sysconfdir}/gprofng.rc
%{_bindir}/*
%{_libdir}/*.so
%{_libdir}/bfd-plugins/
%{_libdir}/gprofng/
%{platform_dir}/
%doc %{_mandir}/man1/*
%doc %{_infodir}/*.info*
%ghost %{_sysconfdir}/alternatives/ld
%ghost %{_sysconfdir}/alternatives/%{platform_ld}
%if 0%{?rhel}
%exclude %{_infodir}/dir
%endif

# Development stuff
%files devel
%defattr(-,root,root)
%{_includedir}/*.h
%exclude %{_libdir}/*.la

%files -n libctf%{?ctf_so_ver}
%defattr(-,root,root)
%doc libctf/ChangeLog libctf/NEWS
%{_libdir}/libctf.so.%{?ctf_so_ver}*

%files -n libctf-nobfd%{?ctf_so_ver}
%defattr(-,root,root)
%doc libctf/ChangeLog libctf/NEWS
%{_libdir}/libctf-nobfd.so.%{?ctf_so_ver}*

%files -n libgprofng%{?gprofng_so_ver}
%defattr(-,root,root)
%doc gprofng/README
%{_libdir}/libgprofng.so.%{?gprofng_so_ver}*
%exclude %{_datadir}/doc/gprofng/examples.*

%files -n libsframe%{?sframe_so_ver}
%defattr(-,root,root)
%{_libdir}/libsframe.so.%{?sframe_so_ver}*

%post
/sbin/ldconfig
/usr/sbin/update-alternatives \
 --install %{_bindir}/ld ld %{_bindir}/ld.bfd 1 \
   --slave %{platform_dir}/bin/ld %{platform_ld} %{platform_dir}/bin/ld.bfd

/sbin/install-info %{_infodir}/as.info*        %{_infodir}/dir || :
/sbin/install-info %{_infodir}/bfd.info*       %{_infodir}/dir || :
/sbin/install-info %{_infodir}/binutils.info*  %{_infodir}/dir || :
/sbin/install-info %{_infodir}/gprof.info*     %{_infodir}/dir || :
/sbin/install-info %{_infodir}/ld.info*        %{_infodir}/dir || :

%preun
if [ ${1} -eq 0 ]; then
  /sbin/install-info --delete %{_infodir}/as.info*        %{_infodir}/dir || :
  /sbin/install-info --delete %{_infodir}/bfd.info*       %{_infodir}/dir || :
  /sbin/install-info --delete %{_infodir}/binutils.info*  %{_infodir}/dir || :
  /sbin/install-info --delete %{_infodir}/gprof.info*     %{_infodir}/dir || :
  /sbin/install-info --delete %{_infodir}/ld.info*        %{_infodir}/dir || :
fi

%postun
/sbin/ldconfig
if [ ${1} -eq 0 ]; then
  /usr/sbin/update-alternatives --remove ld %{_bindir}/ld.bfd
  /usr/sbin/update-alternatives --auto ld
fi

%post   -n libctf%{?ctf_so_ver} -p /sbin/ldconfig
%postun -n libctf%{?ctf_so_ver} -p /sbin/ldconfig

%post   -n libctf-nobfd%{?ctf_so_ver} -p /sbin/ldconfig
%postun -n libctf-nobfd%{?ctf_so_ver} -p /sbin/ldconfig

%post   -n libgprofng%{?gprofng_so_ver} -p /sbin/ldconfig
%postun -n libgprofng%{?gprofng_so_ver} -p /sbin/ldconfig

%post   -n libsframe%{?sframe_so_ver} -p /sbin/ldconfig
%postun -n libsframe%{?sframe_so_ver} -p /sbin/ldconfig

%changelog
openSUSE Build Service is sponsored by