File octave.spec of Package octave

# spec file for package octave
# Copyright (c) 2024 SUSE LLC
# 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

%define apiver  v59
# Required for RC builds, in this case version contains ~rc, src_ver -rc
%define pkg_ver 9.2.0
%define src_ver %{pkg_ver}
# Image processing library
%if 0
# currently, octave cannot be built against ImageMagick 7
%bcond_without imagemagick
# Default variant - GraphicsMagick
%bcond_with imagemagick
# Use native graphics or gnuplot
%bcond_without native_graphics
# Build GUI
%bcond_without gui
# JIT compilation
%bcond_with jit
# JAVA support
%bcond_without java
# Sound IO
%bcond_without sound
# Allow building without openBLAS, e.g. for architectures
# like RISC-V where openBLAS is not available
%bcond_without openblas
%if %{with openblas}
%define blas_library openblas
%define blas_library blas
Name:           octave
Version:        %{pkg_ver}
Release:        0
Summary:        A High Level Programming Language
License:        GPL-3.0-or-later
Group:          Productivity/Scientific/Math
Source1:        octave.macros
Source2:        %{name}-rpmlintrc
Patch0:         octave_tools_pie.patch
Patch1:         0001-Disable-signal-handler-thread-avoid-duplicate-signal.patch
BuildRequires:  %{blas_library}-devel
BuildRequires:  arpack-ng-devel
# Required for Patch0
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  dejagnu
BuildRequires:  fdupes
BuildRequires:  fftw3-threads-devel
BuildRequires:  flex
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran
BuildRequires:  ghostscript
BuildRequires:  glpk-devel
BuildRequires:  gmp-devel
BuildRequires:  gperf
BuildRequires:  hdf5-devel
BuildRequires:  lapack-devel
BuildRequires:  libtool
BuildRequires:  lzip
# required for help/doc called from the tests
BuildRequires:  makeinfo
BuildRequires:  pcre-devel
BuildRequires:  pkgconfig
BuildRequires:  qhull_r-devel
BuildRequires:  qrupdate-devel
BuildRequires:  readline-devel
BuildRequires:  suitesparse-devel
BuildRequires:  sundials-devel
# Tests build requires
BuildRequires:  unzip
BuildRequires:  xvfb-run
BuildRequires:  zip
BuildRequires:  pkgconfig(RapidJSON)
BuildRequires:  pkgconfig(libcurl)
BuildRequires:  pkgconfig(zlib)
Requires:       octave-cli = %{version}
Requires(pre):  update-alternatives
%if %{with imagemagick}
BuildRequires:  pkgconfig(Magick++)
BuildRequires:  pkgconfig(GraphicsMagick++)
# GUI build requires
%if %{with gui}
BuildRequires:  desktop-file-utils
BuildRequires:  hicolor-icon-theme
BuildRequires:  qscintilla-qt6-devel
BuildRequires:  qt6-tools-helpgenerators
BuildRequires:  qt6-tools-linguist
BuildRequires:  update-desktop-files
BuildRequires:  cmake(Qt6Core)
BuildRequires:  cmake(Qt6Core5Compat)
BuildRequires:  cmake(Qt6Gui)
BuildRequires:  cmake(Qt6Help)
BuildRequires:  cmake(Qt6Network)
BuildRequires:  cmake(Qt6OpenGL)
BuildRequires:  cmake(Qt6OpenGLWidgets)
BuildRequires:  cmake(Qt6PrintSupport)
BuildRequires:  cmake(Qt6Widgets)
BuildRequires:  cmake(Qt6Xml)
# Section testing
BuildRequires:  xorg-x11-Xvfb
%if %{without native_graphics}
BuildRequires:  gnuplot
# \Section
# boo#1095605
Requires:       qt6-sql-sqlite
Obsoletes:      octave-gui < 4.0
Provides:       octave-gui = %{version}
# Sound IO build requires
%if %{with sound}
BuildRequires:  pkgconfig(alsa)
BuildRequires:  pkgconfig(portaudio-2.0)
BuildRequires:  pkgconfig(sndfile)
# JAVA functions build requires
%if %{with java}
BuildRequires:  java-devel
# JIT build requires
%if %{with jit}
BuildRequires:  llvm-devel
# Native graphics build requires
%if %{with native_graphics}
BuildRequires:  Mesa-devel
BuildRequires:  Mesa-dri
BuildRequires:  fltk-devel
BuildRequires:  gl2ps-devel
BuildRequires:  pkgconfig(fontconfig)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(glu)
Requires:       gnuplot

Octave is a high level programming language. It is designed for the
solution of numeric problems.
%if %{with gui}

This package contains the graphical user interface.

%package        cli
Summary:        Command-line user interface for Octave
Group:          Productivity/Scientific/Math
Requires:       makeinfo
Requires(pre):  update-alternatives
Recommends:     octave-doc = %{version}
# SECTION Resolve degeneracy between multiple libsundials_{sunlinsol,ida}.so providers from serial and parallel flavours of sundials
Requires:       %(rpm -qR sundials-devel | grep -oP "libsundials_ida[0-9]")
Requires:       %(rpm -qR sundials-devel | grep -oP "libsundials_sunlinsol[0-9_]+")
%if %{with native_graphics}
Recommends:     epstool
Recommends:     pstoedit
# transfig requires texlive installation now
# Recommends:     transfig

