# The following GCC versioning stuff shamelessly copied # from the Fedora spec file for gcc-python-plugin # GCC will only load plugins that were built against exactly that build of GCC # We thus need to embed the exact GCC version as a requirement within the # metadata. # # Define "gcc_vr", a variable to hold the VERSION-RELEASE string for the gcc # we are being built against. # # Unfortunately, we can't simply run: # rpm -q --qf="%{version}-%{release}" # to determine this, as there's no guarantee of a sane rpm database within # the chroots created by our build system # # So we instead query the version from gcc's output. # # gcc.spec has: # Version: %{gcc_version} # Release: %{gcc_release}%{?dist} # ...snip... # echo 'Red Hat %{version}-%{gcc_release}' > gcc/DEV-PHASE # So, given this output: # # $ gcc --version # gcc (GCC) 4.6.1 20110908 (Red Hat 4.6.1-9) # Copyright (C) 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # we can scrape out the "4.6.1-9" from the version line. # # We then have to add the dist tag; which we must hope is the same as what we # have # # The following implements the above: %global gcc_vr %(gcc --version | python -c "import re; import sys; print(re.match(r'.*\\(Red Hat (.+)\\).*', sys.stdin.read()).group(1))")%{dist} # Define a boolean to make it easy to turn the above off, in case it fails: %global with_hard_gcc_version_requirement 1 # Exclude the architectures for which LLVM is not built. Keep in sync with # the ExcludeArch of the LLVM package spec. # package spec file. ExcludeArch: s390 s390x ppc ppc64 %global downloadurl http://llvm.org/%{?prerel:pre-}releases/%{version}%{?prerel:/%{prerel}} %global gcc_plugins_dir %(gcc --print-file-name=plugin) Name: dragonegg Version: 3.1 Release: 1%{?dist} Summary: GCC plugin to use LLVM optimizers and code generators Group: Development/Languages License: GPLv2+ URL: http://dragonegg.llvm.org/ Source0: %{downloadurl}/dragonegg-%{version}%{?prerel}.src.tar.gz BuildRequires: llvm-devel = %{version} BuildRequires: gcc-plugin-devel %if %{with_hard_gcc_version_requirement} Requires: gcc = %{gcc_vr} %else Requires: gcc %endif %description DragonEgg is a GCC plugin that replaces GCC's optimizers and code generators with those from the LLVM project. %prep %setup -q -n %{name}-%{version}%{?prerel:%{prerel}}.src %build echo "gcc_vr = %{gcc_vr}" # FIXME needs %{optflags} GCC=%{_bindir}/gcc make %{_smp_mflags} %install mkdir -p %{buildroot}%{gcc_plugins_dir} install -m 755 dragonegg.so %{buildroot}%{gcc_plugins_dir} %files %defattr(-,root,root,-) %doc README COPYING %{gcc_plugins_dir}/%{name}.so %changelog * Wed May 23 2012 Eric Smith - 3.1-1 - Updated to latest upstream. - Added ExcludeArch to avoid building on architectures for which LLVM is not built. It seems to me that it should be possible to build LLVM on the excluded architectures for use as a cross-compiler host only, but this isn't being done. Note that we currently don't build for any EPEL because no EPEL provides a new enough LLVM. Maybe someday. * Sat Dec 03 2011 Eric Smith - 3.0-1 - Update to upstream final release * Fri Dec 02 2011 Eric Smith - 3.0-0.1.rc3 - Initial version