## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 6;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global octpkg mcxlab
%global project mcxcl

%global forgeurl  https://github.com/fangq/%{project}

Name:           octave-%{octpkg}
Version:        2024.2
Release:        %autorelease
Summary:        MCXLAB - A GPU Monte Carlo 3-D photon transport simulator for MATLAB/Octave
License:        GPL-3.0-or-later
URL:            http://mcx.space
%forgemeta

Source0:        %forgesource
# Fix linking flags
# https://github.com/fangq/mcxcl/pull/51
Patch:          %{forgeurl}/pull/51.patch
BuildRequires:  make
BuildRequires:  octave-devel
BuildRequires:  gcc-c++
BuildRequires:  git-core
BuildRequires:  vim-common
BuildRequires:  opencl-headers
BuildRequires:  ocl-icd-devel

Requires:       octave opencl-filesystem
Requires(post): octave
Requires(postun): octave

%description
Monte Carlo eXtreme OpenCL (MCX-CL) is a fast photon transport simulation
software for 3D heterogeneous turbid media, accelerated by GPUs.
MCXLAB-CL is the native MEX version of MCX-CL for Matlab and GNU Octave.
It contains the entire MCX-CL code into a MEX function which can be called
directly inside Matlab or Octave. The input and output files in MCX are
replaced by convenient in-memory struct variables in MCXLAB-CL, thus,
making it much easier to use and interact. Matlab/Octave also provides
convenient plotting and data analysis functions. With MCXLAB-CL, your
analysis can be streamlined and speed-up without involving disk files.

%prep
%forgeautosetup -S git

rm -rf .git_filters deploy setup example
cp utils/*.m mcxlabcl

cat > DESCRIPTION << EOF
Name: %{octpkg}
Version: %{version}
Date: %(date +"%Y-%d-%m")
Title: %{summary}
Author: Qianqian Fang <fangqq@gmail.com>
Maintainer: Qianqian Fang <fangqq@gmail.com>
Description: Monte Carlo eXtreme OpenCL (MCX-CL) is a fast photon transport simulation 
 software for 3D heterogeneous turbid media, accelerated by GPUs.
 MCXLAB-CL is the native MEX version of MCX-CL for Matlab and GNU Octave. 
 It contains the entire MCX-CL code into a MEX function which can be called 
 directly inside Matlab or Octave. The input and output files in MCX are 
 replaced by convenient in-memory struct variables in MCXLAB-CL, thus, 
 making it much easier to use and interact. Matlab/Octave also provides 
 convenient plotting and data analysis functions. With MCXLAB-CL, your 
 analysis can be streamlined and speed-up without involving disk files.
EOF

cp LICENSE.txt COPYING

cat > INDEX << EOF
mcxlabcl >> MCXLABCL
MCXLABCL
 cwdiffusion
 getdistance
 hobbysplines
 image3i
 islicer
 loadmc2
 loadmch
 json2mcx
 mcx2json
 mcxdcsg1
 mcxdetphoton
 mcxdettime
 mcxdettpsf
 mcxdetweight
 mcxfluence2energy
 mcxlabcl
 mcxloadfile
 mcxloadnii
 mcxmeanpath
 mcxmeanscat
 mcxplotphotons
 mcxplotvol
 normalizemcx
 serialcorr
 slice3i
 stacked_bar3
 tddiffusion
EOF

%build
cd src
make oct LIBOPENCLDIR=`octave-config -p OCTLIBDIR`
cd ../
rm README.txt
mv mcxlabcl/README.txt .
rm mcxlabcl/*.txt
mv mcxlabcl/examples .
mv mcxlabcl inst
rm -rf src
rm -rf doc
%octave_pkg_build

%install
%octave_pkg_install

%post
%octave_cmd pkg rebuild

%preun
%octave_pkg_preun

%postun
%octave_cmd pkg rebuild

%files
%license LICENSE.txt
%doc examples README.txt AUTHORS.txt
%dir %{octpkgdir}
%{octpkgdir}/DESCRIPTION
%{octpkgdir}/INDEX
%{octpkgdir}/PKG_ADD
%{octpkgdir}/*.m
%{octpkgdir}/*.mex
%doc %{octpkgdir}/doc-cache
%doc %{octpkgdir}/NEWS
%{octpkgdir}/packinfo

%changelog
## START: Generated by rpmautospec
* Thu Jul 18 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2024.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Tue Jul 09 2024 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 2024.2-5
- feat: upload sources

* Tue Jul 09 2024 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 2024.2-4
- feat: spdx license

* Wed Jun 05 2024 Orion Poplawski <orion@nwra.com> - 2024.2-1
- Update to 2024.2
- Add patch to fix linkage with Octave 9.1+

* Thu Jan 25 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Thu Jul 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Sun Apr 09 2023 Orion Poplawski <orion@nwra.com> - 0.9.5-10
- Rebuild for octave 8.1.0

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Wed Jun 01 2022 Orion Poplawski <orion@nwra.com> - 0.9.5-7
- Rebuild for octave 7.1

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Wed Oct 02 2019 Qianqian Fang <fangqq@gmail.com> - 0.9.5-1
- Initial package

## END: Generated by rpmautospec