File mingw64-rhash.spec of Package mingw64-rhash

#
# spec file for package rhash
#
# Copyright (c) 2022 SUSE LLC, 2023 Stephan Jauernick for mingw64 port
#
# 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/
#

# TODO: figure out why gettext fails with libintl_

%define _mingw mingw64
%define major   0

Name:           %{_mingw}-rhash
Version:        1.4.3
Release:        0
Summary:        Recursive Hasher
License:        0BSD
URL:            https://github.com/rhash/RHash
Source0:        https://github.com/rhash/RHash/archive/v%{version}.tar.gz#/rhash-%{version}.tar.gz
BuildRequires:  mingw64-cross-pkg-config
BuildRequires:  mingw64-filesystem >= 35
BuildRequires:  mingw64-cross-gcc
#BuildRequires:  mingw64-libintl-devel

%_mingw64_package_header_debug
BuildArch:      noarch

%description
RHash (Recurcive Hasher) is a console utility for computing and
verifying magnet links and hash sums of files.
It supports CRC32, MD4, MD5, SHA1/SHA2, Tiger, DC++ TTH, BitTorrent
BTIH, AICH, eDonkey hash, GOST R 34.11-94, RIPEMD-160, HAS-160, EDON-R,
Whirlpool and Snefru hash algorithms. Hash sums are used to ensure and
verify integrity of large volumes of data for a long-term storing or
transferring.

Program features:
 * Calculation of Magnet links and EDonkey 2000 links.
 * Output in a predefined (SFV, BSD-like) or a user-defined format.
 * Updating crc files (adding hash sums of files missing in the crc
   file).
 * Ability to process directories recursively.

%_mingw64_debug_package

%package -n %{_mingw}-librhash%{major}
Summary:        LibRHash Shared Library

%description -n %{_mingw}-librhash%{major}
LibRHash is a professional, portable, thread-safe C library for
computing a wide variety of hash sums, such as CRC32, MD4, MD5, SHA1,
SHA256, SHA512, AICH, ED2K, Tiger, DC++ TTH, BitTorrent BTIH, GOST R
34.11-94, RIPEMD-160 HAS-160, EDON-R, Whirlpool and Snefru.
Hash sums are used to ensure and verify integrity of large volumes of
data for a long-term storing or transferring.

%package devel
Summary:        Headers and Static Library for LibRHash
Requires:       %{_mingw}-librhash%{major} = %{version}
Provides:       %{_mingw}-librhash-devel = %{version}
Obsoletes:      %{_mingw}-librhash-devel < %{version}

%description devel
LibRHash is a professional, portable, thread-safe C library for
computing a wide variety of hash sums, such as CRC32, MD4, MD5, SHA1,
SHA256, SHA512, AICH, ED2K, Tiger, DC++ TTH, BitTorrent BTIH, GOST R
34.11-94, RIPEMD-160 HAS-160, EDON-R, Whirlpool and Snefru.
Hash sums are used to ensure and verify integrity of large volumes of
data for a long-term storing or transferring.

This package includes LibRHash development files.

#%lang_package

%prep
%autosetup -n RHash-%{version} -p1

%build
# repleace unwanted fomit-frame pointer with desirable optflags
sed -i "s|-fomit-frame-pointer|%{optflags}|g" configure
# not a autotools configure - we can't use _mingw64_configure because configure does not understand --cache-file
%{_mingw64_env} ; __mingw64_topdir=.; if ! test -x configure; then __mingw64_topdir=..; fi; \
$__mingw64_topdir/configure \
	--cc=%{_mingw64_cc} \
	--ar=%{_mingw64_ar} \
	--target=%{_mingw64_target} \
	--prefix=%{_mingw64_prefix} \
	--enable-lib-shared \
	--extra-ldflags="$LDFLAGS" \
	--extra-cflags="$CFLAGS"

cat config.mak
echo
cat librhash/config.mak

%{_mingw64_make} %{?_smp_mflags}

%install
%{_mingw64_makeinstall} DESTDIR=%{buildroot} install-conf install-pkg-config install-lib-headers
find %{buildroot}
#%find_lang %{name} %{?no_lang_C}

#%check
#%make_build test

%post -n %{_mingw}-librhash%{major} -p /sbin/ldconfig
%postun -n %{_mingw}-librhash%{major} -p /sbin/ldconfig

%files
%license COPYING
%doc ChangeLog README.md
# TODO: fix this.... 
# [   61s] mingw64-rhash-1.4.3-28.1.noarch.rpm: directories not owned by a package:
# [   61s]  - /usr/i686-w64-mingw64/sys-root/mingw/etc
%dir %{_mingw64_sysconfdir}
%config(noreplace) %{_mingw64_sysconfdir}/rhashrc
%{_mingw64_bindir}/ed2k-link.exe
%{_mingw64_bindir}/edonr256-hash.exe
%{_mingw64_bindir}/edonr512-hash.exe
%{_mingw64_bindir}/gost12-256-hash.exe
%{_mingw64_bindir}/gost12-512-hash.exe
%{_mingw64_bindir}/has160-hash.exe
%{_mingw64_bindir}/magnet-link.exe
%{_mingw64_bindir}/rhash.exe
%{_mingw64_bindir}/sfv-hash.exe
%{_mingw64_bindir}/tiger-hash.exe
%{_mingw64_bindir}/tth-hash.exe
%{_mingw64_bindir}/whirlpool-hash.exe
%{_mingw64_mandir}/man1/ed2k-link.1%{?ext_man}
%{_mingw64_mandir}/man1/edonr256-hash.1%{?ext_man}
%{_mingw64_mandir}/man1/edonr512-hash.1%{?ext_man}
%{_mingw64_mandir}/man1/gost12-256-hash.1%{?ext_man}
%{_mingw64_mandir}/man1/gost12-512-hash.1%{?ext_man}
%{_mingw64_mandir}/man1/has160-hash.1%{?ext_man}
%{_mingw64_mandir}/man1/magnet-link.1%{?ext_man}
%{_mingw64_mandir}/man1/rhash.1%{?ext_man}
%{_mingw64_mandir}/man1/sfv-hash.1%{?ext_man}
%{_mingw64_mandir}/man1/tiger-hash.1%{?ext_man}
%{_mingw64_mandir}/man1/tth-hash.1%{?ext_man}
%{_mingw64_mandir}/man1/whirlpool-hash.1%{?ext_man}

%files -n %{_mingw}-librhash%{major}
%{_mingw64_bindir}/librhash*.dll

%files devel
%license COPYING
%doc ChangeLog README.md
%{_mingw64_includedir}/rhash.h
%{_mingw64_includedir}/rhash_torrent.h
%{_mingw64_libdir}/librhash.*
%{_mingw64_libdir}/pkgconfig/*.pc

#%files lang -f %{name}.lang

%changelog
openSUSE Build Service is sponsored by