antlr/antlr.spec

232 lines
7.5 KiB
RPMSpec

#
# spec file for package antlr
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#
%define section free
Name: antlr
Version: 2.7.7
Release: 0
Summary: Another Tool for Language Recognition
License: GPL-2.0+ and SUSE-Public-Domain and MIT
Group: Development/Tools/Other
Url: http://www.antlr.org/
#Source0: http://www.antlr.org/download/antlr-2.7.4.tar.gz
Source0: %{name}-%{version}.tar.bz2
Source1: %{name}-build.xml
Source2: %{name}-script
Source3: http://www.antlr.org/share/1069557132934/makefile.gcj
Source1000: antlr-rpmlintrc
Patch0: %{name}-jedit.patch
Patch1: gcc45fix.diff
Patch2: fix-docpath.diff
BuildRequires: ant
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: java-devel
BuildRequires: libstdc++-devel
BuildRequires: python-devel
BuildRequires: unzip
BuildRequires: xml-commons-apis
Requires: %{name}-java
Requires: jpackage-utils
Provides: %{name}-bootstrap = %{version}
Obsoletes: %{name}-bootstrap < %{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%py_requires
%description
ANTLR, Another Tool for Language Recognition, (formerly PCCTS) is a
language tool that provides a framework for constructing recognizers,
compilers, and translators from grammatical descriptions containing C++
or Java actions (you can use PCCTS 1.xx to generate C-based parsers).
# To not introduce arch dependent java package, lets have this in separate subpackage
%package java
Summary: ANother Tool for Language Recognition (Manual)
Group: Development/Tools/Other
Requires: java >= 1.6.0
Provides: file:/%{_javadir}/%{name}.jar
BuildArch: noarch
%description java
ANTLR, Another Tool for Language Recognition, (formerly PCCTS) is a
language tool that provides a framework for constructing recognizers,
compilers, and translators from grammatical descriptions containing C++
or Java actions (you can use PCCTS 1.xx to generate C-based parsers).
This package provides the Java runtime for antlr
%package manual
Summary: ANother Tool for Language Recognition (Manual)
Group: Development/Tools/Other
BuildArch: noarch
%description manual
ANTLR, Another Tool for Language Recognition, (formerly PCCTS) is a
language tool that provides a framework for constructing recognizers,
compilers, and translators from grammatical descriptions containing C++
or Java actions (you can use PCCTS 1.xx to generate C-based parsers).
This package provides the manual and examples for antlr.
%package javadoc
Summary: ANother Tool for Language Recognition (Java Documentation)
Group: Development/Tools/Other
PreReq: coreutils
BuildArch: noarch
%description javadoc
ANTLR, Another Tool for Language Recognition, (formerly PCCTS) is a
language tool that provides a framework for constructing recognizers,
compilers, and translators from grammatical descriptions containing C++
or Java actions (you can use PCCTS 1.xx to generate C-based parsers).
This package provides the Javadoc for antlr.
%package devel
Summary: ANother Tool for Language Recognition (c++ runtime)
Group: Development/Tools/Other
Requires: antlr
%description devel
ANTLR, Another Tool for Language Recognition, (formerly PCCTS) is a
language tool that provides a framework for constructing recognizers,
compilers, and translators from grammatical descriptions containing C++
or Java actions (you can use PCCTS 1.xx to generate C-based parsers).
This package provides the C++ runtime (libantlr.a) and a headers files
of antlr
%package -n python-%{name}
Summary: ANother Tool for Language Recognition (python runtime)
Group: Development/Tools/Other
Requires: antlr
%py_requires
%description -n python-%{name}
Python support for generating your Lexers, Parsers and TreeParsers in Python.
This feature extends the benefits of ANTLR's predicated-LL(k) parsing
technology to the Python language and platform.
ANTLR Python support was contributed (and is to be maintained) by Wolfgang
Haefelinger and Marq Kole.
%prep
%setup -q
# remove all binary libs
find . -name "*.jar" -exec rm -f {} \;
%patch0 -p0
cp -p %{SOURCE1} build.xml
#Fix the source so that it compiles with GCC 4.5
%patch1 -p1
#Ensure that the manuals are installed in the correct openSUSE docpath
%patch2 -p0
# check for license problematic files:
find | grep "\(ShowString.java$\|StreamConverter.java$\)" && exit 42
%build
ant -Dj2se.apidoc=%{_javadocdir}/java
%configure
make
%py_compile lib/python/antlr
%install
# % {makeinstall}
# The upstream make install just installs a files to more or less random location
# instead of fixing it, let's install it in %%install section
#### jars ###
install -d -m 0755 %{buildroot}%{_javadir}
cp -a work/lib/%{name}.jar %{buildroot}%{_javadir}/%{name}-%{version}.jar
(cd %{buildroot}%{_javadir} && for jar in *-%{version}.jar; do ln -s -f ${jar} `echo $jar| sed "s|-%{version}||g"`; done)
# compat symlink
install -d -m 0755 %{buildroot}%{_datadir}/%{name}-%{version}/
ln -s -f %{_javadir}/%{name}-%{version}.jar %{buildroot}%{_datadir}/%{name}-%{version}/%{name}.jar
### scripts ###
install -d -m 0755 %{buildroot}%{_bindir}/
install -m 0755 %{SOURCE2} %{buildroot}%{_bindir}/%{name}
install -m 0755 scripts/%{name}-config %{buildroot}%{_bindir}/
### javadoc ###
install -d -m 0755 %{buildroot}%{_javadocdir}/%{name}
cp -ar work/api/* %{buildroot}%{_javadocdir}/%{name}
### python runtime ###
install -d -m 0755 %{buildroot}%{py_sitedir}/%{name}
cp -a lib/python/antlr/* %{buildroot}%{py_sitedir}/%{name}
# compat symlink
ln -s -f %{py_sitedir}/%{name}/*.py %{buildroot}%{_datadir}/%{name}-%{version}/
ln -s -f %{py_sitedir}/%{name}/*.pyc %{buildroot}%{_datadir}/%{name}-%{version}/
### cpp runtime ###
install -m 0644 lib/cpp/src/lib%{name}.a %{buildroot}%{_libdir}
install -d -m 0755 %{buildroot}%{_includedir}/%{name}
install -m 0644 lib/cpp/%{name}/*hpp %{buildroot}%{_includedir}/%{name}
### find duplicates ###
find examples -type f | xargs chmod 0644
%fdupes -s examples
%clean
rm -rf %{buildroot}
%check
# % {__make} check
# % post -p /sbin/ldconfig
# % postun -p /sbin/ldconfig
%files
%defattr(0644,root,root,0755)
%doc %attr(644,-,-) LICENSE.txt README.txt CHANGES.txt
%dir %{_datadir}/%{name}-%{version}
%defattr(0755,root,root,0755)
%{_bindir}/antlr
%{_bindir}/antlr-config
%files java
%defattr(0644,root,root,0755)
%dir %{_datadir}/%{name}-%{version}
%{_datadir}/%{name}-%{version}/*jar
%{_javadir}/%{name}*.jar
%files manual
%defattr(0644,root,root,0755)
%doc doc examples
%files javadoc
%defattr(0644,root,root,0755)
%doc %{_javadocdir}/%{name}
%files devel
%defattr(0644,root,root)
%attr(755,root,root) %{_libdir}/libantlr.a
%{_includedir}/%{name}
%files -n python-%{name}
%defattr(-,root,root)
%dir %{_datadir}/%{name}-%{version}
%{_datadir}/%{name}-%{version}/*py
%{_datadir}/%{name}-%{version}/*pyc
%py_sitedir/%{name}
%changelog