# # spec file for package zstd-jni # # Copyright (c) 2023 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/ # %{!?make_build:%global make_build make %{?_smp_mflags}} %global ver 1.5.4 %global rev 2 %global uver %{ver}-%{rev} %ifarch x86_64 %global archname amd64 %else %global archname %{_arch} %endif Name: zstd-jni Version: %{ver}.%{rev} Release: 0 Summary: JNI binding for Zstd License: BSD-2-Clause Group: Development/Libraries/Java URL: https://github.com/luben/%{name} Source0: %{url}/archive/refs/tags/v%{uver}.tar.gz Source1: https://repo1.maven.org/maven2/com/github/luben/%{name}/%{uver}/%{name}-%{uver}.pom Patch0: 00-load-system-library.patch BuildRequires: cmake BuildRequires: fdupes BuildRequires: gcc-c++ BuildRequires: maven-local BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) %if 0%{?sle_version}<=120500 BuildRequires: glibc-devel %endif %description JNI bindings for Zstd native library that provides fast and high compression lossless algorithm for Android, Java and all JVM languages: • static compress/decompress methods • implementation of InputStream and OutputStream for transparent compression of data streams fully compatible with the “zstd” program. • minimal performance overhead %package javadoc Summary: API documentation for %{name} Group: Documentation/HTML BuildArch: noarch %description javadoc API documentation for %{name} %prep %setup -q -n %{name}-%{uver} %patch -P 0 -p1 cp %{SOURCE1} pom.xml cat <<__JAVA__ >src/main/java/com/github/luben/zstd/util/ZstdVersion.java package com.github.luben.zstd.util; public class ZstdVersion { public static final String VERSION = "%{uver}"; } __JAVA__ sed -i \ -e 's#^project(%{name})#project(%{name} LANGUAGES C CXX ASM)#' \ -e '/add_definitions("-Oz")/d' \ CMakeLists.txt cat <<__CMAKELISTS__ >>CMakeLists.txt add_compile_options(%{optflags}) add_compile_options("-std=c99") add_compile_options("-Wundef") add_compile_options("-Wshadow") add_compile_options("-Wcast-align") add_compile_options("-Wstrict-prototypes") add_compile_options("-Wno-unused-variable") add_compile_options("-Wpointer-arith") add_compile_options("-flto") add_compile_options("-static-libgcc") add_compile_options("-lpthread") target_link_libraries(zstd-jni-\${NATIVE_VERSION} PRIVATE pthread) __CMAKELISTS__ # Specify the library name, depends on 00-load-system-library.patch sed -i -e 's#@SYS_LIBRARY_PREFIX@#%{_libdir}/%{name}#' \ src/main/java/com/github/luben/zstd/util/Native.java %pom_add_plugin org.apache.maven.plugins:maven-jar-plugin \ ' com.github.luben.zstd_jni ' %build %global __builddir . %if 0%{?sle_version}<=120500 export CFLAGS=-std=c99 %endif %cmake . %cmake_build %{mvn_build} -f -- \ -Dproject.build.outputTimestamp=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ) %install install -dm0755 %{buildroot}%{_libdir}/%{name} install -spm0755 lib%{name}-%{uver}.so %{buildroot}%{_libdir}/%{name} %mvn_install %fdupes %{buildroot}%{_javadocdir}/%{name} %files -f .mfiles %license LICENSE %doc README.md %{_libdir}/%{name} %files javadoc -f .mfiles-javadoc %license LICENSE %changelog