File TeXmacs.spec of Package TeXmacs

#
# spec file for package TeXmacs
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 8/2011 - now  open-slx GmbH <Sascha.Manns@open-slx.de>
# Copyright (c) 2009 - 7/2011 Sascha Manns <saigkill@opensuse.org>
#
# 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 https://bugs.opensuse.org/
#


Name:           TeXmacs
Version:        2.1.4.15298
Release:        0
Summary:        A Structured WYSIWYG Scientific Text Editor
License:        GPL-3.0-or-later
URL:            https://www.texmacs.org/
Source:         %{name}-%{version}.tar.gz
#Patch1:         Reproducibility.patch
#Patch2:         texmacs-hashtree-fix.patch
BuildRequires:  texinfo
BuildRequires:  hostname
BuildRequires:  fdupes
BuildRequires:  fontpackages-devel
BuildRequires:  libtool-ltdl-devel
BuildRequires:  pkgconfig
#BuildRequires:  png++-devel
BuildRequires:  update-desktop-files
BuildRequires:  xdg-utils
BuildRequires:  pkgconfig(Qt6Core)
BuildRequires:  pkgconfig(Qt6PrintSupport)
BuildRequires:  pkgconfig(Qt6Svg)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  qt6-base-devel
BuildRequires:  qt6-svg-devel
BuildRequires:  qt6-tools-devel
BuildRequires:  qt6-wayland-devel
BuildRequires:  gnutls-devel
BuildRequires:  gmp-devel
BuildRequires:  ghostscript-devel
#BuildRequires:  pkgconfig(guile-1.8)
BuildRequires:  pkgconfig(ice)
BuildRequires:  pkgconfig(libjpeg)
BuildRequires:  pkgconfig(python3)
BuildRequires:  pkgconfig(sm)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xaw7)
BuildRequires:  pkgconfig(xext)
BuildRequires:  pkgconfig(xft)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(xrender)
BuildRequires:  pkgconfig(xt)

BuildRequires:  libtool
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  gcc-c++
BuildRequires:  rsync
BuildRequires:  aspell-devel

%description
GNU TeXmacs is a free scientific text editor, inspired by TeX and GNU
Emacs. The editor allows you to write structured documents via a
WYSIWYG (what-you-see-is-what-you-get) and user friendly interface. New
styles can be created by the user. The program implements high-quality
typesetting algorithms and TeX fonts, which help you to produce
professional looking documents.

The high typesetting quality still goes through for automatically
generated formulas, which makes TeXmacs suitable as an interface for
computer algebra systems. TeXmacs also supports the Guile/Scheme
extension language, so that you may customize the interface and write
your own extensions to the editor.

%package examples
Summary:        A Structured WYSIWYG Scientific Text Editor
Group:          Productivity/Scientific/Other

%description examples
GNU TeXmacs is a free scientific text editor, inspired by TeX and GNU
Emacs. The editor allows you to write structured documents via a
WYSIWYG (what-you-see-is-what-you-get) and user friendly interface. New
styles can be created by the user. The program implements high-quality
typesetting algorithms and TeX fonts, which help you to produce
professional looking documents.

The high typesetting quality still goes through for automatically
generated formulas, which makes TeXmacs suitable as an interface for
computer algebra systems. TeXmacs also supports the Guile/Scheme
extension language, so that you may customize the interface and write
your own extensions to the editor.

%prep
%setup -q -n TeXmacs-%{version}

%build
# 1. Ensure the embedded guile folders exist
if [ ! -d "tm-guile188" ]; then
    echo "Error: tm-guile188 directory not found in source!"
    exit 1
fi

# 2. Force the use of the correct compiler and linker
# We use 'nm' and 'ld' directly to prevent the "link: missing operand" error
export CC=gcc
export CXX=g++
export LD=ld
export NM=nm

#gcc15
QT6_BIN=$(qt6-config --bindir 2>/dev/null || echo %{_libdir}/qt6/bin)
QT6_LIBEXEC=$(qt6-config --libexecdir 2>/dev/null || echo %{_libdir}/qt6/libexec)

# 3. Setup Qt6 Path
export PATH="%{_libdir}/qt6/bin:%{_libdir}/qt6/libexec:$PATH"

export MOC=%{_libdir}/qt6/bin/moc
export UIC=%{_libdir}/qt6/bin/uic
export RCC=%{_libdir}/qt6/bin/rcc

GUILE_INC_DIR="tm-guile188/include"
GUILE_LIB_DIR="tm-guile188/lib"

# 4. Manual Configure
./configure \
    --prefix=%{_prefix} \
    --with-qt-find-method=pkgconfig \
    --with-qt-bin=$QT6_BIN \
    --with-qt-libexec=$QT6_LIBEXEC \
    --with-guile=embedded18 \
    --with-gnutls=yes \
    CPPFLAGS="-I$(pwd)/tm-guile188/include" \
    LDFLAGS="-L$(pwd)/tm-guile188/lib"

# 4.5 Build embedded Guile (required for internal headers)
cd tm-guile188
export CFLAGS="%{optflags} -fpermissive -Wno-error=incompatible-pointer-types"
export CXXFLAGS="%{optflags} -fpermissive -Wno-error=incompatible-pointer-types"

./configure --prefix=$(pwd)/build --disable-shared --enable-static --disable-error-on-warning
%make_build
make install
cd ..

# 5. Inject the Scheme library files before building
cp -rf tm-guile188/ice-9 ./TeXmacs/progs/

%make_build \
    MOC="$MOC" \
    UIC="$UIC" \
    RCC="$RCC" \
    QT_MOC="$MOC"

%install
export XDG_UTILS_INSTALL_MODE=system

%make_install DESTDIR=%{buildroot}
mkdir -p %{buildroot}%{_datadir}/mime/packages
install -m 0644 TeXmacs/misc/mime/texmacs.xml %{buildroot}%{_datadir}/mime/packages/texmacs.xml

%suse_update_desktop_file -i texmacs

%fdupes %{buildroot}/%{_prefix}

%files
%{_bindir}/fig2ps
%{_bindir}/texmacs
%{_includedir}/TeXmacs.h
%{_mandir}/man1/fig2ps.1%{?ext_man}
%{_mandir}/man1/texmacs.1%{?ext_man}
%doc %{_datadir}/TeXmacs/examples
%doc %{_datadir}/TeXmacs/doc
%license %{_datadir}/TeXmacs/LICENSE
%doc %{_datadir}/TeXmacs/texts
%{_datadir}/icons/hicolor/*/*/*texmacs*
%{_datadir}/pixmaps/*.xpm
%{_datadir}/applications/*.desktop
%{_datadir}/mime/packages/texmacs.xml
%dir %{_datadir}/TeXmacs
%dir %{_libexecdir}/TeXmacs
%dir %{_libexecdir}/TeXmacs/bin
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/scalable
%dir %{_datadir}/icons/hicolor/scalable/apps
%dir %{_datadir}/icons/hicolor/scalable/mimetypes
%dir %{_datadir}/icons/hicolor/*x*/
%dir %{_datadir}/icons/hicolor/*x*/apps
%dir %{_datadir}/icons/hicolor/*x*/mimetypes
%{_libexecdir}/TeXmacs/bin
%{_datadir}/TeXmacs/fonts
%{_datadir}/TeXmacs/langs
%{_datadir}/TeXmacs/packages
%{_datadir}/TeXmacs/misc
%{_datadir}/TeXmacs/plugins
%{_datadir}/TeXmacs/progs
%{_datadir}/TeXmacs/styles

%changelog
openSUSE Build Service is sponsored by