%description    cli
Octave is a high level programming language. It is designed for the
solution of numeric problems.

This package contains the command-line user interface.

%package        devel
Summary:        Development files for Octave
Group:          Development/Languages/Other
Requires:       %{blas_library}-devel
Requires:       %{name}-cli = %{version}
Requires:       fftw3-devel
Requires:       fftw3-threads-devel
Requires:       gcc-c++
Requires:       gcc-fortran
Requires:       hdf5-devel
Requires:       make

%description    devel
Octave is a high level programming language. It is designed for the
solution of numeric problems.

This package contains all necessary include files and libraries needed
to develop applications using Octave.

%package        doc
Summary:        Documentation for Octave
Group:          Documentation/Other
BuildArch:      noarch

%description    doc
Octave is a high level programming language. It is designed for the
solution of numeric problems.

This package contains documentation for Octave.

%setup -q -n %{name}-%{src_ver}
%autopatch -p1


# rebuild makefiles after Patch0
autoreconf -i -s -f
%configure \
  --libexecdir=%{_libdir} \
%if %{with imagemagick}
  %{?with_gui: --with-qt} \
  %{!?with_gui: --without-qt} \
  %{?with_jit: --enable-jit} \
  %{!?with_java: --disable-java} \
  --with-blas=%{blas_library} \
  --disable-docs \


# see bnc#557340
mkdir -p %{buildroot}/%{_sysconfdir}/
echo %{_libdir}/%{name}/%{src_ver} > %{buildroot}/%{_sysconfdir}/{name}.conf
find %{buildroot} -type f -name "*.la" -delete -print
# local rc file into /etc
mkdir %{buildroot}/%{_sysconfdir}/%{name}
mv %{buildroot}/%{_datadir}/%{name}/site/m/startup/octaverc %{buildroot}/%{_sysconfdir}/%{name}
ln -s %{_sysconfdir}/%{name}/octaverc %{buildroot}/%{_datadir}/%{name}/site/m/startup/octaverc
mkdir -p %{buildroot}/%{_libdir}/%{name}/packages
mkdir -p %{buildroot}/%{_datadir}/%{name}/packages
# Documentation
install -Dm 644 -t %{buildroot}%{_mandir}/man1/ doc/*/*.1
install -Dm 644 -t %{buildroot}%{_infodir} doc/*/*.info doc/*/*.info-*
# Remove icons with huge size, we have scalable SVGs
rm -rf %{buildroot}/%{_datadir}/icons/hicolor/1024x1024
# gui related fixes
%if %{without gui}
rm -rf %{buildroot}/%{_datadir}/icons/hicolor/
rm -rf %{buildroot}/%{_datadir}/metainfo/
rm -rf %{buildroot}/%{_datadir}/applications/
# rpm macros
install -Dm 644 %{SOURCE1} %{buildroot}%{_rpmmacrodir}/macros.octave
# substitute correct values for octave_blas macros
sed -i 's/OCTAVE_BLAS_LIBRARY_NAME/%{blas_library}/g' %{buildroot}%{_rpmmacrodir}/macros.octave

# increase stack size set by the JVM, affects the whole octave process
echo "-Xss8m" >  %{buildroot}/%{_datadir}/%{name}/%{src_ver}/m/java/java.opts

%fdupes %{buildroot}%{_datadir}/octave/

# Increase stack limits. OpenBLAS tests are run after some JVM test, and OpenBLAS
# dgetrf is quite memory hungry, see
echo "-Xss8m" >  scripts/java/java.opts

# We need "--no-gui-libs" as a temporary work around to
xvfb-run make %{?_smp_mflags} check RUN_OCTAVE_OPTIONS="--no-gui-libs"


%post cli
%install_info --info-dir=%{_infodir} %{_infodir}/

%postun cli
%install_info_delete --info-dir=%{_infodir} %{_infodir}/

%license COPYING
%doc README ChangeLog
%if %{with gui}

%files cli
%config %{_sysconfdir}/{name}.conf
%config(noreplace) %{_sysconfdir}/%{name}/octaverc
%dir %{_libdir}/%{name}
%dir %{_libdir}/%{name}/%{src_ver}
%dir %{_libdir}/%{name}/packages
%dir %{_datadir}/%{name}/packages
%dir %{_sysconfdir}/%{name}
%if %{with gui}
%dir %{_libdir}/%{name}/%{src_ver}/exec/
%dir %{_libdir}/%{name}/%{src_ver}/exec/*-*-linux-gnu*/
%exclude %{_datadir}/%{name}/%{src_ver}/locale/

%files devel

%files doc
%doc doc/interpreter/octave.pdf
%doc doc/liboctave/liboctave.pdf
%doc doc/refcard/refcard-a4.pdf
%doc doc/refcard/refcard-legal.pdf

openSUSE Build Service is sponsored by