%bcond_with reflections
Name: jna
Version: 5.18.1
Release: 1
Summary: Pure Java access to native libraries
License: Apache-2.0 OR LGPL-2.1-or-later
URL: https://github.com/java-native-access/jna/
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
# Package list for prebuild
Source1: package-list
# Add RPM_LD_FLAGS for adapt build
Patch0000: 0001-Adapt-build.patch
# MODIFIED FROM UPSTREAM - we rip out all sorts of gunk here that is
# unnecessary when JNA is properly installed with the OS.
Patch0001: 0002-Load-system-library.patch
# The X11 tests currently segfault; overall I think the X11 JNA stuff is just a
# Really Bad Idea, for relying on AWT internals, using the X11 API at all,
# and using a complex API like X11 through JNA just increases the potential
# for problems.
Patch0002: 0003-Tests-headless.patch
# Adds --allow-script-in-comments arg to javadoc to avoid error
Patch0003: 0004-Fix-javadoc-build.patch
# Avoid generating duplicate manifest entry
Patch0004: 0005-Fix-duplicate-manifest-entry.patch
# Remove Werror flag for build
Patch0005: 0006-Remove-Werror.patch
Patch0006: 0007-Support-openjdk-17.patch
BuildRequires: gcc
BuildRequires: make
BuildRequires: javapackages-local
BuildRequires: libffi-devel
BuildRequires: ant
BuildRequires: ant-junit
BuildRequires: junit
BuildRequires: libX11-devel
BuildRequires: libXt-devel
BuildRequires: objectweb-asm
BuildRequires: hamcrest
%if %{with reflections}
BuildRequires: reflections
%endif
Requires: libffi
Provides: jna-contrib = %{version}-%{release}
Obsoletes: jna-contrib < %{version}-%{release}
%description
JNA provides Java programs easy access to native shared libraries
(DLLs on Windows) without writing anything but Java code. JNA's
design aims to provide native access in a natural way with a
minimum of effort. No boilerplate or generated code is required.
While some attention is paid to performance, correctness and ease
of use take priority.
%package help
Summary: Help docs for jna
BuildArch: noarch
Provides: jna-javadoc = %{version}-%{release}
Obsoletes: jna-javadoc < %{version}-%{release}
%description help
This package contains the help docs for jna.
%prep
%autosetup -n jna-%{version} -p1
cp %{SOURCE1} .
chmod -Rf a+rX,u+w,g-w,o-w .
sed -i 's|@LIBDIR@|%{_libdir}/jna|' src/com/sun/jna/Native.java
sed -i 's/TEMPLATE/%{version}/' pom-jna-jpms.xml \
pom-jna-platform.xml \
pom-jna.xml \
pom-jna-platform-jpms.xml
sed -i 's/\r//' LICENSE
chmod -c 0644 LICENSE OTHERS CHANGES.md
%if %{with reflections}
sed s,'<include name="junit.jar"/>,&<include name="reflections.jar"/>,' -i build.xml
build-jar-repository -s -p lib junit reflections
%else
build-jar-repository -s -p lib junit
rm test/com/sun/jna/StructureFieldOrderInspector.java
rm test/com/sun/jna/StructureFieldOrderInspectorTest.java
%endif
cp lib/native/aix-ppc64.jar lib/clover.jar
%build
ant -Drelease -Dcompatibility=1.8 -Dplatform.compatibility=1.8\
-Dcflags_extra.native="%{optflags}" -Ddynlink.native=true -DCC=%{__cc} native dist
find contrib -name build -exec rm -rf {} \; || :
%install
install -d -m 755 %{buildroot}%{_libdir}/%{name}
install -m 755 build/native*/libjnidispatch*.so %{buildroot}%{_libdir}/%{name}/
%mvn_file :jna jna jna/jna %{_javadir}/jna
%mvn_package :jna-platform contrib
%mvn_alias :jna-platform :platform
%mvn_artifact pom-jna.xml build/jna-min.jar
%mvn_artifact pom-jna-platform.xml contrib/platform/dist/jna-platform.jar
%mvn_install -J doc/javadoc
%files -f .mfiles -f .mfiles-contrib
%doc OTHERS README.md CHANGES.md TODO
%license LICENSE LGPL2.1 AL2.0
%{_libdir}/jna
%files help -f .mfiles-javadoc
%license LICENSE LGPL2.1 AL2.0
%changelog
* Mon May 25 2026 Ge Wang <wang__ge@126.com> - 5.18.1-1
- Update to 5.18.1
* Mon Mar 02 2026 yaoxin <1024769339@qq.com> - 5.15.0-1
- Update to 5.15.0
* Tue Jan 17 2023 caodongxia <caodongxia@h-partners.com> - 4.5.1-8
- Add source package-list
* Wed Jun 2 2021 wulei <wulei80@huawei.com> - 4.5.1-7
- fixes failed: gcc: command not found
* Tue Mar 3 2020 chenli <chenli147@huawei.com> - 4.5.1-6
- Fixed URL
* Fri Nov 22 2019 sunguoshuai <sunguoshuai@huawei.com> - 4.5.1-5
- Package init.