Package antlr: Specfile

Group: Development/Java
# BEGIN SourceDeps(oneline):
BuildRequires(pre): rpm-build-python rpm-macros-fedora-compat
BuildRequires: rpm-build-java
# END SourceDeps(oneline)
BuildRequires: /proc
BuildRequires: jpackage-generic-compat
# fedora bcond_with macro
%define bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
%define bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
# redefine altlinux specific with and without
%define with()         %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
%define without()      %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
# see https://bugzilla.altlinux.org/show_bug.cgi?id=10382
%define _localstatedir %{_var}
%bcond_without doxygen
%bcond_without python

%global debug_package %{nil}
# since we have only a static library

Summary:       ANother Tool for Language Recognition
Name:          antlr
Version:       2.7.7
Release:       alt12_53jpp8
Epoch:         0
License:       ANTLR-PD
URL:           http://www.antlr2.org/
Source0:       http://www.antlr2.org/download/antlr-%{version}.tar.gz
Source1:       %{name}-build.xml
Source2:       %{name}-script
Source3:       http://repo2.maven.org/maven2/antlr/antlr/%{version}/%{name}-%{version}.pom
Patch1:        %{name}-%{version}-newgcc.patch
# see BZ#848662
Patch2:        antlr-examples-license.patch

%ifarch %{mono_arches}
%if ! 0%{?rhel} >= 6
BuildRequires: mono-core mono-data mono-devel mono-extras mono-web
BuildRequires: mono-winforms
%endif
%endif
BuildRequires: gcc-c++
BuildRequires: ant
BuildRequires: java-devel >= 1.7.0
BuildRequires: java-javadoc
BuildRequires: javapackages-local
%if %{with doxygen}
BuildRequires: doxygen graphviz libgraphviz
%endif
%if %{with python}
# Do not support Python3
BuildRequires: python-devel
BuildRequires: python-module-setuptools
%endif
Source44: import.info

%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].

%package     tool
Group: Development/Java
Summary:       ANother Tool for Language Recognition
Provides:      %{name} = %{version}-%{release}
BuildArch:     noarch

%description tool
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].

%package     manual
Group: Development/Java
Summary:       Manual for %{name}
BuildArch:     noarch

%description manual
Documentation for %{name}.

%package     javadoc
Group: Development/Java
Summary:       Javadoc for %{name}
BuildArch:     noarch

%description javadoc
Javadoc for %{name}.

%package     C++
Group: Development/Java
Summary:       C++ bindings for antlr2 generated parsers
Provides:      antlr-static = %{version}-%{release}

%description C++
This package provides a static C++ library for parsers generated by ANTLR2.

%if %{with doxygen}
%package     C++-doc
Group: Development/Java
Summary:       Documentation for C++ bindings for antlr2 generated parsers
BuildArch:     noarch

%description C++-doc
This package contains the documentation for the C++ bindings for parsers
generated by ANTLR2.
%endif

%if %{with python}
%package     -n python-module-antlr
Group: Development/Java
Summary:       Python 2 runtime support for ANTLR-generated parsers
%{?python_provide:%python_provide python2-%{name}}

# This can be removed in Fedora 30
Provides:      %{name}-python = %{version}-%{release}
Obsoletes:     %{name}-python < 2.7.7-48

BuildArch:     noarch

Obsoletes: python-module-antlr2 <= 0:2.7.7-alt11_13jpp6.1
Conflicts: python-module-antlr2 <= 0:2.7.7-alt11_13jpp6.1


%description -n python-module-antlr
Python runtime support for ANTLR-generated parsers
%endif

%prep
%setup -q
# remove all binary libs
find . -name "*.jar" -exec rm -f {} \;
cp -p %{SOURCE1} build.xml
%patch1
%patch2 -p1
# CRLF->LF
sed -i 's/\r//' LICENSE.txt

# set jar location
%mvn_file %{name}:%{name} %{name}

%build
ant -Dj2se.apidoc=%{_javadocdir}/java
# make expects to find it here
cp work/lib/antlr.jar .
export CLASSPATH=.
%configure --without-examples
make CXXFLAGS="${CXXFLAGS} -fPIC" DEBUG=1 verbose=1
# no longer needed
rm antlr.jar

