File javacc3.spec of Package javacc3

#
# spec file for package javacc3
#
# Copyright (c) 2017 SUSE LINUX 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 _with_repolib 1
# If you want repolib package to be built,
# issue the following: 'rpmbuild --with repolib'
%define with_repolib %{?_with_repolib:1}%{!?_with_repolib:0}
%define without_repolib %{!?_with_repolib:1}%{?_with_repolib:0}
%define repodir %{_javadir}/repository.jboss.com/sun-javacc/3.2-brew
%define repodirlib %{repodir}/lib
%define repodirsrc %{repodir}/src
%define section free
%define _basename javacc
Name:           javacc3
Version:        3.2
Release:        0
Summary:        A parser/scanner generator for java
License:        SUSE-BSD-3-Clause-with-non-nuclear-addition
Group:          Development/Libraries/Java
Url:            https://javacc.dev.java.net/
Source0:        javacc-3.2-src.tar.bz2
Source1:        javacc
Source2:        jjdoc
Source3:        jjtree
Source4:        javacc-component-info.xml
Patch0:         javacc-encoding.patch
BuildRequires:  ant
BuildRequires:  java-devel
BuildRequires:  perl
Requires:       javapackages-tools
BuildArch:      noarch

%description
Java Compiler Compiler (JavaCC) is the most popular parser generator
for use with Java applications. A parser generator is a tool that reads
a grammar specification and converts it to a Java program that can
recognize matches to the grammar. In addition to the parser generator
itself, JavaCC provides other standard capabilities related to parser
generation such as tree building (via a tool called JJTree included
with JavaCC), actions, debugging, etc.

%if %{with_repolib}
%package	repolib
Summary:        A parser/scanner generator for java
Group:          Development/Libraries/Java

%description	 repolib
Java Compiler Compiler (JavaCC) is the most popular parser generator
for use with Java applications. A parser generator is a tool that reads
a grammar specification and converts it to a Java program that can
recognize matches to the grammar. In addition to the parser generator
itself, JavaCC provides other standard capabilities related to parser
generation such as tree building (via a tool called JJTree included
with JavaCC), actions, debugging, etc.

%endif

%package        manual
Summary:        A parser/scanner generator for java
Group:          Development/Libraries/Java

%description manual
Java Compiler Compiler (JavaCC) is the most popular parser generator
for use with Java applications. A parser generator is a tool that reads
a grammar specification and converts it to a Java program that can
recognize matches to the grammar. In addition to the parser generator
itself, JavaCC provides other standard capabilities related to parser
generation such as tree building (via a tool called JJTree included
with JavaCC), actions, debugging, etc.

%package demo
Summary:        A parser/scanner generator for java
Group:          Development/Libraries/Java

%description demo
Java Compiler Compiler (JavaCC) is the most popular parser generator
for use with Java applications. A parser generator is a tool that reads
a grammar specification and converts it to a Java program that can
recognize matches to the grammar. In addition to the parser generator
itself, JavaCC provides other standard capabilities related to parser
generation such as tree building (via a tool called JJTree included
with JavaCC), actions, debugging, etc.

%prep
%setup -q -n %{_basename}-%{version}
%patch0 -p1
cp %{SOURCE1} javacc3
cp %{SOURCE2} jjdoc3
cp %{SOURCE3} jjtree3
mv www/doc .
tag=`echo %{name}-%{version}-%{release} | sed 's|\.|_|g'`
sed -i "s/@TAG@/$tag/g" %{SOURCE4}
# enum is a reserved word in java5+.
# For that reason we do this ugly hack that works nevertheless
perl -pi -e 's#enum#emun#g' bootstrap/javacc.jar
perl -pi -e 's#enum#emun#g' $(find . -name "*.java")
perl -pi -e 's#enum#emun#g' $(find . -name "*.jj")

%build
ant \
  -Dant.build.javac.source=1.6 \
  -Dversion=%{version} \
  jar

%install
install -d -m 755 %{buildroot}%{_javadir}
install -m 644 bin/lib/%{_basename}.jar %{buildroot}%{_javadir}/%{name}-%{version}.jar
ln -s %{name}-%{version}.jar %{buildroot}%{_javadir}/%{name}.jar
install -d -m 755 %{buildroot}%{_bindir}
install -m 755 javacc3 jjdoc3 jjtree3 %{buildroot}%{_bindir}
install -d -m 755 %{buildroot}%{_datadir}/%{name}
cp -pr examples %{buildroot}%{_datadir}/%{name}
%if %{with_repolib}
	install -d -m 755 %{buildroot}%{repodir}
	install -d -m 755 %{buildroot}%{repodirlib}
	install -m 755 %{SOURCE4} %{buildroot}%{repodir}/component-info.xml
	install -d -m 755 %{buildroot}%{repodirsrc}
	install -m 755 %{SOURCE0} %{buildroot}%{repodirsrc}
	cp %{buildroot}%{_javadir}/javacc3.jar %{buildroot}%{repodirlib}/javacc.jar
%endif

%files
%{_javadir}/*.jar
%doc LICENSE README
%defattr(0755,root,root,0755)
%{_bindir}/*
%dir %{_javadir}/repository.jboss.com
%dir %{_javadir}/repository.jboss.com/sun-javacc

%files manual
%doc doc/*

%files demo
%{_datadir}/%{name}
%if %{with_repolib}
%files repolib
%dir %{_javadir}/repository.jboss.com
%{repodir}
%endif

%changelog
openSUSE Build Service is sponsored by