%global major_version 3.9 Name: clang%{major_version} Version: %{major_version}.1 Release: 1%{?dist} Summary: A C language family front-end for LLVM License: NCSA URL: http://llvm.org Source0: http://llvm.org/releases/%{version}/cfe-%{version}.src.tar.xz Source100: clang-config.h # Support versioned install Patch0: clang-versioned.patch Patch1: clang-find_package.patch BuildRequires: cmake3 BuildRequires: llvm%{major_version}-devel = %{version} BuildRequires: libxml2-devel BuildRequires: llvm%{major_version}-static Requires: %{name}-libs%{?_isa} = %{version}-%{release} # clang requires gcc, clang++ requires libstdc++-devel # - https://bugzilla.redhat.com/show_bug.cgi?id=1021645 # - https://bugzilla.redhat.com/show_bug.cgi?id=1158594 Requires: libstdc++-devel Requires: gcc-c++ %description clang: noun 1. A loud, resonant, metallic sound. 2. The strident call of a crane or goose. 3. C-language family front-end toolkit. The goal of the Clang project is to create a new C, C++, Objective C and Objective C++ front-end for the LLVM compiler. Its tools are built as libraries and designed to be loosely-coupled and extensible. %package libs Summary: Runtime library for clang %description libs Runtime library for clang. %package devel Summary: Development header files for clang. Requires: %{name}%{?_isa} = %{version}-%{release} %description devel Development header files for clang. %package analyzer Summary: A source code analysis framework License: NCSA and MIT BuildArch: noarch Requires: %{name} = %{version}-%{release} # not picked up automatically since files are currently not installed in # standard Python hierarchies yet Requires: python %description analyzer The Clang Static Analyzer consists of both a source code analysis framework and a standalone tool that finds bugs in C and Objective-C programs. The standalone tool is invoked from the command-line, and is intended to run in tandem with a build of a project or code base. %prep %setup -q -n cfe-%{version}.src #patch0 -p1 -b .versioned %patch1 -p1 -b .find_package %build mkdir -p _build cd _build export PATH=%{_libdir}/llvm%{major_version}/bin:$PATH %cmake3 .. \ -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \ -DCMAKE_INSTALL_BINDIR:PATH=bin \ -DCMAKE_LIBRARY_PATH:PATH=%{_libdir}/llvm%{major_version} \ -DCLANG_ENABLE_ARCMT:BOOL=ON \ -DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \ -DCLANG_INCLUDE_DOCS:BOOL=ON \ -DCLANG_INCLUDE_TESTS:BOOL=ON \ -DCLANG_PLUGIN_SUPPORT:BOOL=ON \ -DCLANG_BUILD_EXAMPLES:BOOL=OFF make %{?_smp_mflags} %install cd _build make install DESTDIR=%{buildroot} # Move and symlink into FHS dirs mkdir -p %{buildroot}%{_bindir} for bin in %{buildroot}%{_libdir}/%{name}/bin/* do # Already versioned binaries if [ ${bin%%%{major_version}} != $bin ] then mv $bin %{buildroot}%{_bindir}/${bin##*/} ln -s ../../../bin/${bin##*/} %{buildroot}%{_libdir}/%{name}/bin/${bin##*/} else # Unversioned binaries if [ -L $bin ] then target=$(readlink $bin) # Make the link point to the versioned binary if needed [ ${target%%%{major_version}} == $target ] && ln -sf ${target}-%{major_version} $bin [ $target == clang-%{major_version} ] && continue fi mv $bin %{buildroot}%{_bindir}/${bin##*/}-%{major_version} ln -s ../../../bin/${bin##*/}-%{major_version} %{buildroot}%{_libdir}/%{name}/bin/${bin##*/} fi done for dir in include share do mkdir -p %{buildroot}%{_prefix}/$dir/%{name} mv %{buildroot}%{_libdir}/%{name}/$dir/* %{buildroot}%{_prefix}/$dir/%{name}/ rmdir %{buildroot}%{_libdir}/%{name}/$dir ln -s ../../$dir/%{name} %{buildroot}%{_libdir}/%{name}/$dir done mkdir -p %{buildroot}%{_libdir}/cmake mv %{buildroot}%{_libdir}/%{name}/lib/cmake/clang %{buildroot}%{_libdir}/cmake/%{name} ln -s ../../../cmake/%{name} %{buildroot}%{_libdir}/%{name}/lib/cmake/clang # Create ld.so.conf.d entry mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d cat >> %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf << EOF %{_libdir}/%{name}/lib EOF # multilib fix mv -v %{buildroot}%{_includedir}/%{name}/clang/Config/config{,-%{__isa_bits}}.h install -m 0644 %{SOURCE100} %{buildroot}%{_includedir}/%{name}/clang/Config/config.h # remove git integration rm -v %{buildroot}%{_bindir}/git-clang-format-%{major_version} rm -v %{buildroot}%{_libdir}/%{name}/bin/git-clang-format # remove editor integrations (bbedit, sublime, emacs, vim) rm -v %{buildroot}%{_datadir}/%{name}/clang/clang-format-bbedit.applescript rm -v %{buildroot}%{_datadir}/%{name}/clang/clang-format-sublime.py* rm -v %{buildroot}%{_datadir}/%{name}/clang/clang-format.el rm -v %{buildroot}%{_datadir}/%{name}/clang/clang-format.py* # remove diff reformatter rm -v %{buildroot}%{_datadir}/%{name}/clang/clang-format-diff.py* # install static-analyzer # http://clang-analyzer.llvm.org/installation#OtherPlatforms mkdir -p %{buildroot}%{_libexecdir}/clang-analyzer%{major_version}/ cp -vpr ../tools/scan-view %{buildroot}%{_libexecdir}/clang-analyzer%{major_version}/ cp -vpr ../tools/scan-build %{buildroot}%{_libexecdir}/clang-analyzer%{major_version}/ # remove non-Linux scripts rm -v %{buildroot}%{_libexecdir}/clang-analyzer%{major_version}/scan-build/*/*.bat rm -v %{buildroot}%{_libexecdir}/clang-analyzer%{major_version}/scan-build/bin/set-xcode-analyzer # fix manual page location mkdir -p %{buildroot}%{_mandir}/man1/ mv -v %{buildroot}%{_libexecdir}/clang-analyzer%{major_version}/scan-build/man/scan-build.1 %{buildroot}%{_mandir}/man1/scan-build-%{major_version}.1 %check # requires lit.py from LLVM utilities cd _build make check-all %post libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig %files %dir %{_libdir}/%{name}/bin %{_libdir}/%{name}/bin/c* %{_bindir}/c* %files libs %config(noreplace) %{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf %dir %{_libdir}/%{name} %dir %{_libdir}/%{name}/lib %{_libdir}/%{name}/lib/*.so.* %{_libdir}/%{name}/lib/*.so %files devel %{_includedir}/%{name}/ %{_libdir}/%{name}/include %{_libdir}/%{name}/lib/clang/ %{_libdir}/%{name}/lib/cmake/ %{_libdir}/cmake/%{name}/ %{_datadir}/%{name}/ %{_libdir}/%{name}/share %files analyzer %{_bindir}/scan-view-%{major_version} %{_bindir}/scan-build-%{major_version} %{_libdir}/%{name}/bin/scan* %{_libdir}/%{name}/libexec/ %{_libexecdir}/clang-analyzer%{major_version} %{_mandir}/man1/scan-build-%{major_version}.1.* %changelog * Tue Feb 7 2017 Orion Poplawski - 3.7.1-1 - Initial versioned package