File libc++abi.spec of Package libc++abi

%define realname libcxxabi
%define gen      9
%define mainver  9.0
%define realver  %{mainver}.0
%define srcext   tar.xz

%define so_ver   1

%if 0%{?suse_version} < 1500
%define cxx11abi -D_GLIBCXX_USE_CXX11_ABI=0
%endif

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

# Common info
Name:          libc++abi
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       MIT or BSD-3-Clause
Group:         Development/Languages/C and C++
URL:           http://libcxx.llvm.org/
Summary:       Low level C++ Standard Library support

# Build-time parameters
BuildRequires: xz cmake >= 3.4.3
BuildRequires: gcc-c++
BuildRequires: libc++-devel
BuildRequires: llvm-devel
BuildRoot:     %{_tmppath}/%{name}-root
### Source:        http://llvm.org/releases/%{realver}/%{realname}-%{realver}%{?extraver}.src.%{srcext}
### Source:        https://github.com/llvm/llvm-project/releases/download/llvmorg-%{realver}/%{realname}-%{realver}%{?extraver}.src.%{srcext}
Source:        http://releases.llvm.org/%{realver}/%{realname}-%{realver}%{?extraver}.src.%{srcext}

%description
libc++abi is a new implementation of low level support for
a standard C++ library.

Features and Goals:

  * Correctness as defined by the C++11 standard.
  * Provide a portable sublayer to ease the porting of libc++
  * On Mac OS X, be ABI compatible with the existing low-level support.

%package -n libc++abi%{?so_ver}
Group:         Development/Languages/C and C++
Summary:       Low level C++ Standard Library support
Provides:      %{name} = %{version}-%{release}
Provides:      %{realname} = %{version}-%{release}
Provides:      %{realname}%{?so_ver} = %{version}-%{release}
Provides:      llvm-%{name} = %{version}-%{release}
Provides:      llvm-%{realname} = %{version}-%{release}
Provides:      llvm-%{name}%{?so_ver} = %{version}-%{release}
Provides:      llvm-%{realname}%{?so_ver} = %{version}-%{release}

%description -n libc++abi%{?so_ver}
libc++abi is a new implementation of low level support for
a standard C++ library.

Features and Goals:

  * Correctness as defined by the C++11 standard.
  * Provide a portable sublayer to ease the porting of libc++
  * On Mac OS X, be ABI compatible with the existing low-level support.

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for C++ Standard Library
Requires:      libc++abi%{?so_ver} = %{version}-%{release}
Provides:      libc++abi%{?so_ver}-devel = %{version}-%{release}
Provides:      %{realname}-devel = %{version}-%{release}
Provides:      %{realname}%{?so_ver}-devel = %{version}-%{release}
Provides:      llvm-%{name}-devel = %{version}-%{release}
Provides:      llvm-%{realname}-devel = %{version}-%{release}
Provides:      llvm-%{name}%{?so_ver}-devel = %{version}-%{release}
Provides:      llvm-%{realname}%{?so_ver}-devel = %{version}-%{release}

%description devel
libc++abi is a new implementation of low level support for
a standard C++ library.

This package contains files needed for software development with use
of libc++abi.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{realver}%{?extraver}.src

%build
# Fix for RHEL/CentOS
_CFLAGS="%{optflags} %{?gcc_lto}"
_CXXFLAGS="%{optflags} %{?gcc_lto} %{?cxx11abi}"
_LDFLAGS="-Wl,--as-needed -Wl,--strip-all %{?gcc_lto}"
%ifarch %ix86
_CFLAGS+=' -march=i686'
_CXXFLAGS+=' -march=i686'
%endif
%{__mkdir} build
cd build
cmake .. \
 -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_CXX_FLAGS_RELEASE="$_CXXFLAGS" \
 -DCMAKE_C_FLAGS_RELEASE="$_CFLAGS" \
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS" \
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS -shared" \
 -DCMAKE_SKIP_RPATH=YES \
 -DCMAKE_VERBOSE_MAKEFILE=YES \
%if 0%{__isa_bits} == 64
 -DLIBCXXABI_LIBDIR_SUFFIX=64 \
%endif
 \
 -DLIBCXXABI_ENABLE_STATIC=NO \
 -DLIBCXXABI_LIBCXX_PATH=%{_prefix}
%{__make} %{?_smp_mflags}

%install
%{__make} -C build install DESTDIR=%{buildroot}
# Internal headers
%{__install} -D -m0644 include/cxxabi.h          %{buildroot}/%{_includedir}/c++abi/v1/cxxabi.h
%{__install} -D -m0644 include/__cxxabi_config.h %{buildroot}/%{_includedir}/c++abi/v1/__cxxabi_config.h

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

%files -n libc++abi%{?so_ver}
%defattr(-,root,root)
%doc CREDITS.TXT LICENSE.TXT
%{_libdir}/libc++abi.so.%{?so_ver}*

# Development stuff
%files devel
%defattr(-,root,root)
%{_includedir}/c++abi/
%{_libdir}/libc++abi.so

%post   -n libc++abi%{?so_ver} -p /sbin/ldconfig
%postun -n libc++abi%{?so_ver} -p /sbin/ldconfig

%changelog