File rxtx-java.spec of Package rxtx-java

#
# spec file for package rxtx-java
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define src_name rxtx
%define upver 2.2
%define prever pre2
%define libversion 2
%define force_aqute_bnd 0
Name:           rxtx-java
Version:        %{upver}~%{prever}
Release:        0
Summary:        Full Java CommAPI implementation
License:        LGPL-2.1-or-later
Group:          Development/Libraries/Java
URL:            http://rxtx.qbang.org/wiki/index.php/Main_Page
Source0:        http://rxtx.qbang.org/pub/rxtx/%{src_name}-%{upver}%{prever}.zip
Source1:        rxtx-osgi.bnd
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:  pkgconfig
BuildRequires:  unzip
BuildRequires:  zip
BuildRequires:  pkgconfig(lockdev)
Requires:       librxtx%{libversion}
%if 0%{?sle_version} > 150100 || 0%{?suse_version} >= 1550 || %{force_aqute_bnd}
BuildRequires:  aqute-bnd
BuildRequires:  javapackages-local
%else
BuildRequires:  java-devel
BuildRequires:  javapackages-tools
%endif
%if 0%{?mdkversion}
Patch3:         rxtx-java-formatstring.patch
%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
Requires(pre):  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:          Development/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}-%{upver}%{prever}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%if 0%{?mdkversion}
%patch3 -p1
%endif
%patch4
%patch5 -p1
%patch6 -p1
%if %{?pkg_vcmp:%pkg_vcmp java-devel >= 1.8}%{!?pkg_vcmp:0}
%patch7 -p1
%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_build

%if 0%{?sle_version} > 150100 || 0%{?suse_version} >= 1550 || %{force_aqute_bnd}
# Inject OSGi metadata
bnd wrap -p %{SOURCE1} -v %{upver} -o RXTXcomm-bnd.jar RXTXcomm.jar
mv RXTXcomm-bnd.jar RXTXcomm.jar
%endif

# 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
%doc AUTHORS ChangeLog README RMISecurityManager.html INSTALL PORTING TODO
%license COPYING
%{_datadir}/java/RXTXcomm.jar

%files javadoc
%dir %{_javadocdir}
%doc %{_javadocdir}/%{name}-%{version}-javadoc.zip
%doc %{_javadocdir}/%{name}-javadoc.zip

%files src
%{_javadir}/%{name}-%{version}-src.zip

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

%files -n librxtx%{libversion}-devel
%{_includedir}/rxtx
%{_libdir}/*.la

%changelog
openSUSE Build Service is sponsored by