File cgx.spec of Package cgx

#
# spec file for package cgx
#
# 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 https://bugs.opensuse.org/
#


%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "doc"
%define psuffix -doc-src
%endif

Name:           cgx%{?psuffix}
Version:        2.22
Release:        0
Summary:        An open source finite element pre/postprocessor
# main code: GPLv2
# GPLv2+: libSNL
License:        GPL-2.0-only AND GPL-2.0-or-later
Group:          Productivity/Scientific/Other
URL:            http://www.calculix.de/
Source0:        http://www.dhondt.de/cgx_%{version}.all.tar.bz2
Source1:        calculix.png
# PATCH-FIX-OPENSUSE patch-cgx-src-makefile
Patch0:         cgx-2.8-src-makefile.patch
# PATCH-FIX-OPENSUSE patch-cgx-freeglut
Patch2:         cgx-2.8-freeglut.patch
# PATCH-FIX-OPENSUSE patch-cgx-libSNL-shared
Patch3:         cgx-2.8-libSNL-shared.patch
Patch5:         cgx-2.11-CXX.patch
# PATCH-FIX-OPENSUSE
Patch6:         0001-Add-explicit-namespace-std-for-cout-and-endl.patch
%if "%{flavor}" == "doc"
BuildRequires:  texlive-epstopdf
BuildRequires:  latex2html
BuildArch:      noarch
%else
BuildRequires:  Mesa-devel
BuildRequires:  freeglut-devel
BuildRequires:  gcc-c++
BuildRequires:  libSNL-devel
BuildRequires:  update-desktop-files
Recommends:     ccx
Suggests:       cgx-doc
Suggests:       cgx-examples
%endif

%description
CGX is a pre/postprocessor for the finite element packages
CalculiX. It also supports the DUNS and openFoam results
file formats.

%package examples
Summary:        Example problems for cgx
Group:          Productivity/Scientific/Other
BuildArch:      noarch

%description examples
CGX is a pre/postprocessor for the finite element packages
CalculiX. cgx-examples contains examples.

%package -n cgx-doc
Summary:        Documentation for cgx
BuildArch:      noarch

%description -n cgx-doc
Documentation for CGX, the CalculiX pre/postprocessor

%prep
%setup -q -c

# simplify directory tree
mv CalculiX/cgx_%{version}*/* .
rm -Rf CalculiX

%autopatch -p1

%build
# use rpm's proposal for CFLAGS
%if "%{flavor}" == ""
export GLOBAL_OFLAGS="%{optflags}"
make -C src %{?_smp_mflags}

%else
pushd doc
pdflatex cgx.tex ; pdflatex cgx.tex ; pdflatex cgx.tex
rm *eps-converted-to.pdf
popd
chmod -f 644 doc/*.pdf
%endif

# prepare documentation files
chmod -f 644 {README,CHANGES,COPYING}

%install
%if "%{flavor}" == ""
install -Dm 755 -t %{buildroot}%{_bindir} src/cgx

find ./examples/ -type f \( -name '*.bak' -or -name '*~' \) -exec rm {} \;
find ./examples/ -type f -exec chmod 644 {} \;
mkdir -p %{buildroot}/%{_datadir}/%{name}-examples-%{version}
cp -r examples/* %{buildroot}/%{_datadir}/%{name}-examples-%{version}

install -Dm 0644 %{SOURCE1} %{buildroot}%{_datadir}/icons/hicolor/64x64/%{name}.png
%suse_update_desktop_file -c %{name} %{name} "CalculiX Finite Elements Solver" %{name} %{name} "Education Engineering"
%endif

%if "%{flavor}" == ""
%files
%license COPYING
%doc README CHANGES
%{_bindir}/cgx
%dir %{_datadir}/icons/hicolor/
%dir %{_datadir}/icons/hicolor/64x64/
%{_datadir}/icons/hicolor/64x64/%{name}.png
%{_datadir}/applications/%{name}.desktop

%files examples
%{_datadir}/%{name}-examples-%{version}
%else

%files -n cgx-doc
%doc doc/*.pdf
%endif

%changelog
openSUSE Build Service is sponsored by