File rxtx-java.spec of Package rxtx-java

#
# spec file for package rxtx-java
#
# Copyright (c) 2015 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 src_name rxtx
%define libversion 2
Name:           rxtx-java
Version:        2.2pre2
Release:        lp150.11.2
Summary:        Full Java CommAPI implementation
License:        LGPL-2.1+
Group:          Development/Libraries/Java
Url:            http://rxtx.qbang.org/wiki/index.php/Main_Page
Source0:        %{src_name}-%{version}.zip
#Source0:       %{src_name}-%{version}.tar.bz2
Patch0:         rxtx-java-arduinouno.diff
Patch1:         rxtx-java-disable-crazy-version-tests.diff
Patch2:         rxtx-java-error.diff
Patch4:         rxtx-java-sysio.patch
Patch5:         rxtx-java-38400.patch
Patch6:         rxtx-java-version.patch
Patch7:         rxtx-java-missing-javah.patch
BuildRequires:  automake
BuildRequires:  libtool
BuildRequires:  unzip
BuildRequires:  zip
# this Requires imports the path we install stuff into
# there must be a better way to get that result.
Requires:       java
Requires:       librxtx%{libversion}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?mdkversion}
Patch3:         rxtx-java-formatstring.patch
%endif
%if 0%{?suse_version} > 1130
BuildRequires:  pkgconfig(lockdev)
%endif
%if 0%{?suse_version} && 0%{?suse_version} < 1100
# the java installation fails on SLES10 without this...
BuildRequires:  java-devel
BuildRequires:  update-alternatives
%else
BuildRequires:  java-devel >= 1.6.0
BuildRequires:  java-devel <= 1.8.0
%endif

%description
RxTx is a Java library, using a native implementation (via JNI), providing serial
and parallel communication for the Java Development Toolkit (JDK). It is based on
the specification for Sun's Java Communications API.

%package javadoc
Summary:        Javadocs for rxtx-java
Group:          Documentation/HTML
# FIXME: use proper Requires(pre/post/preun/...)
PreReq:         coreutils

%description javadoc
RxTx is a Java library, using a native implementation (via JNI), providing serial
and parallel communication for the Java Development Toolkit (JDK). It is based on
the specification for Sun's Java Communications API.

%package src
Summary:        Java Sources for rxtx-java
Group:          Documentation/Sources

%description src
RxTx is a Java library, using a native implementation (via JNI), providing serial
and parallel communication for the Java Development Toolkit (JDK). It is based on
the specification for Sun's Java Communications API.

%package -n librxtx%{libversion}
Summary:        Full Java CommAPI implementation native library
Group:          Development/Libraries/C and C++

%description -n librxtx%{libversion}
RxTx is a Java library, using a native implementation (via JNI), providing serial
and parallel communication for the Java Development Toolkit (JDK). It is based on
the specification for Sun's Java Communications API.

%package -n librxtx%{libversion}-devel
Summary:        Full Java CommAPI implementation native library include
Group:          Development/Sources

%description -n librxtx%{libversion}-devel
RxTx is a Java library, using a native implementation (via JNI), providing serial
and parallel communication for the Java Development Toolkit (JDK). It is based on
the specification for Sun's Java Communications API.

