File sciteco.spec of Package sciteco

Name:		sciteco
Version:	2.4.0
Release:	1%{?dist}
Summary:	Scintilla-based Text Editor and Corrector

License:	GPL-3.0-or-later
URL:		https://rhaberkorn.github.io/sciteco/
Source0:	%{name}-%{version}.tar.gz
# Package will be relocatable.
Prefix:		/usr

BuildRequires:	gcc >= 5.0, gcc-c++ >= 5.0, make, pkgconfig, autoconf, automake, libtool
BuildRequires:	glib2-devel >= 2.44
BuildRequires:	ncurses-devel
BuildRequires:	gtk3-devel >= 3.12
%if 0%{?suse_version}
BuildRequires:	xvfb-run
%else
# Should contain the xvfb-run utility.
BuildRequires:  xorg-x11-server-Xvfb
%endif
BuildRequires:	groff

%description
SciTECO is an interactive TECO dialect, similar to Video TECO.
It also adds features from classic Standard TECO-11, and incorporates
many unique new ideas. It supports both terminal (ncurses) and
graphical (GTK+3) interfaces.

%package common
Summary:	Architecture-independant files and the SciTECO standard library
BuildArch:	noarch

%description common
Architecture-independant files and the SciTECO standard library

%package curses
Summary:	Scintilla-based Text Editor and Corrector (curses)
Requires:	%{name}-common = %{version}-%{release}
%if 0%{?suse_version}
Suggests:	xclip
%endif

%description curses
Scintilla-based Text Editor and Corrector (curses)

%package gtk
Summary:	Scintilla-based Text Editor and Corrector (GTK+)
Requires:	%{name}-common = %{version}-%{release}

%description gtk
Scintilla-based Text Editor and Corrector (GTK+)

%prep
%autosetup

# NOTE: The %%conf section is not available everywhere
%build
# If ./configure is in the source tarball, it is preferred.
# But we might be building from a Git tarball or repository as well.
test -x ./configure || autoreconf -i

%define _configure ../configure

mkdir build-curses
pushd build-curses
%configure --with-interface=ncurses \
           --with-scitecodatadir=../share/%{name}
popd

mkdir build-gtk
pushd build-gtk
%configure --with-interface=gtk --program-prefix=g \
           --with-scitecodatadir=../share/%{name}
popd

%make_build -C build-curses
# NOTE: Since the Gtk+ version of SciTECO is called during the build,
# we need an XServer which may be missing on the build server.
# That's why we use xvfb.
xvfb-run -a %make_build -C build-gtk

%check
# Test suite runs must be verbose, since we will not have
# access to the output dir in case of failures.
export TESTSUITEFLAGS="--verbose"
make -C build-curses check
xvfb-run -a make -C build-gtk check

%install
%make_install -C build-curses
xvfb-run -a %make_install -C build-gtk

# Fix up the hash bang lines, which have been overwritten by the Gtk installation.
# Unnecessary in unstable builds or releases after v2.4.0.
sed -Ei '1s|^#!.*? |#!%{_bindir}/%{name} |' %{buildroot}%{_bindir}/{grosciteco,tedoc}.tes

# For the sciteco-gtk package:
install -d %{buildroot}%{_datadir}/icons/hicolor/16x16/apps
install -m 0644 ico/%{name}-16.png %{buildroot}%{_datadir}/icons/hicolor/16x16/apps/%{name}.png
install -d %{buildroot}%{_datadir}/icons/hicolor/32x32/apps
install -m 0644 ico/%{name}-32.png %{buildroot}%{_datadir}/icons/hicolor/32x32/apps/%{name}.png
install -d %{buildroot}%{_datadir}/icons/hicolor/48x48/apps
install -m 0644 ico/%{name}-48.png %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
install -d %{buildroot}%{_datadir}/icons/hicolor/256x256/apps
install -m 0644 ico/%{name}-256.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/%{name}.png

install -d %{buildroot}%{_datadir}/applications
install -m 0644 src/%{name}.desktop %{buildroot}%{_datadir}/applications/

# We don't want to ship those - see below
rm -f %{buildroot}%{_mandir}/man1/gsciteco.1*
rm -f %{buildroot}%{_mandir}/man1/ggrosciteco.tes.1*
rm -f %{buildroot}%{_mandir}/man1/gtedoc.tes.1*
rm -f %{buildroot}%{_mandir}/man7/gsciteco.7*

%files common
%license COPYING
%doc README
# FIXME: Perhaps sciteco-curses and sciteco-gtk should ship their own copies?
%{_mandir}/man1/sciteco.1.gz
%{_mandir}/man1/grosciteco.tes.1.gz
%{_mandir}/man1/tedoc.tes.1.gz
%{_mandir}/man7/sciteco.7.gz
%{_datadir}/%{name}
%exclude %{_datadir}/%{name}/fallback.css

%files curses
%{_bindir}/%{name}
# Theoretically, these scripts could be in sciteco-common,
# but they need an interpreter and the name depends on the version installed.
%{_bindir}/grosciteco.tes
%{_bindir}/tedoc.tes

%files gtk
%{_bindir}/g%{name}
# Theoretically, these scripts could be in sciteco-common,
# but they need an interpreter and the name depends on the version installed.
%{_bindir}/ggrosciteco.tes
%{_bindir}/gtedoc.tes
%{_datadir}/%{name}/*.css
%{_datadir}/icons/hicolor/16x16/apps/*.png
%{_datadir}/icons/hicolor/32x32/apps/*.png
%{_datadir}/icons/hicolor/48x48/apps/*.png
%{_datadir}/icons/hicolor/256x256/apps/*.png
%{_datadir}/applications/*.desktop

%changelog
* Tue Aug 12 2025 Robin Haberkorn <robin.haberkorn@googlemail.com> - 2.4.0-1
- Initial RPM packaging
openSUSE Build Service is sponsored by