Blob Blame History Raw
%bcond_without  gui

Name:           ansifilter
Version:        1.12
Release:        1%{?dist}
Summary:        ANSI terminal escape code converter
License:        GPLv3+
URL:            http://www.andre-simon.de/doku/ansifilter/ansifilter.php
Source0:        http://www.andre-simon.de/zip/%{name}-%{version}.tar.bz2
%if %{with gui}
Source1:        ansifilter.desktop
Source2:        http://www.andre-simon.de/img/af_icon.png
%endif

%description
Ansifilter handles text files containing ANSI terminal escape codes. The
command sequences may be stripped or be interpreted to generate formatted
output (HTML, RTF, TeX, LaTeX, BBCode).

%if %{with gui}
%package        gui
Summary:        GUI for %{name} based on Qt4
BuildRequires:  desktop-file-utils
BuildRequires:  qt4-devel

%description    gui
Ansifilter handles text files containing ANSI terminal escape codes. The
command sequences may be stripped or be interpreted to generate formatted
output (HTML, RTF, TeX, LaTeX, BBCode).

This is a GUI of %{name} based on Qt4.
%endif

%prep
%setup -q

# Preserve timestamps.
sed -i 's|install -m|install -pm|g' makefile

%if %{with gui}
# Remove pre-configured files which may cause errors during building.
rm -frv src/qt-gui/moc_*.cpp
rm -frv src/qt-gui/Makefile*
%endif

# CRLF quickfix
find . -type f -exec sed -i 's/\r$//' {} + -print

%build
# Upstream embeds the cli code in gui so no need to require cli to use GUI
# program, in order to achieve this we need to preserve the objects with -c.
make CFLAGS+="%{optflags} -c" LDFLAGS="%{?__global_ldflags}" %{?_smp_mflags}

%if %{with gui}
# %%_qt4_qmake will respect the redhat-rpm-config
make all-gui QMAKE="%{_qt4_qmake}" %{?_smp_mflags}
%endif

%install
%make_install

%if %{with gui}
make install-gui DESTDIR=%{buildroot}
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{S:1}
install -pDm644 %{S:2} %{buildroot}%{_datadir}/pixmaps/%{name}.png
%endif

# Use %%doc and %%license to handle docs.
rm -frv %{buildroot}%{_docdir}

%files
%doc ChangeLog README
%license COPYING
%{_bindir}/ansifilter
%{_mandir}/man1/ansifilter.1*

%if %{with gui}
%files gui
%doc ChangeLog README
%license COPYING
%{_bindir}/ansifilter-gui
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.png
%endif

%changelog
* Tue Mar 31 2015 Christopher Meng <rpm@cicku.me> - 1.12-1
- Update to 1.12

* Mon Feb 16 2015 Christopher Meng <rpm@cicku.me> - 1.11-1
- Update to 1.11

* Thu Jun 26 2014 Christopher Meng <rpm@cicku.me> - 1.8-2
- Correct the license.
- desktop file added for gui program.

* Mon Apr 21 2014 Christopher Meng <rpm@cicku.me> - 1.8-1
- Update to 1.8

* Tue Dec 31 2013 Christopher Meng <rpm@cicku.me> - 1.7-1
- Initial Package.