# 1. Commit Hash from your build logs %global commit e3825986359ecd75d82aa88ff2015d36e234e55d %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global date 20260106 Name: minc-tools Version: 2.3.2 Release: 8.%{date}git%{shortcommit}%{?dist} Summary: Basic command-line tools for MINC files License: BSD-3-Clause URL: https://github.com/BIC-MNI/minc-tools Source0: https://github.com/BIC-MNI/%{name}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: make BuildRequires: bison BuildRequires: flex # NeuroFedora Dependencies BuildRequires: libminc-devel BuildRequires: netcdf-devel BuildRequires: hdf5-devel BuildRequires: zlib-devel # Runtime scripts often need these Requires: ImageMagick Requires: perl %description A collection of tools that work on MINC format images, including: mincinfo, mincresample, mincreshape, minccalc, and mincstats. %prep # Unpack the specific commit directory %autosetup -n %{name}-%{commit} # Fedora's libminc-devel 2.5.0 LIBMINCConfig.cmake derives its install prefix # one directory too shallow: the config sits in %{_libdir}/cmake/LIBMINC and # takes "${CMAKE_CURRENT_LIST_DIR}/../../" as the prefix, which is %{_libdir}, # not /usr. Every path it exports is then wrong, including # LIBMINC_USE_FILE = %{_libdir}/lib64/cmake/LIBMINC/UseLIBMINC.cmake # and CMakeLists.txt:46 INCLUDEs exactly that, so configure fails with # INCLUDE could not find requested file # We already override LIBMINC_INCLUDE_DIR and LIBMINC_LIBRARY below, which is # why only the USE_FILE path bites. Use LIBMINC_CMAKE_DIR instead, which the # same config computes correctly from CMAKE_CURRENT_LIST_FILE. # Reported: docs/upstream/fedora-libminc-config-prefix.md sed -i 's|INCLUDE( ${LIBMINC_USE_FILE} )|INCLUDE( ${LIBMINC_CMAKE_DIR}/UseLIBMINC.cmake )|' CMakeLists.txt grep -q 'INCLUDE( ${LIBMINC_CMAKE_DIR}/UseLIBMINC.cmake )' CMakeLists.txt # --- FIX 1: C23 Standard Conflicts (NAN collision) --- sed -i 's/\bNAN\b/MINC_NAN/g' progs/minccalc/gram.y sed -i 's/\bNAN\b/MINC_NAN/g' progs/minccalc/lex.l # --- FIX 2: C23/HDF5 Conflict (true/false keywords) --- sed -i '/enum {false=0, true=1};/d' progs/mincdump/mincdump.h # cmake 4.x: drop the IF(COMMAND CMAKE_POLICY) block that SETs CMP0026 OLD — # CMP0026 (LOCATION property read on TARGET) was removed in CMake 4.x and # the SET call now hard-errors. sed -i '/^IF(COMMAND CMAKE_POLICY)/,/^ENDIF(COMMAND CMAKE_POLICY)/d' CMakeLists.txt # Testing/CMakeLists.txt uses GET_PROPERTY(... TARGET tgt PROPERTY LOCATION) # (the same removed CMP0026 mechanism). Disable the Testing subdir entirely # (we don't run upstream's tests in the RPM build anyway). sed -i '/add_subdirectory[[:space:]]*(Testing)/Id; /ADD_SUBDIRECTORY[[:space:]]*(Testing)/Id' CMakeLists.txt # netCDF API, and it is NOT a flat rename -- which is why this has to be # conditional. netcdf.h as of 4.9.3 (F44+): # #ifdef NETCDF_ENABLE_LEGACY_MACROS # #define _FillValue "_FillValue" # #endif # #define NC_FillValue "_FillValue" # so NC_FillValue is unconditional there and _FillValue is opt-in. But netcdf # 4.9.2, which is what F43 ships, defines ONLY _FillValue and has no # NC_FillValue at all. Applying the rename there does not fix anything, it # BREAKS the build: f43 failed with "'NC_FillValue' undeclared ... did you # mean 'MI_FillValue'?" (11082193) caused by this very sed. # # Probe the installed header for the symbol rather than version-compare the # distro: the question is "does this netcdf expose NC_FillValue", and the # header answers it directly. netcdf-devel is a BuildRequires, so it is # present by %prep. if grep -qE '^[[:space:]]*#[[:space:]]*define[[:space:]]+NC_FillValue\b' %{_includedir}/netcdf.h; then find progs -name '*.[chyl]' -exec sed -i 's/\b_FillValue\b/NC_FillValue/g' {} + grep -q '\bNC_FillValue\b' progs/mincgen/ncgentab.y \ || { echo "ERROR: netcdf exposes NC_FillValue but the rename did not apply" >&2; exit 1; } else # Pre-4.9.3: the source's own _FillValue is correct. Assert it survived, # so a future source change that drops it cannot pass silently. grep -q '\b_FillValue\b' progs/mincgen/ncgentab.y \ || { echo "ERROR: no _FillValue in ncgentab.y on a netcdf without NC_FillValue" >&2; exit 1; } fi # --- FIX 3: Cleanly Rewrite conversion/CMakeLists.txt --- # We overwrite this file to: # 1. Disable the broken NIfTI tools # 2. Properly build the internal 'acr_nema' library which lacks its own build file cat > conversion/CMakeLists.txt << 'EOF' INCLUDE_DIRECTORIES(${LIBMINC_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/Acr_nema) # Manually define the helper library sources SET(ACR_SRCS Acr_nema/acr_io.c Acr_nema/dicom_client_routines.c Acr_nema/dicom_network.c Acr_nema/element.c Acr_nema/file_io.c Acr_nema/globals.c Acr_nema/group.c Acr_nema/message.c Acr_nema/value_repr.c ) # Create the static library locally ADD_LIBRARY(acr_nema STATIC ${ACR_SRCS}) # Tool: minctoecat (Needs acr_nema) ADD_EXECUTABLE(minctoecat minctoecat/minctoecat.c minctoecat/ecat_write.c minctoecat/machine_indep.c ) TARGET_LINK_LIBRARIES(minctoecat acr_nema ${LIBMINC_LIBRARIES} m) # Tool: ecattominc ADD_EXECUTABLE(ecattominc ecattominc/ecattominc.c ecattominc/insertblood.c ecattominc/ecat_file.c ecattominc/machine_indep.c ) TARGET_LINK_LIBRARIES(ecattominc ${LIBMINC_LIBRARIES}) # Tool: upet2mnc ADD_EXECUTABLE(upet2mnc micropet/upet2mnc.c) TARGET_LINK_LIBRARIES(upet2mnc ${LIBMINC_LIBRARIES}) # Install these tools to bin/ INSTALL(TARGETS minctoecat ecattominc upet2mnc DESTINATION bin) EOF %build # --- FIX 4: Linker & Compiler Flags --- # -std=gnu17: Forces older C standard to avoid strict C23 keyword errors. # -fcommon: Allows legacy global variables (fixes "multiple definition" errors). export CFLAGS="%{optflags} -std=gnu17 -fcommon" %cmake \ -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \ -DBUILD_TESTING=OFF \ -DLIBMINC_DIR=%{_libdir}/cmake/libminc \ -DLIBMINC_INCLUDE_DIR=%{_includedir} \ -DLIBMINC_LIBRARY=%{_libdir}/libminc.so %cmake_build %install %cmake_install # Fix man page location — cmake installs to /usr/man/ instead of /usr/share/man/ if [ -d %{buildroot}%{_prefix}/man ]; then mkdir -p %{buildroot}%{_mandir} cp -a %{buildroot}%{_prefix}/man/* %{buildroot}%{_mandir}/ rm -rf %{buildroot}%{_prefix}/man fi %check # Tests disabled (-DBUILD_TESTING=OFF) — upstream's Testing/CMakeLists.txt # uses TARGET LOCATION property reads that cmake 4.x removed. %files %license COPYING # Use wildcard for README to match whatever is present (README or README.md) %doc README* %{_bindir}/minc* %{_bindir}/rawtominc %{_bindir}/voxeltoworld %{_bindir}/worldtovoxel %{_bindir}/invert_raw_image %{_bindir}/ecattominc %{_bindir}/upet2mnc %{_bindir}/transformtags %{_bindir}/xfmconcat %{_bindir}/xfminvert %{_bindir}/xfm* %{_mandir}/man1/*.1* %changelog * Mon Oct 05 2026 Morgan Hough - 2.3.2-8.20260106gite382598 - Make the _FillValue -> NC_FillValue rename CONDITIONAL on the installed netcdf. It is not a flat rename: netcdf 4.9.3 (F44+) defines NC_FillValue unconditionally and _FillValue only under NETCDF_ENABLE_LEGACY_MACROS, while netcdf 4.9.2 (F43) defines only _FillValue and has no NC_FillValue at all. The unconditional sed therefore BROKE f43: "'NC_FillValue' undeclared ... did you mean 'MI_FillValue'?" (build 11082193), caused by the sed meant to fix the opposite problem. - Probe %%{_includedir}/netcdf.h for the #define rather than version-compare the distro; netcdf-devel is a BuildRequires so the header is there by %%prep. Both branches assert their expected post-state, and the probe was tested in all three directions -- it matches 4.9.3, does not match a simulated 4.9.2, and is not satisfied by MI_FillValue. * Sat Sep 19 2026 Morgan Hough - 2.3.2-7.20260106gite382598 - Work around Fedora libminc-devel 2.5.0's broken LIBMINCConfig.cmake, which computes its install prefix as %%{_libdir} instead of /usr and so points LIBMINC_USE_FILE at %%{_libdir}/lib64/cmake/LIBMINC/UseLIBMINC.cmake. f45 aarch64 failed at configure on it (11005218); f44 is unaffected because Fedora ships libminc 2.4 there. Use LIBMINC_CMAKE_DIR, which the same config gets right. * Sat May 23 2026 Morgan Hough - 2.3.2-6.20260106gite382598 - Rename _FillValue to NC_FillValue in progs/mincgen — newer libnetcdf drops the underscore-prefixed identifier (reserved-to-implementation) * Sat May 23 2026 Morgan Hough - 2.3.2-5.20260106gite382598 - Drop CMAKE_POLICY(SET CMP0026 OLD) block (CMP0026 was removed in cmake 4.x); disable Testing/ subdir (its GET_PROPERTY ... LOCATION reads are also gone) * Sat May 23 2026 Morgan Hough - 2.3.2-4.20260106gite382598 - Add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 for cmake 4.x compatibility (F44+) * Mon Mar 16 2026 Morgan Hough - 2.3.2-2.20260106gite382598 - Fix man page installation: /usr/man/ -> /usr/share/man/ - Include man pages in files list * Tue Jan 06 2026 Matthew Hough - 2.3.2-1.20260106gite382598 - Initial package for NeuroFedora - Update to latest git snapshot (e382598) - Fix C23 compatibility issues (NAN, true/false keywords) - Fix legacy linker errors with -fcommon - Completely rewrite conversion/CMakeLists.txt to fix linking