Blob Blame History Raw
%define opt %(test -x %{_bindir}/ocamlopt && echo 1 || echo 0)
%define debug_package %{nil}

%if !%opt
# Prevent RPM from stripping bytecode /usr/bin/spatch.
%define __strip /bin/true
%endif

Name:           coccinelle
Version:        0.2.5
Release:        0.rc1.2%{?dist}
Summary:        Semantic patching for Linux (spatch)

Group:          Development/Libraries
License:        GPLv2

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ExcludeArch:    sparc64 s390 s390x ppc64

URL:            http://coccinelle.lip6.fr/
Source0:        http://coccinelle.lip6.fr/distrib/%{name}-%{version}-rc1.tgz

BuildRequires:  ocaml >= 3.10.0
BuildRequires:  ocaml-findlib-devel
BuildRequires:  ocaml-ocamldoc

BuildRequires:  python-devel
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

BuildRequires:  chrpath

%global __ocaml_requires_opts -i Ast_c -i Token_c -i Type_cocci -i Ast_cocci -i Common


%description
Coccinelle is a tool to utilize semantic patches for manipulating C
code.  It was originally designed to ease maintenance of device
drivers in the Linux kernel.


%package doc
Summary:        Documentation for %{name}
Group:          Development/Libraries
Requires:       %{name} = %{version}-%{release}


%description doc
The %{name}-doc package contains documentation for %{name}.


%package examples
Summary:        Examples for %{name}
Group:          Development/Libraries
Requires:       %{name} = %{version}-%{release}


%description examples
The %{name}-examples package contains examples for %{name}.



%prep
%setup -q -n %{name}-%{version}-rc1

# Remove .cvsignore files.
find -name .cvsignore -delete

# Convert a few files to UTF-8 encoding.
for f in demos/demo_rule9/sym53c8xx.res demos/demo_rule9/sym53c8xx.c; do
  mv $f $f.orig
  iconv -f iso-8859-1 -t utf-8 < $f.orig > $f
  rm $f.orig
done


%build
./configure --prefix=%{_prefix}
%{__sed} -i \
  -e 's,LIBDIR=.*,LIBDIR=%{_libdir},' \
  -e 's,MANDIR=.*,MANDIR=%{_mandir},' \
  -e 's,SHAREDIR=.*,SHAREDIR=%{_datadir}/%{name},' \
  Makefile.config

# Note that _smp_mflags breaks the build.
%if !%opt
make all
%else
make all opt
%endif


%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install

%if %opt
# Just the native code version.
rm $RPM_BUILD_ROOT%{_bindir}/spatch
mv $RPM_BUILD_ROOT%{_bindir}/spatch.opt $RPM_BUILD_ROOT%{_bindir}/spatch
strip $RPM_BUILD_ROOT%{_datadir}/%{name}/spatch.opt
%else
# Else prevent prelink from buggering about with the bytecode binary.
mkdir -p $RPM_BUILD_ROOT/etc/prelink.conf.d
echo '-b %{_bindir}/spatch' \
  > $RPM_BUILD_ROOT/etc/prelink.conf.d/%{name}.conf
%endif

strip $RPM_BUILD_ROOT%{_libdir}/*.so
chrpath --delete $RPM_BUILD_ROOT%{_libdir}/*.so

# Remove bogus Makefiles from Python directory.
find $RPM_BUILD_ROOT%{_datadir}/%{name} -name Makefile -delete

# Move Python libraries to python lib directory.
mkdir -p $RPM_BUILD_ROOT%{python_sitelib}
mv $RPM_BUILD_ROOT%{_datadir}/%{name}/python/coccilib \
  $RPM_BUILD_ROOT%{python_sitelib}

rmdir $RPM_BUILD_ROOT%{_datadir}/%{name}/python


%check
LD_LIBRARY_PATH=. \
./spatch.opt -cocci_file demos/simple.cocci demos/simple.c


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%doc authors.txt bugs.txt changes.txt copyright.txt
%doc credits.txt install.txt license.txt readme.txt
%{_bindir}/spatch
%{_datadir}/%{name}/
%{python_sitelib}/coccilib/
%{_mandir}/man1/*.1.gz
%{_libdir}/*.so
%if !%opt
%config(noreplace) /etc/prelink.conf.d/%{name}.conf
%endif


%files doc
%defattr(-,root,root,-)
%doc docs


%files examples
%defattr(-,root,root,-)
%doc demos


%changelog
* Mon Jan 10 2011 Richard W.M. Jones <rjones@redhat.com> - 0.2.5-0.rc1.2
- Bump and rebuild.

* Fri Jan  7 2011 Richard W.M. Jones <rjones@redhat.com> - 0.2.5-0.rc1.1
- New upstream version 0.2.5-rc1.
- Remove upstream patch for Python 2.7.
- Rebuild for OCaml 3.12.0.

* Wed Jul 28 2010 Orcan Ogetbil <oget[DOT]fedora[AT]gmail[DOT]com> - 0.2.3-0.rc6.3
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Sat Jul 24 2010 Richard W.M. Jones <rjones@redhat.com> - 0.2.3-0.rc6.2
- Ignore some bogus generated requires.

* Fri Jul 23 2010 Richard W.M. Jones <rjones@redhat.com> - 0.2.3-0.rc6.1
- Fix for Python 2.7.

* Fri Jul 23 2010 Richard W.M. Jones <rjones@redhat.com> - 0.2.3-0.rc6
- New upstream version 0.2.3rc6.

* Wed Jul 21 2010 David Malcolm <dmalcolm@redhat.com> - 0.2.0-0.rc1.2.1
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Tue Jan 12 2010 Richard W.M. Jones <rjones@redhat.com> - 0.2.0-0.rc1.2
- New upstream version 0.2.0rc1.

* Thu Nov  5 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.10-2
- Upstream URL and Source0 changed.

* Thu Oct  8 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.10-1
- New upstream version 0.1.10.
- Removed patch, since fix to CVE-2009-1753 (RHBZ#502174) is now upstream.

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.1.8-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Fri May 22 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.8-4
- New upstream version 0.1.8.
- Include patch from Debian to fix CVE-2009-1753 (RHBZ#502174).
- Segfaults on PPC64, so added to ExcludeArch.

* Thu Apr 16 2009 S390x secondary arch maintainer <fedora-s390x@lists.fedoraproject.org>
- ExcludeArch sparc64, s390, s390x as we don't have OCaml on those archs
  (added sparc64 per request from the sparc maintainer)

* Tue Mar 17 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.5-3
- Make the documentation subpackage "-doc" not "-docs".
- Comment about patch0 and send upstream.

* Mon Mar 16 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.5-2
- BR python-devel.

* Mon Mar 16 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.5-1
- New upstream version 0.1.5.
- Use the correct method to get Python sitelib (Michal Schmidt).

* Wed Jan 28 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.4-8
- Remove useless Makefiles from python/coccilib.
- License is GPLv2 (not GPLv2+).
- Include documentation and demos in subpackages.
- Move python library to a more sensible path.
- Add a check section.

* Mon Jan 26 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.4-6
- Install the shared library in _libdir.
- Install the native code version if we have the optimizing compiler.

* Wed Jan 21 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.4-3
- Patch for Python 2.6.

* Wed Jan 21 2009 Richard W.M. Jones <rjones@redhat.com> - 0.1.4-2
- Initial RPM release.