File scilab.spec of Package scilab

#
# spec file for package scilab
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


%define sover 5
%define soname lib%{name}%{sover}
#%define beta_version 5.5.0-beta-1

Name:           scilab
Summary:        High Level Programming Language/Numerical Analysis Software
License:        CECILL-2.0 and BSD-3-Clause
Group:          Productivity/Scientific/Math
Version:        5.5.2
Release:        0
Url:            http://www.scilab.org
# FOR STABLE RELEASE
Source0:        http://www.scilab.org/download/%{version}/%{name}-%{version}-src.tar.gz
# FOR BETA RELEASE
#Source0:        http://www.scilab.org/download/%{beta_version}/%{name}-%{beta_version}-src.tar.gz
Source1:        %{name}-rpmlintrc

# Bug 767102 - help() should suggest scilab-doc
Patch1:         %{name}-0001-Use-pkcon-to-install-doc-package.patch
# Bug 64307 - Use dynamic stack on 32-bit to avoid miscompilation
# http://bugzilla.scilab.org/show_bug.cgi?id=12625
Patch2:         %{name}-0002-always-use-dynamic-stack.patch
# PATCH-FIX-UPSTREAM scilab-fix-64bit-portability-issue.patch badshah400@gmail.com -- Fix compiler warnings w.r.t 64bit portability
Patch3:         scilab-fix-64bit-portability-issue.patch
# PATCH-FIX-OPENSUSE scilab-special-jarnames.patch badshah400@gmail.com -- Adapt configure script for a few java library names peculiar to openSUSE
Patch5:         scilab-special-jarnames.patch
# PATCH-FIX-UPSTREAM scilab-build-with-xmlgraphics-commons-2_0.patch badshah400@gmail.com -- Fix compilation with xmlgraphics-commons >= 2.0
Patch6:         scilab-build-with-xmlgraphics-commons-2_0.patch
# PATCH-FIX-OPENSUSE scilab-0003-fix-xcos-desktop.patch sfalken@opensuse.org -- Change Desktop categories in xcos.desktop to clear brp-check-suse failure
Patch7:         %{name}-0003-fix-desktop-categories.patch
# PATCH-FIX-UPSTREAM scilab-build-with-jogl-gluegen-2.3.patch badshah400@gmail.com -- Make scilab build with jogl and gluegen >= 2.3.0
Patch8:         scilab-build-with-jogl-2.3.patch
# PATCH-FIX-UPSTREAM scilab-disable-debian-specific-cflags.patch badshah400@gmail.com -- Disable cflags meant excl. for Debian
Patch9:         scilab-disable-debian-specific-cflags.patch
# Dependencies are extracted from :
# "http://wiki.scilab.org/Dependencies of Scilab 5.X"
# Mandatory
BuildRequires:  asm2
BuildRequires:  f2c
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran

## for dynamic link features
Requires:       gcc
Requires:       gcc-c++
Requires:       gcc-fortran
# Core
BuildRequires:  libcurl-devel
BuildRequires:  libxml2-devel
BuildRequires:  ncurses-devel
BuildRequires:  pcre-devel

# Numerical libraries
# see "http://wiki.scilab.org/Linalg performances"
BuildRequires:  arpack-ng-devel
BuildRequires:  blas-devel
BuildRequires:  lapack-devel
BuildRequires:  libarpack2

# GUI/Console
BuildRequires:  ant
BuildRequires:  java-devel >= 1.8.0
BuildRequires:  jpackage-utils

BuildRequires:  Mesa-devel
BuildRequires:  flexdock
BuildRequires:  jogl2 >= 2.2.4

Requires:       flexdock
Requires:       jogl2 >= 2.2.4

BuildRequires:  jrosetta
Requires:       jrosetta

