%global debug_package %{nil}

Name:           libcxx
Version:        12.0.1
Release:        1%{?dist}
Summary:        LLVM "libcxx" runtime libraries
License:        BSD
URL:            http://llvm.org
Source0:        https://github.com/llvm/llvm-project/releases/download/llvmorg-%{version}/libcxx-%{version}.src.tar.xz

Patch0:        0001-libcxx-Remove-monorepo-requirement.patch
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  cmake
BuildRequires:  python3

%description
The libcxx-devel package includes the libraries and header files for libcxx.

    
%package devel
Summary:    Headers and libraries for libcxx devel
Requires:    %{name}%{?_isa} = %{version}-%{release}
 
%description devel
%{summary}.

%prep
%autosetup -n libcxx-%{version}.src

%build
mkdir -p _build
cd _build

cmake \
        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DCMAKE_C_COMPILER_TARGET=%{_arch} \
        -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
%if 0%{?__isa_bits} == 64
        -DLLVM_LIBDIR_SUFFIX=64 \
%else
        -DLLVM_LIBDIR_SUFFIX= \
%endif
  ..

%make_build
# Copy result libc++.a
mkdir results-static
find . -name libc++.a -exec cp {} ./results-static \;
cp ../src/include/atomic_support.h include/c++/v1
cp ../src/include/refstring.h include/c++/v1

%install
cd _build
%make_install
install results-static/libc++.a %{buildroot}/%{_libdir}
install include/c++/v1/atomic_support.h %{buildroot}/%{_libdir}/../include/c++/v1
install include/c++/v1/refstring.h %{buildroot}/%{_libdir}/../include/c++/v1

%files
%{_libdir}/libc++*
%{_prefix}/include/*

%files devel
%{_includedir}/c++/
%{_libdir}/libc++.so

%changelog
* Tue Feb 7 2023 Wang Zehong <wangzehong2@huawei.com> - 12.0.1-1
- update to 12.0.1-1
