# This flag prevents internal links %undefine _ld_as_needed %global post_release 1 %if 0%{?post_release} %global commit a6e6a2cfa92f93a3ee2971ebc9ddfc3b0b581ab2 %global date 20250704git %global shortcommit %(c=%{commit}; echo ${c:0:7}) %else %global commit %{nil} %global date %{nil} %global shortcommit %{nil} %endif %if %{?__isa_bits:%{__isa_bits}}%{!?__isa_bits:32} == 64 %global arch64 1 %else %global arch64 0 %endif Name: metis Version: 5.2.1 Release: %autorelease -s %{date}git%{shortcommit} Summary: Serial Graph Partitioning and Fill-reducing Matrix Ordering License: ASL 2.0 AND LGPL-2.0-or-later URL: https://github.com/KarypisLab/METIS %if 0%{?post_release} Source0: https://github.com/KarypisLab/METIS/archive/%{commit}/METIS-%{commit}.tar.gz %else Source0: https://github.com/KarypisLab/METIS/archive/%{version}/METIS-%{version}.tar.gz %endif Patch0: %{name}-%{version}-installation.patch Patch1: %{name}-%{version}-set_metis_header.patch ## Rename library of 64 integer version Patch4: %{name}-%{version}_lib64.patch Patch2: %{name}-%{version}-set_metis64_header.patch # Remove pre-included arch-specific flags Patch5: %{name}-%{version}-specific_architecture_flags.patch Patch6: %{name}-%{version}-set_cmake_config.patch BuildRequires: make BuildRequires: cmake BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: pcre-devel BuildRequires: help2man BuildRequires: chrpath BuildRequires: GKlib-devel %description METIS is a set of serial programs for partitioning graphs, partitioning finite element meshes, and producing fill reducing orderings for sparse matrices. The algorithms implemented in METIS are based on the multilevel recursive-bisection, multilevel k-way, and multi-constraint partitioning schemes developed in our lab. METIS is distributed with OpenMP support. %package devel Summary: METIS headers and development-related files Requires: %{name}%{?_isa} = %{version}-%{release} %description devel Header and library files of Metis. %if 0%{?arch64} %package -n metis64 Summary: Serial Graph Partitioning and Fill-reducing Matrix Ordering (64bit INTEGER) %description -n metis64 METIS is a set of serial programs for partitioning graphs, partitioning finite element meshes, and producing fill reducing orderings for sparse matrices. The algorithms implemented in METIS are based on the multilevel recursive-bisection, multilevel k-way, and multi-constraint partitioning schemes developed in our lab. METIS is distributed with OpenMP support. This build has 64bit INTEGER support. %package -n metis64-devel Summary: METIS development libraries (64bit INTEGER) Requires: metis64%{?_isa} = %{version}-%{release} %description -n metis64-devel Header and library files of Metis, OpenMP version (64bit INTEGER). %endif %prep %setup -qc pushd METIS-%{commit} %patch -P 0 -p1 -b .backup %patch -P 1 -p1 -b .backup %patch -P 5 -p1 -b .backup %patch -P 6 -p1 -b .backup popd %if 0%{?arch64} cp -a METIS-%{commit} metis64 pushd metis64 %patch -P 4 -p1 -b .backup popd %endif %build PCRE_LDFLAGS="-lpcreposix" GK_LDFLAGS="-lGKlib" %cmake -S METIS-%{commit} -B METIS-%{commit} \ %if "%{?_lib}" == "lib64" %{?_cmake_lib_suffix64} \ %endif -DCMAKE_BUILD_TYPE:STRING=Release \ -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON \ -DGKLIB_PATH=%{_prefix} \ -DSHARED:BOOL=ON \ -DOPENMP:BOOL=ON \ -DPCRE:BOOL=ON \ -DVALGRIND:BOOL=ON \ -DCMAKE_C_FLAGS:STRING="%{optflags} -I../include" \ -DCMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING="%{__global_ldflags} ${PCRE_LDFLAGS} ${GK_LDFLAGS}" \ -DCMAKE_EXE_LINKER_FLAGS_RELEASE:STRING="%{__global_ldflags} ${PCRE_LDFLAGS} ${GK_LDFLAGS}" \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE \ -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} %define __cmake_builddir METIS-%{commit} %cmake_build %if 0%{?arch64} PCRE_LDFLAGS="-lpcreposix" GK_LDFLAGS="-lGKlib" %cmake -S metis64 -B metis64 \ %if "%{?_lib}" == "lib64" %{?_cmake_lib_suffix64} \ %endif -DCMAKE_BUILD_TYPE:STRING=Release \ -Dintsize:STRING=64 -Drealsize:STRING=64 \ -DGKLIB_PATH=%{_prefix} \ -DCMAKE_SKIP_INSTALL_RPATH:BOOL=YES\ -DSHARED:BOOL=ON \ -DOPENMP:BOOL=ON \ -DPCRE:BOOL=ON \ -DCMAKE_C_FLAGS:STRING="%{optflags} -I../include" \ -DCMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING="%{__global_ldflags} $PCRE_LDFLAGS ${GK_LDFLAGS}" \ -DCMAKE_EXE_LINKER_FLAGS_RELEASE:STRING="%{__global_ldflags} $PCRE_LDFLAGS ${GK_LDFLAGS}" \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE \ -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} %define __cmake_builddir metis64 %cmake_build pushd metis64 mv include/metis.h include/metis64.h patch -p1 < %{PATCH2} popd %endif %install %define __cmake_builddir METIS-%{commit} %cmake_install mkdir -p %{buildroot}%{_includedir} ## Generate manpages from binaries LD_PRELOAD=%{buildroot}%{_libdir}/lib%{name}.so.0 \ help2man --version-string="%{version}" -n "Partitions a graph into a specified number of parts." \ -N --output="gpmetis.1" --no-discard-stderr --help-option="-help" %{buildroot}%{_bindir}/gpmetis LD_PRELOAD=%{buildroot}%{_libdir}/lib%{name}.so.0 \ help2man --version-string="%{version}" \ -n "Computes a fill-reducing ordering of the vertices of the graph using multilevel nested dissection." \ -N --output="ndmetis.1" --no-discard-stderr --help-option="-help" %{buildroot}%{_bindir}/ndmetis LD_PRELOAD=%{buildroot}%{_libdir}/lib%{name}.so.0 \ help2man --version-string="%{version}" -n "Partitions a mesh into a specified number of parts." \ -N --output="mpmetis.1" --no-discard-stderr --help-option="-help" %{buildroot}%{_bindir}/mpmetis LD_PRELOAD=%{buildroot}%{_libdir}/lib%{name}.so.0 \ help2man --version-string="%{version}" -n "Converts a mesh into a graph that is compatible with METIS." \ -N --output="m2gmetis.1" --no-discard-stderr -h "-help" %{buildroot}%{_bindir}/m2gmetis mkdir -p %{buildroot}%{_mandir}/man1 mv *.1 %{buildroot}%{_mandir}/man1 # Save metis.h install -pm 644 METIS-%{commit}/include/metis.h %{buildroot}%{_includedir}/ %if 0%{?arch64} %define __cmake_builddir metis64 %cmake_install # Save metis64.h install -pm 644 metis64/include/metis64.h %{buildroot}%{_includedir}/ %endif ## Remove rpaths chrpath -d %{buildroot}%{_bindir}/* %check cp -p %{buildroot}%{_bindir}/*metis METIS-%{commit}/graphs/ cp -p %{buildroot}%{_bindir}/graphchk METIS-%{commit}/graphs/ pushd METIS-%{commit}/graphs LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./ndmetis mdual.graph LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./mpmetis metis.mesh 2 LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./gpmetis test.mgraph 4 LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./gpmetis copter2.graph 4 LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./graphchk 4elt.graph popd %if 0%{?arch64} cp -p %{buildroot}%{_bindir}/*metis64 metis64/graphs/ cp -p %{buildroot}%{_bindir}/graphchk64 metis64/graphs/ pushd metis64/graphs LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./ndmetis64 mdual.graph LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./mpmetis64 metis.mesh 2 LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./gpmetis64 test.mgraph 4 LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./gpmetis64 copter2.graph 4 LD_LIBRARY_PATH=%{buildroot}%{_libdir}:$LD_LIBRARY_PATH ./graphchk64 4elt.graph popd %endif %files %doc METIS-%{commit}/Changelog METIS-%{commit}/manual/manual.pdf %license METIS-%{commit}/LICENSE %{_bindir}/cmpfillin %{_bindir}/gpmetis %{_bindir}/graphchk %{_bindir}/m2gmetis %{_bindir}/mpmetis %{_bindir}/ndmetis %{_mandir}/man1/*.1.gz %{_libdir}/lib%{name}.so.0 %files devel %{_includedir}/%{name}.h %{_libdir}/lib%{name}.so %if 0%{?arch64} %files -n metis64 %doc metis64/Changelog metis64/manual/manual.pdf %license metis64/LICENSE %{_bindir}/cmpfillin64 %{_bindir}/gpmetis64 %{_bindir}/graphchk64 %{_bindir}/m2gmetis64 %{_bindir}/mpmetis64 %{_bindir}/ndmetis64 %{_libdir}/lib%{name}64.so.0 %files -n metis64-devel %{_includedir}/%{name}64.h %{_libdir}/lib%{name}64.so %endif %changelog %autochangelog