BuildRequires:  apache-commons-logging
BuildRequires:  batik
BuildRequires:  fop
BuildRequires:  javahelp2
BuildRequires:  jeuclid
BuildRequires:  jgraphx >= 2.0.0.1
BuildRequires:  jlatexmath
BuildRequires:  jlatexmath-fop
BuildRequires:  xml-commons-jaxp-1.3-apis
BuildRequires:  xmlgraphics-commons
BuildRequires:  xmlgraphics-fop

Requires:       apache-commons-logging
Requires:       batik
Requires:       fop
Requires:       javahelp2
Requires:       jeuclid
Requires:       jgraphx >= 2.0.0.1
Requires:       jlatexmath
Requires:       jlatexmath-fop
Requires:       xmlgraphics-commons
Requires:       xmlgraphics-fop

# TCL/TK features
BuildRequires:  tcl-devel
BuildRequires:  tk-devel

Requires:       bwidget
Requires:       tcl
Requires:       tk

# Modelica
BuildRequires:  ocaml

# Documentation
BuildRequires:  saxon9
Requires:       saxon9
#BuildRequires:  docbook-style-xsl
BuildRequires:  docbook-xsl-stylesheets
BuildRequires:  liberation-fonts
# make doc now requires access to display
BuildRequires:  Mesa-libGL-devel
BuildRequires:  xorg-x11-server
%define         X_display         ":98"

# QA tests and validation
BuildRequires:  ant-junit
# FIXME: Disable until cobertura and checkstyle builds for >= openSUSE 13.1 are fixed
%if 0%{?suse_version} <= 1230
BuildRequires:  checkstyle
BuildRequires:  cobertura
%endif
BuildRequires:  junit4

# All optional dependencies are needed to provide a full-featured Scilab
BuildRequires:  fftw-devel
BuildRequires:  gettext-devel
BuildRequires:  hdf5-devel
BuildRequires:  libmatio-devel
BuildRequires:  suitesparse-devel

# hdf5 does not bump soname but check at runtime
Requires:       hdf5 = %{_hdf5_version}

# Specific dependencies for packaging purpose
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes

# scilab parts
Requires:       scilab-devel = %{version}
Requires:       scilab-modules = %{version}

Recommends:     scilab-lang = %{version}

Requires(post): shared-mime-info
Requires(postun): shared-mime-info
Requires(post): desktop-file-utils
Requires(postun): desktop-file-utils
Requires(post): hicolor-icon-theme
Requires(postun): hicolor-icon-theme

%description
Scilab is the free software for numerical computation providing a powerful
computing environment for engineering and scientific applications. It
includes hundreds of mathematical functions. It has a high level programming
language allowing access to advanced data structures, 2-D and 3-D graphical
functions.

%package -n     %{soname}
Summary:        Scientific software package for numerical computations (shared libraries)
Group:          Development/Libraries/Other

%description -n %{soname}
Scilab is the free software for numerical computation providing a powerful
computing environment for engineering and scientific applications. It
includes hundreds of mathematical functions. It has a high level programming
language allowing access to advanced data structures, 2-D and 3-D graphical
functions.

This package provides the shared libraries required by scilab and scilab-devel.


%package        devel
Summary:        Scientific software package for numerical computations (include files)
Group:          Development/Languages/C and C++
Requires:       %{soname} = %{version}
Requires:       libSM-devel
Requires:       libxml2-devel
Requires:       ncurses-devel
Requires:       pcre-devel
Requires:       pkg-config
Requires:       tcl-devel
Requires:       tk-devel

%description    devel
Scilab is the free software for numerical computation providing a powerful
computing environment for engineering and scientific applications. It
includes hundreds of mathematical functions. It has a high level programming
language allowing access to advanced data structures, 2-D and 3-D graphical
functions.

This package provides files for coding in C/C++ with Scilab.

%package        modules
Summary:        Scilab modules
Group:          Productivity/Scientific/Other
BuildArch:      noarch
Requires:       scilab = %{version}
Recommends:     scilab-modules-doc = %{version}

