File mingw64-clang13.spec of Package mingw64-clang13

#
# spec file for package mingw64-clang13
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define _tagver 13.0.1
%define _sonum  13
%define _soclang 13
%define _name clang%{_soclang}
Name:           mingw64-%{_name}
Version:        %{_tagver}
Release:        0
Summary:        CLANG frontend for LLVM
License:        Apache-2.0 WITH LLVM-exception AND NCSA
Group:          Development/Languages/C and C++
URL:            https://clang.llvm.org/
# NOTE: please see README.packaging in the llvm package for details on how to update this package
Source:         https://github.com/llvm/llvm-project/releases/download/llvmorg-%{_tagver}/clang-%{version}.src.tar.xz
BuildRequires:  cmake(LLVM) = %{_tagver}
BuildRequires:  gcc-c++
BuildRequires:  libxml2-devel
BuildRequires:  libxml2-devel
BuildRequires:  mingw64(cmake:LLVM) =  %{_tagver}
BuildRequires:  mingw64(pkg:zlib)
BuildRequires:  mingw64-cross-cmake
BuildRequires:  mingw64-cross-gcc-c++
BuildRequires:  mingw64-libxml2-devel
BuildRequires:  pkgconfig(zlib)
%_mingw64_package_header_debug
BuildArch:      noarch

#Requires(post): mingw64-update-alternatives
#Requires(postun):mingw64-update-alternatives
Recommends:     mingw64-clang-tools
Recommends:     mingw64-cross-gcc
#Recommends:     glibc-devel
#Recommends:     libstdc++-devel
Suggests:       mingw64-clang%{_sonum}-doc
#Suggests:       libc++-devel

%description
This package contains the clang (C language) frontend for LLVM.

%package -n mingw64-clang%{_sonum}-tools
Summary:        Tools for Clang
Group:          Development/Languages/C and C++
URL:            https://clang-analyzer.llvm.org/
# Avoid multiple provider errors
Requires:       mingw64-clang%{_sonum}
# Some binaries used to be in the clang package.
#Conflicts:      clang5
#Conflicts:      clang6
# hmaptool used to be contained in the llvm package.
#Conflicts:      llvm5
#Conflicts:      llvm6
%if %{suse_version} <= 1500
# llvm9 in SLE/Leap 15.x is still affected.
#Conflicts:      llvm9
%endif
Conflicts:      mingw64-scan-build < %{version}
Conflicts:      mingw64-scan-view < %{version}
Provides:       mingw64-scan-build = %{version}
Provides:       mingw64-scan-view = %{version}
Conflicts:      mingw64-emacs-llvm < %{version}
Provides:       mingw64-emacs-llvm = %{version}
Conflicts:      mingw64-vim-plugin-llvm < %{version}
Provides:       mingw64-clang-tools = %{version}

%description -n mingw64-clang%{_sonum}-tools
This package contains tools and scripts for using Clang, including:
* bash completions for clang,
* the clang-doc tool,
* plugins for using clang-format, clang-rename, clang-include-fixer
  in vim and emacs.
* scripts for using clang-format: git-clang-format and clang-format-diff,
* scripts for using clang-tidy: run-clang-tidy and clang-tidy-diff,
* scripts for using the Clang static analyzer: scan-build and scan-view,
* a script for using find-all-symbols: run-find-all-symbols.

%package -n mingw64-libclang%{_soclang}
Summary:        Clang stable C API for indexing and code completion
Group:          System/Libraries
Conflicts:      mingw64-libclang%{_soclang} < %{version}

%description -n mingw64-libclang%{_soclang}
This library exposes a limited C API for indexing and code completion for
code written in languages of the C family.
It is designed to be stable across major versions of LLVM.

It corresponds to the header files in %{_mingw64_includedir}/clang-c.

%package -n mingw64-clang%{_soclang}-devel
Summary:        CLANG frontend for LLVM (devel package)
Group:          Development/Libraries/C and C++
Requires:       %{name}-devel = %{version}
Requires:       mingw64-clang%{_sonum} = %{version}
Requires:       mingw64-clang-tools >= %{version}
Requires:       mingw64-libclang%{_soclang} >= %{version}
#Requires:       mingw64-libclang-cpp%%{_sonum} = %%{version}
Provides:       mingw64-clang-devel = %{version}

