%global majorver 1
%global minorver 27
%global patchver 2
Name:                genders
Version:             %{majorver}.%{minorver}.%{patchver}
Release:             1
Summary:             Static cluster configuration database
License:             GPLv2
URL:                 https://github.com/chaos/genders
Source:              https://github.com/chaos/genders/archive/genders-%{majorver}-%{minorver}-%{patchver}.tar.gz
Patch0:              %{name}-1.18-shebang.patch
Patch1:              %{name}-1.22-javadoc.patch
BuildRequires:       gcc-c++ gcc bison flex autoconf
%description
Genders is a static cluster configuration database used for cluster
configuration management.  It is used by a variety of tools and
scripts for management of large clusters.  The genders database is
typically replicated on every node of the cluster. It describes the
layout and configuration of the cluster so that tools and scripts can
sense the variations of cluster nodes. By abstracting this information
into a plain text file, it becomes possible to change the
configuration of a cluster by modifying only one file.

%package compat
Summary:             Compatibility library
BuildRequires:       perl-devel perl-generators perl(ExtUtils::MakeMaker)
BuildArch:           noarch
%description compat
Genders API that is compatible with earlier releases of genders.

%package perl
Summary:             Perl libraries
BuildRequires:       perl(ExtUtils::MakeMaker) perl(Config)
%description perl
Genders API bindings for perl.

%package javadoc
Summary:             Java Documentation
BuildRequires:       java-devel
%description javadoc
Genders API Documentation for java.

%package java-devel
Summary:             Java Development libraries
Requires:            %{name}-java%{?_isa} = %{version}-%{release}
%description java-devel
Genders API bindings for java.

%package java
Summary:             Java libraries
BuildRequires:       java-devel make
%description java
Genders API bindings for java.
%global __provides_exclude_from ^(.%{perl_vendorarch}/*\\.so)$

%package -n libgenders
Summary:             Genders libraries
%description -n libgenders
Genders API for C.

%package -n libgenders-devel
Summary:             Genders development libraries
Requires:            libgenders%{?_isa} = %{version}-%{release}
%description -n libgenders-devel
Genders development headers and libraries for C.

%package -n libgendersplusplus
Summary:             Genders libraries for C++
Requires:            libgenders%{?_isa} = %{version}-%{release}
%description -n libgendersplusplus
Genders API for C++.

%package -n libgendersplusplus-devel
Summary:             Genders development libraries
Requires:            libgenders-devel%{?_isa} = %{version}-%{release}
Requires:            libgendersplusplus%{?_isa} = %{version}-%{release}
%description -n libgendersplusplus-devel
Genders development headers and libraries for C++.

%prep
%setup  -q -n %{name}-%{name}-%{majorver}-%{minorver}-%{patchver}
%patch0 -p1
%patch1 -p1

%build
export CPPFLAGS='-I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux -I../../../src/libgenders'
%configure \
    --with-perl-extensions \
    --with-perl-vendor-arch \
    --without-python-extensions \
    --with-cplusplus-extensions \
    --with-extension-destdir="%{buildroot}"
%{__make}

%install
rm -rf %{buildroot}
DESTDIR=%{buildroot} make install
rm -f %{buildroot}/%{_libdir}/*.la
rm -f %{buildroot}/%{_libdir}/*.a
chmod +w %{buildroot}/%{perl_vendorarch}/auto/Lib%{name}/Lib%{name}.so
rm -f %{buildroot}/%{perl_vendorarch}/auto/Lib%{name}/Lib%{name}.bs
rm -f %{buildroot}/%{perl_vendorarch}/auto/Lib%{name}/.packlist
mkdir -p %{buildroot}/%{_libexecdir}
mkdir -p %{buildroot}/%{_jnidir}
mv %{buildroot}/%{_datarootdir}/java/Genders.jar %{buildroot}/%{_jnidir}/
%ldconfig_scriptlets -n libgenders
%ldconfig_scriptlets -n libgendersplusplus
%ldconfig_scriptlets -n genders-java

%files
%doc README NEWS ChangeLog DISCLAIMER DISCLAIMER.UC COPYING TUTORIAL genders.sample
%{_mandir}/man1/*
%{_mandir}/man3/genders.3*
%{_bindir}/*

%files -n libgenders
%doc DISCLAIMER DISCLAIMER.UC COPYING
%{_libdir}/libgenders.so.0*
%{_mandir}/man3/libgenders.3*

%files -n libgenders-devel
%doc DISCLAIMER DISCLAIMER.UC COPYING
%{_mandir}/man3/genders_*
%{_includedir}/genders.h
%{_libdir}/libgenders.so

%files -n libgendersplusplus
%doc DISCLAIMER DISCLAIMER.UC COPYING
%{_libdir}/libgendersplusplus.so.2*

%files -n libgendersplusplus-devel
%doc DISCLAIMER DISCLAIMER.UC COPYING
%{_libdir}/libgendersplusplus.so
%{_includedir}/gendersplusplus*

%files perl
%doc DISCLAIMER DISCLAIMER.UC COPYING
%{_mandir}/man3/Libgenders*
%{_mandir}/man3/Genders*
%{perl_vendorarch}/*

%files java-devel
%doc DISCLAIMER DISCLAIMER.UC COPYING
%{_libdir}/libGendersjni.so

%files java
%doc DISCLAIMER DISCLAIMER.UC COPYING
%{_libdir}/libGendersjni.so.*
%{_jnidir}/Genders.jar

%files javadoc
%doc DISCLAIMER DISCLAIMER.UC COPYING
%{_docdir}/%{name}-%{majorver}.%{minorver}-javadoc

%files compat
%doc DISCLAIMER DISCLAIMER.UC COPYING
%{_mandir}/man3/gendlib*
%{_usr}/lib/genders/*

%changelog
* Mon Sep 6 2021 wulei <wulei80@huawei.com> - 1.27.2-1
- package init