LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File llvm.spec of Package llvm (Project home:aevseev:devel)

%define realname llvm
%define gen      8
%define mainver  8.0
%define realver  %{mainver}.0
%define srcext   tar.xz

%bcond_with doc

%if 0%{?suse_version}
%define pkg_name_lib   libLLVM%{gen}
%else
%define pkg_name_lib   llvm-libs
%endif

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

# Python 3.x support

%if 0%{?suse_version}
%define python3_pkg python3
%define python3 python3
%endif

# EPEL
%if 0%{?rhel} == 6
%define python3_pkg python34
%define python3     python3.4
%endif
%if 0%{?rhel} == 7
%define python3_pkg python34
%define python3     python3.4
%endif

%if ! 0%{?py3_ver:1}
%define py3_ver %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)
%endif
%define py3_gen %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)

%if ! 0%{?python3_sitelib:1}
%define python3_sitelib %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
%endif

# Common info
Name:          %{realname}
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       BSD-3-Clause
Group:         Development/Languages/Other
URL:           http://llvm.org/
Summary:       Low Level Virtual Machine

# Install-time parameters
# opt-viewer deps
Requires:      python(abi) = %{py3_ver}
Requires:      %python3_pkg-pygments %python3_pkg-PyYAML

# Build-time parameters
BuildRequires: xz pkg-config cmake >= 3.4.3
BuildRequires: gcc-c++
BuildRequires: googletest-devel
BuildRequires: %python3_pkg%{?suse_version:-base} %python3_pkg-setuptools
BuildRequires: %python3_pkg-pygments %python3_pkg-PyYAML
BuildRequires: libffi-devel
BuildRequires: libxml2-devel
# Required for LLVMgold LTO plugin
BuildRequires: binutils-devel
# Documentation
%if %{with doc}
BuildRequires: doxygen graphviz graphviz-gd
BuildRequires: fontconfig ghostscript-fonts%{?suse_version:-std}
BuildRequires: python-sphinx
%endif
%if 0%{?suse_version}
BuildRequires: fdupes
%endif
BuildRoot:     %{_tmppath}/%{name}-root
Source:        http://llvm.org/releases/%{realver}/llvm-%{realver}%{?extraver}.src.%{srcext}

%description
LLVM is a compiler infrastructure designed for compile-time, link-time, runtime,
and idle-time optimization of programs from arbitrary programming languages.
LLVM is written in C++ and has been developed since 2000 at the University of
Illinois and Apple. It currently supports compilation of C and C++ programs,
using front-ends derived from GCC 4.0.1. A new front-end for the C family of
languages is in development. The compiler infrastructure
includes mirror sets of programming tools as well as libraries with equivalent
functionality.

%package -n %{pkg_name_lib}
Group:         System/Libraries
Summary:       Shared libraries from LLVM project
Provides:      llvm-libs = %{version}-%{release}
Provides:      libLLVM = %{version}-%{release}

%description -n %{pkg_name_lib}
Shared libraries from LLVM project.

%package -n libLTO%{gen}
Group:         System/Libraries
Summary:       LLVM Link Time Optimizer shared library

%description -n libLTO%{gen}
Shared library providing functions and classes used to support LTO.

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Requires:      %{name} = %{version}-%{release}
Requires:      %{pkg_name_lib} = %{version}-%{release}
Requires:      libLTO%{gen} = %{version}-%{release}
Requires:      llvm-gold-lto-plugin = %{version}-%{release}
Requires:      ncurses-devel zlib-devel

%description devel
Development files for %{name}

%package gold-lto-plugin
Group:         Development/Languages/C and C++
Summary:       LTO plugin for GNU Gold linker

%description gold-lto-plugin
Link-time optimization plugin for GNU Gold linker.

%package doc
Group:         Documentation/HTML
Summary:       Documentation for %{name}
Requires:      %{name} = %{version}
%if ! 0%{?sles_version}
BuildArch:     noarch
%endif

%description doc
Documentation for %{name}

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

