Skip to content

Commit

Permalink
scoch: update & switch to cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
3rav authored Sep 27, 2024
1 parent 2b74554 commit c57392c
Showing 1 changed file with 71 additions and 99 deletions.
170 changes: 71 additions & 99 deletions mingw-w64-scotch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
_realname=scotch
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}"
"${MINGW_PACKAGE_PREFIX}-${_realname}-int64")
"${MINGW_PACKAGE_PREFIX}-${_realname}64")
pkgdesc='Graph partitioning and sparse matrix ordering package (mingw-w64)'
pkgver=7.0.4
pkgrel=3
pkgver=7.0.5
pkgrel=1
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.labri.fr/perso/pelegrin/scotch/"
Expand All @@ -15,14 +15,16 @@ license=('spdx:CECILL-C')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
"${MINGW_PACKAGE_PREFIX}-libsystre")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-ninja"
$([[ ${CARCH} == aarch64 ]] || echo "${MINGW_PACKAGE_PREFIX}-msmpi"))
options=('!strip')
source=("https://gitlab.inria.fr/scotch/scotch/-/archive/v${pkgver}/${_realname}-v${pkgver}.tar.gz"
"Makefile.idx32.inc"
"Makefile.idx64.inc"
"0002-pipe-fix.patch"
"0004-dummysizes-regex.patch")
sha256sums=('8ef4719d6a3356e9c4ca7fefd7e2ac40deb69779a5c116f44da75d13b3d2c2c3'
sha256sums=('385507a9712bb9057497b9ac3f24ad2132bd3f3f8c7a62e78324fc58f2a0079b'
'4221b69dcc53230ff4d6bc18e3982f6d39971a99fc17f4dab609fc19b99d8a30'
'c52bf0598332d8139a37606e7ea9376b7f841059047c0c977b205a763fc7e97a'
'b6e76b1d2f35b3fcc771b97a35a468d6314ee3a619defef18b82fc7654638a49'
Expand All @@ -33,114 +35,84 @@ prepare() {
for p in ${source[*]:3}; do
patch -p1 -i "$srcdir/$p"
done
#sed -i 's/DESTINATION man/DESTINATION share\/man/g' ${srcdir}/${_realname}-v${pkgver}/CMakeLists.txt
}

_build_scotch() {
_idx_makefile_inc=$1
_idx_suffix=$2
_idx_opt=$1

# remove previous build artifacts
cd "${srcdir}/${_realname}-v${pkgver}"
rm -rfd include lib bin include${_idx_suffix} lib${_idx_suffix} bin${_idx_suffix}

cp -p "${srcdir}/${_idx_makefile_inc}" "${srcdir}/${_realname}-v${pkgver}/src/Makefile.inc"
cd "${srcdir}/${_realname}-v${pkgver}/src"

if [[ ${CARCH} != aarch64 ]]; then
make scotch ptscotch esmumps ptesmumps
declare -a extra_config
if check_option "debug" "n"; then
extra_config+=("-DCMAKE_BUILD_TYPE=Release")
else
# No MPI so no PT-Scotch
make scotch esmumps
fi

cd ../lib
${CC} -shared -o lib${_realname}.dll -Wl,--enable-auto-import -Wl,--export-all-symbols,-no-undefined \
-Wl,--out-implib,lib${_realname}.dll.a -Wl,--whole-archive lib${_realname}.a lib${_realname}err.a -Wl,--no-whole-archive \
-pthread

if [[ ${CARCH} != aarch64 ]]; then
mpicc -shared -o libpt${_realname}.dll -Wl,--enable-auto-import -Wl,--export-all-symbols,-no-undefined \
-Wl,--out-implib,libpt${_realname}.dll.a -Wl,--whole-archive libpt${_realname}.a libpt${_realname}err.a -Wl,--no-whole-archive \
-L. -l${_realname} -pthread
fi

cd "${srcdir}/${_realname}-v${pkgver}"
mv include include${_idx_suffix}
mv lib lib${_idx_suffix}
mv bin bin${_idx_suffix}
cd include${_idx_suffix}
mv metis.h scotchmetis.h
if [[ ${CARCH} != aarch64 ]]; then
mv parmetis.h ptscotchparmetis.h
extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
fi

MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
${MINGW_PREFIX}/bin/cmake \
-GNinja \
-DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
"${extra_config[@]}" \
${_idx_opt} \
-DINSTALL_METIS_HEADERS=ON \
-DBUILD_PTSCOTCH=ON \
-DBUILD_LIBESMUMPS=ON \
-DBUILD_LIBSCOTCHMETIS=OFF \
../${_realname}-v${pkgver}

${MINGW_PREFIX}/bin/cmake --build .

}

build()
{
msg2 "Build Scotch with 32-bit indexing"
_build_scotch "Makefile.idx32.inc" "32"

msg2 "Build Scotch with 64-bit indexing"
_build_scotch "Makefile.idx64.inc" "64"
}


_package_scotch() {
_idx_suffix=$1

cd "${srcdir}/${_realname}-v${pkgver}"
mkdir -p ${pkgdir}${MINGW_PREFIX}/{bin,lib,include}
mkdir -p "${pkgdir}${MINGW_PREFIX}/lib/pkgconfig"
echo "
prefix=${MINGW_PREFIX}
libdir=\${prefix}/lib
includedir=\${prefix}/include
Name: scotch
URL: ${url}
Version: ${pkgver}
Description: Serial graph partitioning and sparse matrix ordering package
Cflags: -I\${includedir}
Libs.private: -lscotcherr
Libs: -L\${libdir} -lscotch
" | sed '/^\s*$/d;s/^\s*//' > "${pkgdir}${MINGW_PREFIX}/lib/pkgconfig/scotch.pc"

if [[ ${CARCH} != aarch64 ]]; then
echo "
prefix=${MINGW_PREFIX}
libdir=\${prefix}/lib
includedir=\${prefix}/include
Name: ptscotch
URL: ${url}
Version: ${pkgver}
Description: Parallel graph partitioning and sparse matrix ordering package
Requires: scotch
Requires.private: msmpi
Cflags: -I\${includedir}
Libs.private: -lptscotcherr
Libs: -L\${libdir} -lptscotch
" | sed '/^\s*$/d;s/^\s*//' > "${pkgdir}${MINGW_PREFIX}/lib/pkgconfig/ptscotch.pc"
fi
(
cd include${_idx_suffix}
install -m644 *.h "${pkgdir}${MINGW_PREFIX}/include"
)
(
cd lib${_idx_suffix}
install -m644 lib*.a "${pkgdir}${MINGW_PREFIX}/lib"
install -m644 lib*.dll "${pkgdir}${MINGW_PREFIX}/bin"
)
build() {
mkdir -p "${srcdir}"/build-${MSYSTEM}-static-32 && cd "${srcdir}"/build-${MSYSTEM}-static-32

msg2 "Build static Scotch with 32-bit indexing"
_build_scotch "-DINTSIZE=32"

mkdir -p "${srcdir}"/build-${MSYSTEM}-shared-32 && cd "${srcdir}"/build-${MSYSTEM}-shared-32

msg2 "Build shared Scotch with 32-bit indexing"
_build_scotch "-DINTSIZE=32 -DCMAKE_C_STANDARD_LIBRARIES=-lscotcherr -DBUILD_SHARED_LIBS=ON"

mkdir -p "${srcdir}"/build-${MSYSTEM}-static-64 && cd "${srcdir}"/build-${MSYSTEM}-static-64

msg2 "Build static Scotch with 64-bit indexing"
_build_scotch "-DINTSIZE=64"

mkdir -p "${srcdir}"/build-${MSYSTEM}-shared-64 && cd "${srcdir}"/build-${MSYSTEM}-shared-64

msg2 "Build shared Scotch with 64-bit indexing"
_build_scotch "-DINTSIZE=64 -DCMAKE_C_STANDARD_LIBRARIES=-lscotcherr -DBUILD_SHARED_LIBS=ON"

}

package_scotch()
{
_package_scotch "32"
package_scotch() {
pkgdesc="Graph partitioning and sparse matrix ordering package (mingw-w64)"

# Static Install
cd "${srcdir}"/build-${MSYSTEM}-static-32
DESTDIR=${pkgdir} cmake --install .

# Shared Install
cd "${srcdir}"/build-${MSYSTEM}-shared-32
DESTDIR=${pkgdir} cmake --install .
install -Dm644 "${srcdir}"/${_realname}-v${pkgver}/doc/CeCILL-C_V1-en.txt "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

package_scotch-int64() {
package_scotch64() {
pkgdesc="Graph partitioning and sparse matrix ordering package with 64-bit indexing (mingw-w64)"
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
_package_scotch "64"
provides=()
conflicts=()

# Static Install
cd "${srcdir}"/build-${MSYSTEM}-static-64
DESTDIR=${pkgdir} cmake --install .

# Shared Install
cd "${srcdir}"/build-${MSYSTEM}-shared-64
DESTDIR=${pkgdir} cmake --install .
install -Dm644 "${srcdir}"/${_realname}-v${pkgver}/doc/CeCILL-C_V1-en.txt "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}


Expand Down

0 comments on commit c57392c

Please sign in to comment.