File jansi-native.spec of Package jansi-native

# spec file for package jansi-native
# Copyright (c) 2019 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

%global bits %{__isa_bits}
%global debug_package %{nil}
Name:           jansi-native
Version:        1.7
Release:        0
Summary:        Jansi project JNI library implementation
License:        Apache-2.0
Group:          Development/Libraries/Java
Source1:        %{name}-build.xml
BuildRequires:  ant
BuildRequires:  fdupes
BuildRequires:  gcc
BuildRequires:  hawtjni
BuildRequires:  javapackages-local
Requires:       mvn(org.fusesource.hawtjni:hawtjni-runtime)

Jansi is a Java library that allows you to use ANSI escape sequences
in Java console applications. It implements ANSI support on platforms
which don't support it like Windows and provides graceful degradation for
when output is being sent to output devices which cannot support ANSI sequences.

%package javadoc
Summary:        Javadocs for %{name}
Group:          Documentation/HTML
BuildArch:      noarch

%description javadoc
This package contains the API documentation for %{name}.

%setup -q -n jansi-native-jansi-native-%{version}
cp %{SOURCE1} .

%pom_xpath_remove pom:profiles

cp pom.xml pom-linux%{bits}.xml
%pom_xpath_set pom:project/pom:artifactId %{name} pom.xml
%pom_xpath_set pom:project/pom:artifactId jansi-linux%{bits} pom-linux%{bits}.xml

%pom_remove_parent .

mkdir -p lib
build-jar-repository -s lib hawtjni/hawtjni-runtime

%{ant} -f %{name}-build.xml jar javadoc

# Create a manifest-only jar
%{ant} -f %{name}-build.xml -Dproject.platform=linux%{bits} manifest-jar

# generate the C files for native library
mkdir -p target/native-build
hawtjni-generator \
  -n jansi \
  -o target/native-build \
  -p org.fusesource.jansi.internal \
  -v \

# build the native library
mkdir -p target/native-build/META-INF/native/linux%{bits}
gcc -shared \
  -o target/native-build/META-INF/native/linux%{bits}/ \
  -I %{_jvmlibdir}/java/include/ -I %{_jvmlibdir}/java/include/linux/ \
  -I src/main/native-package/src -I target/native-build \
  -fPIC target/native-build/*.c src/main/native-package/src/*.c
jar uf target/jansi-linux%{bits}-%{version}.jar -C target/native-build META-INF

# jar
install -dm 0755 %{buildroot}%{_jnidir}/%{name}
install -pm 0644 target/%{name}-%{version}.jar %{buildroot}%{_jnidir}/%{name}/%{name}.jar
install -pm 0644 target/jansi-linux%{bits}-%{version}.jar %{buildroot}%{_jnidir}/%{name}/jansi-linux%{bits}.jar
ln -sf jansi-linux%{bits}.jar %{buildroot}%{_jnidir}/%{name}/jansi-linux.jar
# pom
install -dm 0755 %{buildroot}%{_mavenpomdir}/%{name}
install -pm 0644 pom.xml %{buildroot}%{_mavenpomdir}/%{name}/%{name}.pom
%add_maven_depmap %{name}/%{name}.pom %{name}/%{name}.jar
install -pm 0644 pom-linux%{bits}.xml %{buildroot}%{_mavenpomdir}/%{name}/jansi-linux%{bits}.pom
%add_maven_depmap %{name}/jansi-linux%{bits}.pom %{name}/jansi-linux%{bits}.jar -a org.fusesource.jansi:jansi-linux
# javadoc
install -dm 0755 %{buildroot}%{_javadocdir}/%{name}
cp -pr target/site/apidocs/* %{buildroot}%{_javadocdir}/%{name}
%fdupes -s %{buildroot}%{_javadocdir}

%files -f .mfiles
%license license.txt

%files javadoc