%build
# Needed to use freshly built llvm-tblgen
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$(pwd -P)/build/%{_lib}
# Fix for RHEL/CentOS
_CFLAGS="%{optflags} -I%{_includedir}/ncurses"
_CXXFLAGS="%{optflags} %{?cxx11abi} -I%{_includedir}/ncurses"
_LDFLAGS="-Wl,--as-needed -Wl,--strip-all -pthread"
%ifarch %ix86
_CFLAGS+=' -march=i686'
_CXXFLAGS+=' -march=i686'
%endif
%{__mkdir} build
cd build
cmake .. \
 -DCMAKE_INSTALL_PREFIX=%{_prefix} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_ASM_FLAGS_RELEASE="$_CFLAGS" \
 -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" \
 -DCMAKE_SKIP_RPATH=YES \
 -DCMAKE_VERBOSE_MAKEFILE=YES \
 \
 -DBUILD_SHARED_LIBS=YES \
%if 0%{?rhel}
 -DFFI_INCLUDE_DIR=$(pkg-config --variable=includedir libffi) \
%endif
 \
 -DLLVM_BINUTILS_INCDIR=%{_includedir} \
 -DLLVM_DEFAULT_TARGET_TRIPLE=%{_build} \
 -DLLVM_ENABLE_FFI=YES \
 -DLLVM_ENABLE_LTO=FULL \
 -DLLVM_HOST_TRIPLE=%{_host} \
 -DLLVM_INCLUDE_EXAMPLES=NO \
 -DLLVM_INCLUDE_TESTS=NO \
 -DLLVM_INSTALL_UTILS=YES \
%if "%{_lib}" == "lib64"
 -DLLVM_LIBDIR_SUFFIX=64 \
%endif
 -DLLVM_TOOL_OPENMP_BUILD=YES \
 \
%if %{with doc}
 -DLLVM_BUILD_DOCS=YES \
 -DLLVM_ENABLE_DOXYGEN=YES \
 -DLLVM_ENABLE_SPHINX=YES \
 -DLLVM_INSTALL_DOXYGEN_HTML_DIR=%{_defaultdocdir}/llvm/doxygen-html \
%else
 -DLLVM_BUILD_DOCS=NO \
%endif
 \
 -DPYTHON_EXECUTABLE=%{_bindir}/%python3
%{__make} %{?_smp_mflags}

