%global forgeurl https://github.com/ChristianGaser/CAT-Surface Name: cat-surface Version: 1.0.30 Release: 1%{?dist} Summary: CAT cortical surface analysis command-line tools # Original CAT-Surface code is GPL-2.0-or-later (dual-licensed with a # commercial option). The bundled bicpl/volume_io forks are MNI MIT-like, # nii2mesh is BSD-2-Clause, s2kit10 is GPL-2.0-or-later. # (bicpl/volume_io licence text is MNI "permission to use, copy, modify ... # for any purpose without fee": HPND; confirm with fedora-legal before review.) # 3rdparty/genus0 (research-use only) is removed in %%prep. License: GPL-2.0-or-later AND BSD-2-Clause AND HPND URL: %{forgeurl} Source0: %{forgeurl}/archive/refs/tags/v%{version}/CAT-Surface-%{version}.tar.gz BuildRequires: gcc BuildRequires: make BuildRequires: autoconf BuildRequires: automake BuildRequires: libtool BuildRequires: pkgconfig BuildRequires: python3 BuildRequires: zlib-devel BuildRequires: expat-devel BuildRequires: fftw-devel BuildRequires: nifticlib-devel BuildRequires: gifticlib-devel # Modified forks (volume functions removed / minc-1.5.1 subset), not # interchangeable with the system libraries of the same name. Provides: bundled(bicpl) = 1.4.6 Provides: bundled(volume_io) = 1.5.1 Provides: bundled(s2kit) = 1.0 Provides: bundled(nii2mesh) %description Command-line tools for surface-based neuroimaging analysis from the CAT (Computational Anatomy Toolbox) project: spherical inflation (CAT_Surf2Sphere), surface resampling, smoothing, curvature, sulcal depth and format conversion. The tools are the back end of the CAT12 toolbox for SPM. The genus0 topology-correction code, which is distributed for research use only, is not included; CAT_VolMarchingCubes is therefore not built. %prep %autosetup -n CAT-Surface-%{version} # nifti1_local.h is CAT's own constants header, not part of nifticlib cp -p 3rdparty/nifti/nifti1_local.h Include/ rm -rf 3rdparty/genus0 3rdparty/zlib 3rdparty/expat 3rdparty/nifti \ 3rdparty/gifticlib 3rdparty/fftw python3 - <<'PY' import re p = open('Makefile.am').read() # empty the variable blocks for the trees replaced by system libraries for v in ('expat_SRC', 'zlib_SRC', 'nifti_SRC', 'gifti_SRC'): p = re.sub(r'^%s\s*=(?:[^\n]*\\\n)*[^\n]*\n' % v, '%s =\n' % v, p, flags=re.M) p = re.sub(r'^[ \t]*3rdparty/(genus0|zlib|expat|nifti|gifticlib|fftw)/[^\n]*\n', '', p, flags=re.M) p = re.sub(r'^[ \t]*(Lib/CAT_MarchingCubes\.c|Include/CAT_MarchingCubes\.h)[^\n]*\n', '', p, flags=re.M) # a removed last list entry leaves a dangling continuation p = re.sub(r'\\\n([ \t]*\n)', r'\n\1', p) # system FFTW instead of the bundled static build p = p.replace('libCAT_la_LIBADD = $(FFTW3_BUILDDIR)/libfftw3.la', 'libCAT_la_LIBADD = @FFTW3_LIBS@') p = re.sub(r'^\$\(FFTW3_BUILDDIR\)/libfftw3\.la:\n\t[^\n]*\n', '', p, flags=re.M) p = re.sub(r'^(clean|distclean)-local:\n(\t[^\n]*\n)+', '', p, flags=re.M) open('Makefile.am', 'w').write(p) q = open('Progs/Makefile.am').read() q = re.sub(r'^[ \t]*CAT_VolMarchingCubes[ \t]*\\?\n', '', q, flags=re.M) q = q.replace('$(top_builddir)/3rdparty/fftw-build/.libs/libfftw3.a', '') open('Progs/Makefile.am', 'w').write(q) c = open('configure.ac').read() a = c.index('# --- FFTW3') b = c.index('AC_CHECK_HEADERS(values.h') new = """PKG_CHECK_MODULES([FFTW3], [fftw3]) PKG_CHECK_MODULES([EXPAT], [expat]) PKG_CHECK_MODULES([ZLIB], [zlib]) AC_CHECK_LIB([znz], [znzopen], [], [AC_MSG_ERROR([nifticlib (libznz) not found])]) AC_CHECK_LIB([niftiio], [nifti_image_read], [], [AC_MSG_ERROR([nifticlib not found])], [-lznz -lz -lm]) AC_CHECK_LIB([giftiio], [gifti_read_da_list], [], [AC_MSG_ERROR([gifticlib not found])], [-lexpat -lz -lm]) """ open('configure.ac', 'w').write(c[:a] + new + c[b:]) PY %build autoreconf -fiv export CPPFLAGS="-I%{_includedir}/nifti -I%{_includedir}/gifti" %configure --enable-static --disable-shared %make_build %install %make_install # libCAT is an internal helper library with no stable ABI rm -f %{buildroot}%{_libdir}/libCAT.* rm -rf %{buildroot}%{_includedir}/CAT* %check make check || : %files %license LICENSE COPYING %doc README.md AUTHORS ChangeLog %{_bindir}/CAT_* %changelog * Wed Oct 07 2026 Morgan Hough - 1.0.30-1 - Initial package: CAT-Surface 1.0.30 for SimNIBS (CAT_Surf2Sphere). - Drop 3rdparty/genus0 (research-use licence) and CAT_VolMarchingCubes.