%prep
%setup -q -n %{src_name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%if 0%{?mdkversion}
%patch3 -p1
%endif
%patch4
%patch5 -p1
%patch6 -p1
%if 0%{?suse_version} > 1500
%patch7 -p1
%else
%if 0%{?sle_version} == 150000 && 0%{?is_opensuse}
%patch7 -p1
%endif
%endif

%build
export THREADS_FLAG=native
rm acinclude.m4 config.guess config.sub install-sh ltmain.sh missing mkinstalldirs aclocal.m4 Makefile.in ltconfig stamp-h.in
./autogen.sh
CFLAGS="%{optflags}" LDFLAGS=-s \
	%configure \
%if 0%{?suse_version} > 1130
	--enable-liblock=yes
%endif

make %{?_smp_mflags}

# build javadoc
mkdir -p javadoc
javadoc -d javadoc src/gnu/io/*.java
cd javadoc
zip -r ../%{name}-%{version}-javadoc.zip .
cd ..

%install
mkdir -p %{buildroot}%{_javadir} %{buildroot}%{_libdir}
make RXTX_PATH=%{buildroot}%{_libdir} JHOME=%{buildroot}%{_javadir} install

find %{buildroot}%{_prefix} -xtype f -print | \
    sed "s@^$RPM_BUILD_ROOT@@g" > INSTALLED_FILES

if [ "$(cat INSTALLED_FILES)X" = "X" ] ; then
    echo "No files!"
    exit -1
fi

# install javadoc
mkdir -p %{buildroot}%{_javadocdir}
cp %{name}-%{version}-javadoc.zip %{buildroot}%{_javadocdir}
pushd %{buildroot}%{_javadocdir}
ln -s %{name}-%{version}-javadoc.zip %{name}-javadoc.zip
popd

# install src files
cd src
zip -r ../%{name}-%{version}-src.zip gnu/io/
cd ..
cp %{name}-%{version}-src.zip %{buildroot}%{_javadir}

# install lib devel files
mkdir -p %{buildroot}%{_includedir}/rxtx
cp src/*.h %{buildroot}%{_includedir}/rxtx

%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog README RMISecurityManager.html COPYING INSTALL PORTING TODO
%{_datadir}/java/RXTXcomm.jar

%files javadoc
%defattr(-,root,root)
%dir %{_javadocdir}
%doc %{_javadocdir}/%{name}-%{version}-javadoc.zip
%doc %{_javadocdir}/%{name}-javadoc.zip

%files src
%defattr(-,root,root)
%{_javadir}/%{name}-%{version}-src.zip

%files -n librxtx%{libversion}
%defattr(755,root,root)
%{_libdir}/*.so

%files -n librxtx%{libversion}-devel
%defattr(-,root,root)
%{_includedir}/rxtx
%{_libdir}/*.la

%changelog
* Sat Apr 14 2018 F.Schuette@t-online.de
- make patch work for leap 15.0
* Tue Feb 27 2018 F.Schuette@t-online.de
- javah is missing from java-9, patch to use javac -h instead
* Sun Oct  1 2017 F.Schuette@t-online.de
- change source, target to 1.6
* Sun Oct  1 2017 F.Schuette@t-online.de
- BuildRequires java-devel <= 1.8.0
* Tue May  5 2015 F.Schuette@t-online.de
- changed 38400 patch like dstoecker suggested
* Sat May  2 2015 F.Schuette@t-online.de
- remove rules file, user has to be in dialout and lock
* Fri May  1 2015 F.Schuette@t-online.de
- fix serial baudrate 38400 not possible
- fix version # 2.2.pre2
- split package
* Fri May 31 2013 dvaleev@suse.com
- Detect if sysio available (rxtx-java-sysio.patch)
* Fri Dec 30 2011 seife+obs@b1-systems.com
- buildrequire automake and libtool to fix Factory build
* Sat Sep 24 2011 seife+obs@b1-systems.com
- fix build for SLES10, remove always false %%if clause
* Sat Sep 17 2011 seife+obs@b1-systems.com
- also fix build on SLES11SP1
* Sat Sep 17 2011 seife+obs@b1-systems.com
- fix build on openSUSE 11.3  (no pkgconfig() stuff)
* Sat Sep 17 2011 seife+obs@b1-systems.com
- use liblockdev to lock devices
- report locking problems with hint on possible problem
- fix build on newer kernels (no UTS_RELEASE)
* Fri Aug 26 2011 seife+obs@b1-systems.com
- add ttyACM ports so that it works with arduino uno
* Sun Aug 22 2010 kkaempf@novell.com
- update to 2.2pre2
* Sun Mar 11 2007 developer@jefferyfernandez.id.au
- Initial Release for openSUSE