%install
%{__make} -C build install DESTDIR=%{buildroot}
%{__install} -d -m755 %{buildroot}%{_prefix}/lib/bfd-plugins
%{__ln_s} %{_libdir}/LLVMgold.so %{buildroot}%{_prefix}/lib/bfd-plugins/
%if %{with doc}
# Fix tblgen manpage name
TBLGEN_MANPAGE=$(find %{buildroot}%{_mandir}/man1/ -name tblgen.1\*)
%{__ln_s} ${TBLGEN_MANPAGE##*/} %{buildroot}%{_mandir}/man1/llvm-${TBLGEN_MANPAGE##*/}
# Move HTML docs to the correct docdir (for SUSE)
mv -f %{buildroot}%{_prefix}/share/doc/llvm/html %{buildroot}%{_defaultdocdir}/llvm/ || :
# Handle file duplicates
%if 0%{?suse_version}
%fdupes %{buildroot}%{_defaultdocdir}
%endif
%endif

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

%files
%defattr(-,root,root)
%doc CREDITS.TXT LICENSE.TXT README.txt
%{_bindir}/FileCheck
%{_bindir}/bugpoint
%{_bindir}/count
%{_bindir}/dsymutil
%{_bindir}/llc
%{_bindir}/lli
%{_bindir}/lli-child-target
%{_bindir}/llvm-PerfectShuffle
%{_bindir}/llvm-ar
%{_bindir}/llvm-as
%{_bindir}/llvm-bcanalyzer
%{_bindir}/llvm-c-test
%{_bindir}/llvm-cat
%{_bindir}/llvm-cfi-verify
%{_bindir}/llvm-cov
%{_bindir}/llvm-cvtres
%{_bindir}/llvm-cxxdump
%{_bindir}/llvm-cxxfilt
%{_bindir}/llvm-cxxmap
%{_bindir}/llvm-diff
%{_bindir}/llvm-dis
%{_bindir}/llvm-dlltool
%{_bindir}/llvm-dwarfdump
%{_bindir}/llvm-dwp
%{_bindir}/llvm-elfabi
%{_bindir}/llvm-exegesis
%{_bindir}/llvm-extract
%{_bindir}/llvm-lib
%{_bindir}/llvm-link
%{_bindir}/llvm-lto
%{_bindir}/llvm-lto2
%{_bindir}/llvm-mc
%{_bindir}/llvm-mca
%{_bindir}/llvm-modextract
%{_bindir}/llvm-mt
%{_bindir}/llvm-nm
%{_bindir}/llvm-objcopy
%{_bindir}/llvm-objdump
%{_bindir}/llvm-opt-report
%{_bindir}/llvm-pdbutil
%{_bindir}/llvm-profdata
%{_bindir}/llvm-ranlib
%{_bindir}/llvm-rc
%{_bindir}/llvm-readelf
%{_bindir}/llvm-readobj
%{_bindir}/llvm-rtdyld
%{_bindir}/llvm-size
%{_bindir}/llvm-split
%{_bindir}/llvm-stress
%{_bindir}/llvm-strings
%{_bindir}/llvm-strip
%{_bindir}/llvm-symbolizer
%{_bindir}/llvm-undname
%{_bindir}/llvm-xray
%{_bindir}/not
%{_bindir}/obj2yaml
%{_bindir}/opt
%{_bindir}/sancov
%{_bindir}/sanstats
%{_bindir}/verify-uselistorder
%{_bindir}/yaml-bench
%{_bindir}/yaml2obj
%{_libdir}/libOptRemarks.so.%{gen}
%dir %{_datadir}/opt-viewer
%attr(0644,root,root) %{_datadir}/opt-viewer/*.css
%attr(0755,root,root) %{_datadir}/opt-viewer/*.py*
%if %{with doc}
%doc %{_mandir}/man1/*
%exclude %{_mandir}/man1/llvm-config.1*
%exclude %{_mandir}/man1/llvm-tblgen.1*
%exclude %{_mandir}/man1/tblgen.1*
%exclude %{_defaultdocdir}/llvm/doxygen-html/
%exclude %{_defaultdocdir}/llvm/html/
%endif
# LLVM Shared libraries
%files -n %{pkg_name_lib}
%defattr(-,root,root)
%{_libdir}/libLLVM*.so.%{gen}

%files -n libLTO%{gen}
%defattr(-,root,root)
%{_libdir}/libLTO.so.%{gen}

# Development stuff
%files devel
%defattr(-,root,root)
%{_bindir}/llvm-config
%{_bindir}/llvm-tblgen
%{_libdir}/libLTO.so
%{_libdir}/libLLVM*.so
%{_libdir}/libOptRemarks.so
%{_includedir}/llvm/
%{_includedir}/llvm-c/
%dir %{_libdir}/cmake/llvm
%dir %{_libdir}/cmake
%{_libdir}/cmake/llvm/*.cmake
%if %{with doc}
%doc %{_mandir}/man1/llvm-config.1*
%doc %{_mandir}/man1/llvm-tblgen.1*
%doc %{_mandir}/man1/tblgen.1*
%endif

# Gold LTO plugin
%files gold-lto-plugin
%defattr(-,root,root)
%{_libdir}/LLVMgold.so
%dir %{_prefix}/lib/bfd-plugins/
%{_prefix}/lib/bfd-plugins/LLVMgold.so

# Documentation
%if %{with doc}
%files doc
%defattr(-,root,root)
%docdir %{_defaultdocdir}/llvm/doxygen-html
%docdir %{_defaultdocdir}/llvm/html
%dir %{_defaultdocdir}/llvm
%doc %{_defaultdocdir}/llvm/doxygen-html/*
%doc %{_defaultdocdir}/llvm/html/*
%exclude %{_defaultdocdir}/llvm/doxygen-html/*.map
%exclude %{_defaultdocdir}/llvm/doxygen-html/*.md5
%exclude %{_defaultdocdir}/llvm/html/.buildinfo
%endif

%post   -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%post   -n libLTO%{gen} -p /sbin/ldconfig
%postun -n libLTO%{gen} -p /sbin/ldconfig

%post   -n %{pkg_name_lib} -p /sbin/ldconfig
%postun -n %{pkg_name_lib} -p /sbin/ldconfig

%changelog