%description    modules
Scilab is the free software for numerical computation providing a powerful
computing environment for engineering and scientific applications. It
includes hundreds of mathematical functions. It has a high level programming
language allowing access to advanced data structures, 2-D and 3-D graphical
functions.

This package provides Scilab modules.

%package        modules-doc
Summary:        Documentation for Scilab modules
Group:          Documentation/Other
BuildArch:      noarch
Requires:       %{name} = %{version}
Recommends:     %{name}-modules-doc-lang = %{version}

%description    modules-doc
Scilab is the free software for numerical computation providing a powerful
computing environment for engineering and scientific applications. It
includes hundreds of mathematical functions. It has a high level programming
language allowing access to advanced data structures, 2-D and 3-D graphical
functions.

This package provides documentation files for Scilab modules.

%package        tests
Summary:        Provides test files for Scilab
Group:          Development/Tools/Other
BuildArch:      noarch
Requires:       %{name} = %{version}
# Requires:       testng

%description    tests
Scilab is the free software for numerical computation providing a powerful
computing environment for engineering and scientific applications. It
includes hundreds of mathematical functions. It has a high level programming
language allowing access to advanced data structures, 2-D and 3-D graphical
functions.

This package provides test files for Scilab.

%lang_package
%lang_package -n %{name}-modules-doc

%prep
%setup -q

%patch1 -p1
# PATCH5 and PATCH13 have to be applied before PATCH2; all affect ./configure
%patch5 -p1
%patch2 -p1
%patch3 -p1

# Only > 13.2 and Leap have xmlgraphics-commons > 2.0
%if 0%{?suse_version} > 1320 || 0%{?suse_version} == 1315
%patch6 -p1
%endif
%patch7 -p1
%patch8 -p1
%patch9 -p1

# Fix Class-Path in manifest
sed -i '/name="Class-Path"/d' build.incl.xml
sed -i '/name="Class-Path"/d' modules/javasci/build.xml
sed -i '/name="Class-Path"/d' modules/scirenderer/build.xml

%build
%configure \
    --disable-static-system-lib \
    --without-umfpack \
    --without-emf

make %{?_smp_mflags}

export DISPLAY=%{X_display}
Xvfb %{X_display} >& Xvfb.log &
sleep 5
make %{?_smp_mflags} doc

%install
make %{?_smp_mflags} install DESTDIR=%{buildroot}

# Install .conf file so that ldconfig can find shared libs in non-std location
mkdir -p %{buildroot}/%{_sysconfdir}/ld.so.conf.d
echo %{_libdir}/%{name} > %{buildroot}/%{_sysconfdir}/ld.so.conf.d/%{name}.conf

# remove docs
rm -rf %{buildroot}%{_datadir}/scilab/ACK*
rm -rf %{buildroot}%{_datadir}/scilab/CHANGES*
rm -rf %{buildroot}%{_datadir}/scilab/COPYING*
rm -rf %{buildroot}%{_datadir}/scilab/README*
rm -rf %{buildroot}%{_datadir}/scilab/RELEASE*
rm -rf %{buildroot}%{_datadir}/scilab/Readme_Visual.txt
rm -rf %{buildroot}%{_datadir}/scilab/license.txt

# Remove more advanced repl, user should use CLI options instead
rm -fr %{buildroot}%{_datadir}/applications/%{name}-*.desktop

# Fix categories and install .desktop files
for i in scilab scinotes xcos; \
do
  desktop-file-install \
    --dir=%{buildroot}%{_datadir}/applications \
    desktop/$i.desktop;
done

%find_lang %{name} %{?no_lang_C}