# fix doc permissions and remove Makefiles
rm doc/{Makefile,Makefile.in}
chmod 0644 doc/*

%if %{with doxygen}
# generate doxygen docs for C++ bindings
pushd lib/cpp
  doxygen doxygen.cfg
  find gen_doc -type f -exec chmod 0644 {} \;
popd
%endif

%if %{with python}
# build python
cd lib/python
%python_build
cd ../../
%endif

%install
# jars, POM and depmap
%mvn_artifact %{SOURCE3} work/lib/%{name}.jar
%mvn_alias %{name}:%{name} %{name}:%{name}all
%mvn_install -J work/api

mkdir -p $RPM_BUILD_ROOT{%{_includedir}/%{name},%{_libdir},%{_bindir}}
# script
install -p -m 755 %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}/antlr

# C++ lib and headers, antlr-config
install -p -m 644 lib/cpp/antlr/*.hpp $RPM_BUILD_ROOT%{_includedir}/%{name}
install -p -m 644 lib/cpp/src/libantlr.a $RPM_BUILD_ROOT%{_libdir}
install -p -m 755 scripts/antlr-config $RPM_BUILD_ROOT%{_bindir}

%if %{with python}
# python
cd lib/python
%python_install
cd ../..
%endif
chmod 755 $RPM_BUILD_ROOT%{_bindir}/*


%files tool -f .mfiles
%doc --no-dereference LICENSE.txt
%{_bindir}/antlr

# this is actually a development package for the C++ target
# as we ship only a static library, it doesn't make sense
# to have a separate -devel package for the headers
%files C++
%doc --no-dereference LICENSE.txt
%{_includedir}/%{name}
%{_libdir}/libantlr.a
%{_bindir}/antlr-config

%if %{with doxygen}
%files C++-doc
%doc --no-dereference LICENSE.txt
%doc lib/cpp/gen_doc/html/
%endif

%files manual
%doc --no-dereference LICENSE.txt
%doc doc/*

%files javadoc -f .mfiles-javadoc
%doc --no-dereference LICENSE.txt

%if %{with python}
%files -n python-module-antlr
%doc --no-dereference LICENSE.txt
%{python_sitelibdir_noarch}/antlr/*
%{python_sitelibdir_noarch}/antlr-*
%endif

%changelog
* Tue May 08 2018 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt12_53jpp8
- java update

* Wed Nov 22 2017 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt12_52jpp8
- new fc release

* Thu Nov 09 2017 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt12_51jpp8
- fc27 update

* Thu Nov 02 2017 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt12_47jpp8
- new jpp release

* Fri Dec 16 2016 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt12_43jpp8
- new fc release

* Tue Nov 22 2016 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt12_40jpp8
- new fc release

* Thu Feb 04 2016 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt12_37jpp8
- added python obsoletes.

* Tue Feb 02 2016 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt11_37jpp8
- new version

* Wed Nov  5 2014 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 0:2.7.7-alt11_13jpp6.1
- Added module for Python

* Fri Jul 11 2014 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt11_13jpp6
- NMU rebuild to move _mavenpomdir and _mavendepmapfragdir

* Wed Oct 03 2012 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt10_13jpp6
- added ant-junit BR:

* Wed Jun 13 2012 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt9_13jpp6
- added gcj and tool subpackage

* Tue Jun 12 2012 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt8_13jpp6
- build with source and target 1.5

* Mon Jun 11 2012 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt7_13jpp7
- restored antlr-native

* Sat Jan 28 2012 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt7_13jpp6
- new jpp relase

* Tue Mar 30 2010 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt7_1jpp5
- fixed misprint in repolib

* Sun May 10 2009 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt6_1jpp5
- fixed build with gcc44

* Mon Mar 30 2009 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt5_1jpp5
- added repolib

* Tue Nov 25 2008 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt4_1jpp5
- fixed build with gcc43

* Mon Apr 21 2008 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt4_1jpp1.7
- added conflict for .so

* Sat Apr 12 2008 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt3_1jpp1.7
- fixed script permissions

* Thu Aug 02 2007 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt2_1jpp1.7
- converted from JPackage by jppimport script

* Thu Aug 02 2007 Igor Vlasenko <viy@altlinux.ru> 0:2.7.7-alt1_1jpp1.7
- converted from JPackage by jppimport script

* Sat Mar 04 2006 Mikhail Zabaluev <mhz@altlinux.ru> 2.7.6-alt1
- 2.7.6
- Added README.txt to the docs list
- Set source and target compiler attributes

* Tue Feb 01 2005 Mikhail Zabaluev <mhz@altlinux.ru> 2.7.5-alt1
- New upstream release
- Converted to rpm-build-java macros

* Mon Jun 07 2004 Mikhail Zabaluev <mhz@altlinux.ru> 2.7.4-alt1
- New upstream release

* Sat Apr 17 2004 Mikhail Zabaluev <mhz@altlinux.ru> 2.7.3-alt1
- New upstream release

* Wed Sep 10 2003 Mikhail Zabaluev <mhz@altlinux.ru> 2.7.2-alt1
- Ported to ALT Linux from JPackage 2.7.2-2jpp