%global git_user bwalex
%global git_project tc-play
#%%global git_date 20130629
#%%global git_hash b44b1fa

Name:           tcplay
Version:        3.3
#Release:       0.2.%%{git_date}git%%{git_hash}%%{?dist}
Release:        0%{?dist}.2sunshine
Summary:        Utility to create/open/map TrueCrypt and VeraCrypt compatible volumes
License:        BSD
URL:            https://github.com/%{git_user}/%{git_project}
#Source0:       https://github.com/%%{git_user}/%%{git_project}/tarball/%%{git_hash}/%%{git_project}-%%{git_hash}.tar.gz
Source0:        https://github.com/%{git_user}/%{git_project}/archive/v%{version}.tar.gz

BuildRequires:  gcc
BuildRequires:  gcc-c++
%if 0%{?rhel} && 0%{?rhel} <= 7
BuildRequires:  cmake28
%global cmake %cmake28
%else
BuildRequires:  cmake
%endif
BuildRequires:  libgcrypt-devel
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig(devmapper)
BuildRequires:  pkgconfig(uuid)

%description
The tcplay utility provides full support for creating and opening/mapping
TrueCrypt and VeraCrypt compatible volumes.

%package        lib
Summary:        Library to create/open/map TrueCrypt-compatible volumes

%description    lib
The libtcplay library provides an API for creating and opening/mapping
TrueCrypt and VeraCrypt compatible volumes.

%ldconfig_scriptlets lib

%package        devel
Summary:        Development files for libtcplay
Requires:       %{name}-lib%{?_isa} = %{version}-%{release}

%description    devel
Files necessary to develop applications that use the libtcplay.

%prep
#%setup -q -n %%{git_user}-%%{git_project}-%%{git_hash}
%setup -q -n %{git_project}-%{version}

# Let package honor RPM_OPT_FLAGS
sed -i -e "s,-O3,," \
  -e "s,-fPIE,," CMakeLists.txt

%build
%{cmake} -DSBIN_DIR=%{_bindir}
%{cmake_build}

%install
%{cmake_install}
#%%make_install SBINDIR=%{_bindir}
rm %{buildroot}/%{_libdir}/*.a

%files
%license LICENSE
%doc README.md CHANGELOG
%{_bindir}/%{name}
%{_mandir}/man8/%{name}.8*

%files lib
%license LICENSE
%doc README.md CHANGELOG
%{_libdir}/libtcplay.so.3.3

%files devel
%{_includedir}/tcplay_api.h
%{_libdir}/libtcplay.so
%{_libdir}/pkgconfig/tcplay.pc
%{_mandir}/man3/%{name}.3*

%changelog
* Fri Dec 3 2021 Moritz Barsnick <moritz+rpm@barsnick.net> 3.3-0.2sunshine
- use proper cmake build macros

* Thu Mar 5 2020 Moritz Barsnick <moritz+rpm@barsnick.net> 3.3-0.1sunshine
- update to 3.3, adding VeraCrypt support
- drop obsoleted patch
- use standard "make install"
- use %%make_build, %%make_install and %%license macros
- package pkgconfig file and API man page

* Sat Jan 25 2020 Moritz Barsnick <moritz+rpm@barsnick.net> 2.0-15.1sunshine
- fix macros in comments, apparently failing the build and kicking the package
  from Fedora (thanks, maintainer! bz #1676123)
- fix build with glibc 2.28 and above

* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.0-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.0-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.0-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Aug 27 2015 Ralf Corsépius <corsepiu@fedoraproject.org> - 2.0-7
- Filter out harmful CFLAGS from CMakeLists.txt
  (Fix F23FTBFS, RHBZ#1240061).
- BR: pkgconfig(devmapper), pkgconfig(uuid)

* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Mon Aug 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Mon May 05 2014 Eric Smith <brouhaha@fedoraproject.org> - 2.0-3
- Fix dependency on lib subpackage (typo).

* Sat Apr 19 2014 Eric Smith <brouhaha@fedoraproject.org> - 2.0-2
- Package libtcplay.

* Sun Apr 06 2014 Eric Smith <brouhaha@fedoraproject.org> - 2.0-1
- Updated to latest upstream release.

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1-0.2.20130629gitb44b1fa
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Tue Jul 23 2013 Eric Smith <brouhaha@fedoraproject.org> - 1.1-0.1.20130629gitb44b1fa
- Updated to latest upstream snapshot.

* Fri Feb 15 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9-0.7.20111007git97ed5f9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9-0.6.20111007git97ed5f9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9-0.5.20111007git97ed5f9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Sat Oct 08 2011 Eric Smith <eric@brouhaha.com> - 0.9-0.4.20111007git97ed5f9
- Removed more outdated items from spec, not intending to support RHEL5 or
  earlier.

* Thu Oct 06 2011 Eric Smith <eric@brouhaha.com> - 0.9-0.3.20111007git97ed5f9
- updated to new upstream snapshot

* Thu Oct 06 2011 Eric Smith <eric@brouhaha.com> - 0.9-0.2.20111004git59c6097
- updated based on package review comments, bug 743497

* Tue Oct 04 2011 Eric Smith <eric@brouhaha.com> - 0.9-0.1.20111004git59c6097
- initial version