%description -n mingw64-clang%{_soclang}-devel
This package contains the clang (C language) frontend for LLVM.
(development files)

%_mingw64_debug_package

%prep
%autosetup -p1 -n clang-%{version}.src

%build
# build required native tools
d=$PWD
%cmake -B NATIVE
cd $d/build/NATIVE
export PATH=$PWD/bin:$PATH
%cmake_build clang-tblgen
cd $d

%_mingw64_cmake \
    -DCLANG_ENABLE_ARCMT:BOOL=OFF \
    -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=OFF \
    -DCMAKE_DLL_NAME_WITH_SOVERSION=1 \
    -DCOMPILER_RT_BUILD_SANITIZERS:BOOL=OFF \
    -DCOMPILER_RT_BUILD_XRAY:BOOL=OFF \
    -DCOMPILER_RT_USE_LIBCXX:BOOL=OFF \
    -DENABLE_LINKER_BUILD_ID=ON \
    -DLLVM_TABLEGEN_EXE=/usr/%{_mingw64_target}/bin/llvm-tblgen \
    -DLLVM_TARGETS_TO_BUILD=Native \
    -Dexternal_project_source_dirs="-DCMAKE_C_COMPILER=gcc;-DCMAKE_CXX_COMPILER=g++" \

%_mingw64_cmake_build

%install
%_mingw64_cmake_install

# fix mingw64-clang13-tools.noarch: E: env-script-interpreter
sed -i 's,/usr/bin/env ,/usr/bin/,g' %{buildroot}%{_mingw64_bindir}/git-clang-format
sed -i 's,/usr/bin/env ,/usr/bin/,g' %{buildroot}%{_mingw64_bindir}/hmaptool
sed -i 's,/usr/bin/env ,/usr/bin/,g' %{buildroot}%{_mingw64_datadir}/clang/*.py
sed -i 's,/usr/bin/env ,/usr/bin/,g' %{buildroot}%{_mingw64_datadir}/clang/*.el
sed -i 's,/usr/bin/env ,/usr/bin/,g' %{buildroot}%{_mingw64_datadir}/clang/*.sh

# fix mingw64-clang13-tools.noarch: E: script-without-shebang
chmod a-x %{buildroot}%{_mingw64_datadir}/clang/*.sh
chmod a-x %{buildroot}%{_mingw64_datadir}/clang/*.py
chmod a-x %{buildroot}%{_mingw64_datadir}/clang/*.el
chmod a-x %{buildroot}%{_mingw64_datadir}/clang/*.sh

rm %{buildroot}%{_mingw64_datadir}/clang/*.applescript

%files -n mingw64-clang%{_soclang}
%license CODE_OWNERS.TXT LICENSE.TXT
%{_mingw64_bindir}/c-index-test.exe
%{_mingw64_bindir}/clang++.exe
%{_mingw64_bindir}/clang-cl.exe
%{_mingw64_bindir}/clang-cpp.exe
%{_mingw64_bindir}/clang-format.exe
%{_mingw64_bindir}/clang-offload-bundler.exe
%{_mingw64_bindir}/clang-offload-wrapper.exe
%{_mingw64_bindir}/clang-refactor.exe
%{_mingw64_bindir}/clang-rename.exe
%{_mingw64_bindir}/clang-repl.exe
%{_mingw64_bindir}/clang-scan-deps.exe
%{_mingw64_bindir}/clang.exe
%{_mingw64_bindir}/diagtool.exe

%files -n mingw64-clang%{_sonum}-tools
%license CODE_OWNERS.TXT LICENSE.TXT
%{_mingw64_bindir}/git-clang-format
%{_mingw64_bindir}/hmaptool
%{_mingw64_datadir}/clang

%files -n mingw64-libclang%{_soclang}
%license CODE_OWNERS.TXT LICENSE.TXT
%{_mingw64_bindir}/libclang*.dll

%files -n mingw64-clang%{_soclang}-devel
%license CODE_OWNERS.TXT LICENSE.TXT
%{_mingw64_includedir}/clang-c/
%{_mingw64_includedir}/clang/
%dir %{_mingw64_libdir}/clang
%dir %{_mingw64_libdir}/clang/%{version}
%{_mingw64_libdir}/clang/%{version}/include
%{_mingw64_libdir}/cmake/clang
%{_mingw64_libdir}/libclang*.dll.a
openSUSE Build Service is sponsored by