File argon2.spec of Package argon2

#
# spec file for package argon2
#
# Copyright (c) 2017 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 http://bugs.opensuse.org/
#


%define lname libargon2-0
%define _version 20161029
Name:           argon2
Version:        0.0+%{_version}
Release:        0
Summary:        The reference C implementation of Argon2
License:        CC0-1.0 or Apache-2.0
Group:          Productivity/Networking/Security
Url:            https://github.com/P-H-C/phc-winner-argon2
Source:         https://github.com/P-H-C/phc-winner-argon2/archive/%{_version}.tar.gz#/phc-winner-argon2-%{_version}.tar.gz
Patch1:         optflags.patch
BuildRequires:  pkgconfig
BuildRequires:  sed
ExclusiveArch:  i686 x86_64
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
This is the reference C implementation of Argon2, the password-hashing function
that won the Password Hashing Competition (PHC).

Argon2 is a password-hashing function that summarizes the state of the art in
the design of memory-hard functions and can be used to hash passwords for
credential storage, key derivation, or other applications.

%package doc
Summary:        Documentation for Argon2
Group:          Documentation/Other
BuildArch:      noarch

%description doc
Documentation for Argon2, the password-hashing function that won the Password
Hashing Competition (PHC).

%package -n %{lname}
Summary:        The reference C implementation of Argon2
Group:          System/Libraries

%description -n %{lname}
Reference C implementation of Argon2, the password-hashing function
that won the Password Hashing Competition (PHC).

%package devel
Summary:        Development files for argon2
Group:          Development/Libraries/C and C++
Requires:       %{lname} = %{version}

%description devel
Headers for argon2, the reference C implementation of Argon2, the
password-hashing function that won the Password Hashing Competition (PHC).

%prep
%setup -q -n phc-winner-argon2-%{_version}
%patch1 -p1

sed -i s,"LIBRARY_REL = lib","LIBRARY_REL = %{_lib}", Makefile

%build
make %{?_smp_mflags} CFLAGS="-pthread %{optflags} -Iinclude -Isrc"

%install
make %{?_smp_mflags} DESTDIR=%{buildroot} install

chmod -x %{buildroot}%{_includedir}/argon2.h

mv %{buildroot}%{_libdir}/libargon2.so %{buildroot}%{_libdir}/libargon2.so.0
ln -s %{_libdir}/libargon2.so.0 %{buildroot}%{_libdir}/libargon2.so

install -D -m 644 man/argon2.1 %{buildroot}%{_mandir}/man1/argon2.1
install -D -m 644 libargon2.pc %{buildroot}/%{_libdir}/pkgconfig/libargon2.pc

%check
make CFLAGS="-pthread %{optflags} -Iinclude -Isrc" test

%post -n %{lname} -p /sbin/ldconfig
%postun -n %{lname} -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc LICENSE CHANGELOG.md README.md
%{_bindir}/argon2
%{_mandir}/man1/argon2.1%{ext_man}

%files doc
%defattr(-,root,root)
%doc argon2-specs.pdf

%files -n %{lname}
%defattr(-,root,root)
%{_libdir}/libargon2.so.0

%files devel
%defattr(-,root,root)
%{_includedir}/argon2.h
%{_libdir}/libargon2.so
%{_libdir}/pkgconfig/libargon2.pc

%changelog
openSUSE Build Service is sponsored by