# Remove la files
rm -fr %{buildroot}%{_libdir}/%{name}/*.la

# Add localized help files to scilab-doc.lang
# adapted from find-lang.sh
# always provide the english help to handle missing localized help pages
find %{buildroot}%{_datadir}/%{name}/modules/helptools/jar -type f -o -type l|sed '
s:'"%{buildroot}"'::
s:\(.*/'"%{name}"'_\)\([^\._]\+\)\(.*\.jar$\):%lang(\2) \1\2\3:
s:^\([^%].*\)::
s:%lang(en) ::
s:%lang(C) ::
/^$/d' |tee %{name}-modules-doc.lang
# Remove en localization doc files from lang package; bundle these in %{name}-modules-doc directly
sed -i '/scilab_en_US_help.jar/d' %{name}-modules-doc.lang
sed -i '/scilab_images.jar/d' %{name}-modules-doc.lang

%fdupes %{buildroot}%{_datadir}/%{name}/contrib/
%fdupes %{buildroot}%{_datadir}/%{name}/modules/
%fdupes %{buildroot}%{_datadir}/icons/hicolor/24x24/mimetypes/
# All scilab binaries in %%{_bindir} are essentially the same bash script, (hard) link them
%fdupes %{buildroot}%{_bindir}/

# FIXME: Disable tests until checkstyle and cobertura builds are fixed for openSUSE >= 13.1
# FIXME: Weird jvm crashes causes a test to fail, disable for openSUSE 12.3 also for now
%if 0%{?suse_version} < 1230
%check
echo $MALLOC_CHECK_
echo $MALLOC_PERTURB_
make check
%endif

%post -n %{soname}
/sbin/ldconfig

%postun -n %{soname}
/sbin/ldconfig

%post
%mime_database_post
%desktop_database_post
%icon_theme_cache_post

%postun
%mime_database_postun
%desktop_database_postun
%icon_theme_cache_postun

%files -n %{soname}
%defattr(-,root,root)
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/*.so.*

%files
%defattr(-,root,root)
%doc ACKNOWLEDGEMENTS
%doc CHANGES_2.X CHANGES_3.X CHANGES_4.X CHANGES_5.0.X CHANGES_5.1.X CHANGES_5.2.X CHANGES_5.3.X CHANGES_5.4.X CHANGES_5.5.X
%doc RELEASE_NOTES_5.0.X RELEASE_NOTES_5.1.X RELEASE_NOTES_5.2.X RELEASE_NOTES_5.3.X
%doc README_Unix
%{_bindir}/*
%dir %{_datadir}/%{name}/
%{_datadir}/%{name}/etc/
%{_datadir}/%{name}/Version.incl
%{_datadir}/applications/*.desktop
%{_datadir}/icons/*/*/*/*.png
%{_datadir}/mime/packages/%{name}.xml
%{_datadir}/%{name}/contrib
%{_datadir}/%{name}/tools
%dir %{_datadir}/appdata
%{_datadir}/appdata/scilab.appdata.xml

%files lang -f %{name}.lang
%defattr(-,root,root)

%files modules
%defattr(-,root,root)
%{_datadir}/%{name}/modules/
# part of scilab-doc
%exclude %{_datadir}/%{name}/modules/helptools/jar/%{name}_*.jar
%exclude %{_datadir}/%{name}/modules/*/examples
%exclude %{_datadir}/%{name}/modules/*/help
# part of scilab-tests
%exclude %{_datadir}/%{name}/modules/*/tests

%files modules-doc
%defattr(-,root,root)
%{_datadir}/%{name}/modules/*/examples
%{_datadir}/%{name}/modules/*/help
%{_datadir}/%{name}/modules/helptools/jar/%{name}_images.jar
%{_datadir}/%{name}/modules/helptools/jar/%{name}_en_US_help.jar

%files modules-doc-lang -f %{name}-modules-doc.lang
%defattr(-,root,root)

%files devel
%defattr(-,root,root)
%doc COPYING license.txt
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/*.so
%{_includedir}/%{name}/
%{_libdir}/pkgconfig/%{name}.pc
%config %{_sysconfdir}/ld.so.conf.d/%{name}.conf

%files tests
%defattr(-,root,root)
%{_datadir}/%{name}/modules/*/tests

%changelog
openSUSE Build Service is sponsored by