File geant4.spec of Package geant4.11.0

%define debug_build 1

%define g4Name          geant4
%define g4Version       11.0

%if 0%{?rocky_version}
%define bash_config_file   /etc/bashrc
%define csh_config_file    /etc/csh.cshrc
%else
%define bash_config_file   /etc/bash.bashrc.local
%define csh_config_file    /etc/csh.cshrc.local
%endif

Name:          %{g4Name}.%{g4Version}
Version:	      0
Release:	      0
Summary:	      Toolkit for the simulation of the passage of particles through matter
License:	      Geant4
Group:         Productivity/Scientific/Physics
Url:		      http://geant4.web.cern.ch/geant4/support/source/

Source0:	      %{g4Name}-%{version}.tar.gz
Source1:	      %{g4Name}_build_options
Source11:      %{g4Name}-rpmlintrc

Source21:      G4-LEND.patch
Patch0:        G4-multi.patch

%description
Geant simulates the passage of subatomic particles through matter, for instance, particle detectors. Geant 3 simulations are performed by linking Fortran code supplied by the user with the Geant libraries, then running the resulting executable. This package includes gxint, the script used to perform this linking step. Geant 4 is a complete rewrite in C++ with addition of other modern features and detectors.

###############################################################################################################################

%debug_package

###############################################################################################################################

%package       libs
Summary:	      Shared libraries for Geant4
Group:         Productivity/Scientific/Physics

BuildRequires:	cmake >= 3.16
BuildRequires:	gcc-c++

BuildRequires:	libexpat-devel
BuildRequires:	(freetype2-devel or freetype-devel)
BuildRequires:	motif-devel 
BuildRequires:	libxerces-c-devel 
BuildRequires:	zlib-devel 
BuildRequires:	tbb-devel
BuildRequires:	glew-devel
BuildRequires:	eigen3-devel
BuildRequires:	libXmu-devel
BuildRequires:	libqt5-qt3d-devel
BuildRequires:	libqt5-qtbase-devel
#BuildRequires:	vtk-devel
%if 0%{?rocky_version}
%else
BuildRequires:	hdf5-devel
BuildRequires:	SoQt-devel
%endif

%description   libs
This package provides the shared libraries for Geant4 - a toolkit for the simulation of the passage of particles through matter.

###############################################################################################################################

%package       devel
Summary:	      Development files for Geant4
Group:         Development/Languages/C and C++
BuildArch:     noarch

Requires: cmake >= 3.16
Requires: gcc-c++

Requires: libexpat-devel
Requires: (freetype2-devel or freetype-devel)
Requires: motif-devel 
Requires: libxerces-c-devel 
Requires: zlib-devel 
Requires: tbb-devel
Requires: glew-devel
Requires: eigen3-devel
Requires: libXmu-devel
Requires: libqt5-qt3d-devel
Requires: libqt5-qtbase-devel
#Requires: vtk-devel
%if 0%{?rocky_version}
%else
Requires: hdf5-devel
Requires: SoQt-devel
%endif

Requires: %{name}-libs
Requires: (geant4-data-G4NDL-4.6-multi-version or geant4-data-G4NDL-4.6), (geant4-data-G4EMLOW-8.0-multi-version or geant4-data-G4EMLOW-8.0), (geant4-data-PhotonEvaporation-5.7-multi-version or geant4-data-PhotonEvaporation-5.7), (geant4-data-RadioactiveDecay-5.6-multi-version or geant4-data-RadioactiveDecay-5.6), (geant4-data-G4PARTICLEXS-4.0-multi-version or geant4-data-G4PARTICLEXS-4.0), (geant4-data-G4PII-1.3-multi-version or geant4-data-G4PII-1.3), (geant4-data-RealSurface-2.2-multi-version or geant4-data-RealSurface-2.2), (geant4-data-G4SAIDDATA-2.0-multi-version or geant4-data-G4SAIDDATA-2.0), (geant4-data-G4ABLA-3.1-multi-version or geant4-data-G4ABLA-3.1), (geant4-data-G4INCL-1.0-multi-version or geant4-data-G4INCL-1.0), (geant4-data-G4ENSDFSTATE-2.3-multi-version or geant4-data-G4ENSDFSTATE-2.3), (geant4-data-G4TENDL-1.4-multi-version or geant4-data-G4TENDL-1.4), (geant4-data-LEND-1.3-multi-version or geant4-data-LEND-1.3)

