%global git_date 20210206
%global git_rev 6f97e6a
%global git_revision    6f97e6aa6b38f279f7a7ef33c35bbb90614acd71
%global progname        wordgrinder
%global srcpkgdir       %{progname}-%{git_revision}

Name:           wordgrinder
Version:        0.8.0.%{git_date}git%{git_rev}
Release:        1%{?dist}
Summary:        A command line word processor

License:        MIT
URL:            http://cowlark.com/wordgrinder
%global pkgid   %{name}-%{version}
Source:         https://github.com/davidgiven/%{name}/archive/%{git_revision}.tar.gz

BuildRequires:  gcc make ncurses-devel ninja-build
BuildRequires:  lua-devel lua-libs lua lua-filesystem
BuildRequires:  zlib-devel libXft-devel
Requires:       ncurses lua-filesystem

%description
WordGrinder is a Unicode-aware character cell word processor that runs in a
terminal (or a Windows console). It is designed to get the hell out of your way
and let you get some work done.

WordGrinder is a word processor for processing words. It is not WYSIWYG. It is
not point and click. It is not a desktop publisher. It is not a text editor. It
does not do fonts and it barely does styles. What it does do is words. It's
designed for writing text. It gets out of your way and lets you type

%package x11
Summary: X11 version of WordGrinder
#Requires: %name = %version-%release
Requires: libX11
%description x11
An X11 version of the WordGrinder word processor.

%prep

#%setup -q -n %{name}-%{version}
%setup -q -n %{srcpkgdir}

###############################################################################
%build

CFLAGS=-g PREFIX=$RPM_BUILD_ROOT/%{_prefix} OBJDIR=$RPM_BUILD_ROOT/tmp WANT_STRIPPED_BINARIES=no make %{?_smp_mflags}

###############################################################################
%install

make install PREFIX=$RPM_BUILD_ROOT/%{_prefix}
install -D -m 0644 %{_builddir}/%{srcpkgdir}/extras/wordgrinder.mime %{buildroot}%{_datadir}/mime/packages/wordgrinder.mime
install -D -m 0644 -T %{_builddir}/%{srcpkgdir}/extras/icon.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/wordgrinder.png
install -D -m 0644 %{_builddir}/%{srcpkgdir}/extras/wordgrinder.desktop %{buildroot}%{_datadir}/applications/wordgrinder.desktop

%post
update-desktop-database &> /dev/null || :
touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
touch --no-create %{_datadir}/mime/packages &>/dev/null || :

%postun
update-desktop-database &> /dev/null || :
if [ $1 -eq 0 ] ; then
    touch --no-create %{_datadir}/icons/hicolor &>/dev/null
    gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
    update-mime-database %{_datadir}/mime &> /dev/null || :
fi
%posttrans x11
%posttrans
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :

###############################################################################
%files
%license licenses/COPYING.WordGrinder
%_bindir/wordgrinder
%_docdir/wordgrinder/README.wg
%_mandir/man1/wordgrinder.1*

%files x11
%license licenses/COPYING.WordGrinder
%_bindir/xwordgrinder
%_mandir/man1/xwordgrinder.1*
%{_datadir}/applications/wordgrinder.desktop
%{_datadir}/icons/hicolor/256x256/apps/wordgrinder.png
%{_datadir}/mime/packages/wordgrinder.mime
%{_datadir}/mime-info/wordgrinder.mime
%{_datadir}/pixmaps/wordgrinder.png
###############################################################################
%changelog
* Sat Feb 06 2021 Ben Cotton <bcotton@fedoraproject.org> - 0.8.0.20210206git6f97e6a-1
- Update to latest upstream snapshot

* Mon Oct 19 2020 Ben Cotton <bcotton@fedoraproject.org> - 0.8.0.20201019gite8cc7e9-1
- Update to latest upstream snapshot
- Remove wordgrinder-x11's dependency on wordgrinder
- Add desktop files to xwordgrinder

* Sat Oct 17 2020 Ben Cotton <bcotton@fedoraproject.org> - 0.8.0.20201017git5cba17f-1
- Update to latest upstream snapshot

* Fri Oct 16 2020 Ben Cotton <bcotton@fedoraproject.org> - 0.8.0.20201016gitd42fc86-1
- Update to latest upstream snapshot

* Thu Oct 15 2020 Ben Cotton <bcotton@fedoraproject.org> - 0.8.0.20201015gite7efc05-1
- Update to latest upstream snapshot

* Wed Oct 14 2020 Ben Cotton <bcotton@fedoraproject.org> - 0.8.0.20201014git31afd78-1
- Update to latest upstream snapshot

* Tue Oct 13 2020 Ben Cotton <bcotton@fedoraproject.org> - 0.8.0.20201013git0ed98df-1
- Update to latest upstream snapshot

* Mon Oct 12 2020 Ben Cotton <bcotton@fedoraproject.org> - 0.8.0.20201012gitaaa32a3-1
- Build development version for Copr

* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

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

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

* Fri Jan 04 2019 Ben Cotton <bcotton@fedoraproject.org> - 0.7.2-1
- Update to latest upstream release
- Remove unnecessary patch to build scripts

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

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

* Sun Nov 05 2017 Ben Cotton <bcotton@fedoraproject.org> - 0.7.1-1
- Update to latest upstream release
- Remove unneeded dependences, which allows us more build arches
- Split the X11 version into an optional subpackage

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

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

* Thu Jul 06 2017 Ben Cotton <bcotton@fedoraproject.org> - 0.6-4
- Fix debuginfo issues

* Thu Jul 06 2017 Ben Cotton <bcotton@fedoraproject.org> - 0.6-3
- Update the patch to build on Fedora 26

* Sun Jul 02 2017 Ben Cotton <bcotton@fedoraproject.org> - 0.6-2
- Change lua to a version supported by upstream (5.1)

* Wed Jun 07 2017 Ben Cotton <bcotton@fedoraproject.org> - 0.6-1
- Initial RPM release