%description   devel
Geant4 development components such as CMake modules and header files used by simulation applications.

###############################################################################################################################

%package       examples
Summary:	      Geant4 user examples
BuildArch:     noarch

%description   examples
Geant4 user examples to demonstrate the use of the toolkit.

###############################################################################################################################

%define g4InstallRoot   /opt/%{g4Name}
%define g4DataPath      %{g4InstallRoot}/%{g4Name}-data
%define g4ConfigPath    %{g4InstallRoot}/%{g4Name}-multi_config
%define g4InstallPath   %{g4InstallRoot}/%{name}
%define g4ExamplesPath  %{g4InstallRoot}/%{name}-examples

###############################################################################################################################

%prep
%setup -q -n	%{g4Name}-%{version}
find ./ -name .README* -delete
find ./ -name .cproject* -delete
find ./ -name .project* -delete
find ./ -name .gitignore* -delete
find ./ -name .doxygen* -type d -exec rm -rf {} +
find ./ -name .doxygen* -delete
find ./examples -name *.py -exec sed -i "1s@#!.*python.*@#!/usr/bin/python3@" {} \;
%patch0 -p1
cat %{SOURCE21} >> cmake/Modules/G4DatasetDefinitions.cmake
sed -i "s/OFF/ON/g" cmake/Modules/G4DatasetDefinitions.cmake

%build
%if 0%{?rocky_version}
%undefine __cmake_in_source_build
%endif
%cmake $(cat %{SOURCE1}) \
      -DCMAKE_INSTALL_PREFIX=%{g4InstallPath} \
      -DGEANT4_INSTALL_DATADIR=%{g4DataPath} \
%if 0%{?rocky_version}
   -DGEANT4_USE_HDF5=OFF \
   -DGEANT4_USE_INVENTOR_QT=OFF \
%endif
      %{nil}
%cmake_build

%install
%cmake_install

install -d -m 0755 %{buildroot}%{g4ExamplesPath}
cp -r examples %{buildroot}%{g4ExamplesPath}/%{name}

%post devel
if [[ $(ls %{g4ConfigPath}/%{name}.sh 2>/dev/null)  && ! $(grep source %{bash_config_file} | grep %{name}) ]] ; then echo 'source %{g4ConfigPath}/%{name}.sh'  >> %{bash_config_file} ; fi
if [[ $(ls %{g4ConfigPath}/%{name}.csh 2>/dev/null) && ! $(grep source %{csh_config_file}  | grep %{name}) ]] ; then echo 'source %{g4ConfigPath}/%{name}.csh' >> %{csh_config_file}  ; fi

%postun devel
if [[ ! $(ls %{g4ConfigPath}/%{name}.sh 2>/dev/null)  && $(grep source %{bash_config_file} | grep %{name}) ]] ; then sed -i '/%{name}/d' %{bash_config_file} ; fi
if [[ ! $(ls %{g4ConfigPath}/%{name}.csh 2>/dev/null) && $(grep source %{csh_config_file}  | grep %{name}) ]] ; then sed -i '/%{name}/d' %{csh_config_file}  ; fi

%files examples
%dir %{g4ExamplesPath}
%dir %{g4ExamplesPath}/%{name}
%{g4ExamplesPath}/%{name}/*

%files libs
%dir %{g4InstallRoot}
%dir %{g4InstallPath}
%dir %{g4InstallPath}/lib*
%{g4InstallPath}/lib*/*

%files devel
%license LICENSE
%dir %{g4InstallPath}/bin
%{g4InstallPath}/bin/*
%dir %{g4InstallPath}/include
%{g4InstallPath}/include/*
%dir %{g4InstallPath}/share
%{g4InstallPath}/share/*
%dir %{g4ConfigPath}
%{g4ConfigPath}/%{name}*.sh
%{g4ConfigPath}/%{name}*.csh

%changelog

openSUSE Build Service is sponsored by