mirror of
https://develop.openfoam.com/Development/ThirdParty-common.git
synced 2025-12-08 06:57:50 +00:00
- simplifies creation of 64bit indexed libraries, for reuse (with widening) by various OpenFOAM label sizes - add -bin/-no-bin for metis (as per scotch)
227 lines
5.9 KiB
Bash
Executable File
227 lines
5.9 KiB
Bash
Executable File
#!/bin/sh
|
|
#------------------------------------------------------------------------------
|
|
# ========= |
|
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
# \\ / O peration |
|
|
# \\ / A nd | www.openfoam.com
|
|
# \\/ M anipulation |
|
|
#------------------------------------------------------------------------------
|
|
# Copyright (C) 2017-2021 OpenCFD Ltd.
|
|
#------------------------------------------------------------------------------
|
|
# License
|
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
|
#
|
|
# Script
|
|
# makeMETIS
|
|
#
|
|
# Description
|
|
# Build script for METIS
|
|
#
|
|
# ----------------------------------------------
|
|
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
|
|
#------------------------------------------------------------------------------
|
|
# Dynamic library ending (default is .so)
|
|
[ "$(uname -s)" = Darwin ] && EXT_SO=.dylib || EXT_SO=.so
|
|
|
|
# Short-circuit test for an installation
|
|
if [ "$1" = "-test" ]
|
|
then
|
|
[ "$#" -eq 2 ] || { echo "${0##*/} -test : needs 1 argument"; exit 1; }
|
|
dir="${2%/}" # <- *_ARCH_PATH
|
|
[ -d "$dir/include" ] || exit 2
|
|
|
|
package="metis"
|
|
libName="libmetis"
|
|
for lib in \
|
|
"$FOAM_EXT_LIBBIN/$libName$EXT_SO" \
|
|
"$dir/lib/$libName.a" \
|
|
"$dir/lib/$libName$EXT_SO" \
|
|
"$dir/lib$WM_COMPILER_LIB_ARCH/$libName.a" \
|
|
"$dir/lib$WM_COMPILER_LIB_ARCH/$libName$EXT_SO" \
|
|
;
|
|
do
|
|
if [ -r "$lib" ]
|
|
then
|
|
echo " $package include: $dir/include"
|
|
echo " $package library: ${lib%/*}"
|
|
exit 0
|
|
fi
|
|
done
|
|
exit 2
|
|
fi
|
|
#------------------------------------------------------------------------------
|
|
# Run from third-party directory only
|
|
cd "${0%/*}" || exit
|
|
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
|
|
echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
|
|
echo " Check your OpenFOAM environment and installation"
|
|
exit 1
|
|
}
|
|
. etc/tools/ThirdPartyFunctions
|
|
#------------------------------------------------------------------------------
|
|
_foamConfig metis
|
|
|
|
metisPACKAGE=${METIS_VERSION:-metis-system}
|
|
targetType=libso
|
|
|
|
#------------------------------------------------------------------------------
|
|
usage() {
|
|
exec 1>&2
|
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
|
cat<<USAGE
|
|
|
|
usage: ${0##*/} [OPTION] [lib|libso] [METIS-VERSION]
|
|
options:
|
|
-gcc Force use of gcc/g++
|
|
-int32 Use IDXTYPEWIDTH 32
|
|
-int64 Use IDXTYPEWIDTH 64
|
|
-bin Create metis binaries as well (default)
|
|
-no-bin Suppress creation of metis binaries
|
|
-help
|
|
|
|
* Build METIS (default: -int${WM_LABEL_SIZE:-32}) with
|
|
${metisPACKAGE:-'unspecified metis version'}
|
|
|
|
USAGE
|
|
showDownloadHint METIS
|
|
exit 1
|
|
}
|
|
#------------------------------------------------------------------------------
|
|
exportCompiler # Compiler info for CMake/configure
|
|
|
|
unset optForce
|
|
optBinaries=true
|
|
optIntSize="${WM_LABEL_SIZE:-32}"
|
|
|
|
# Parse options
|
|
while [ "$#" -gt 0 ]
|
|
do
|
|
case "$1" in
|
|
'') ;; # Ignore empty
|
|
-h | -help) usage ;;
|
|
-gcc) useGcc ;;
|
|
-force) echo "ignoring $1" ;;
|
|
-int32 | -int64) optIntSize="${1#-int}" ;;
|
|
-bin) optBinaries=true ;;
|
|
-no-bin) optBinaries=false ;;
|
|
|
|
lib|libso)
|
|
targetType="$1"
|
|
;;
|
|
|
|
metis-[0-9]*)
|
|
metisPACKAGE="${1%%/}"
|
|
unset METIS_ARCH_PATH # Avoid inconsistency
|
|
;;
|
|
*)
|
|
die "unknown option/argument: '$1'"
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
[ -n "$metisPACKAGE" ] || die "The metis-VERSION was not specified"
|
|
|
|
# Nothing to build
|
|
if _foamIsNone $metisPACKAGE
|
|
then
|
|
echo "Using metis-none (skip ThirdParty build of METIS)"
|
|
exit 0
|
|
elif _foamIsSystem $metisPACKAGE
|
|
then
|
|
echo "Using metis-system"
|
|
exit 0
|
|
fi
|
|
|
|
# Known build issues for mingw (various things)
|
|
case "$WM_COMPILER" in
|
|
(Mingw*)
|
|
if :
|
|
then
|
|
echo "Skipping metis - known compilation issues with $WM_COMPILER"
|
|
exit 0
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
requireExtLibBin
|
|
|
|
#------------------------------------------------------------------------------
|
|
#
|
|
# Build METIS
|
|
#
|
|
# METIS_ARCH_PATH : installation directory
|
|
# METIS_SOURCE_DIR : location of the original sources
|
|
|
|
METIS_SOURCE_DIR=$sourceBASE/$metisPACKAGE
|
|
: "${METIS_ARCH_PATH:=$installBASE$WM_SIZE_OPTIONS/$metisPACKAGE}"
|
|
|
|
[ -d "$METIS_SOURCE_DIR" ] || {
|
|
echo "Missing sources: '$metisPACKAGE'"
|
|
showDownloadHint METIS
|
|
exit 2
|
|
}
|
|
|
|
#
|
|
# Manual installation (of library)
|
|
#
|
|
install()
|
|
{
|
|
local bindir="$METIS_ARCH_PATH"/bin
|
|
local libdir="$METIS_ARCH_PATH"/lib
|
|
|
|
if [ "$optBinaries" = false ]
|
|
then
|
|
echo "Removing binaries: $bindir"
|
|
rm -rf "$bindir" 2>/dev/null # Failed removal is uncritical
|
|
fi
|
|
if [ "$targetType" = libso ]
|
|
then
|
|
mv "$libdir/libmetis$EXT_SO" "$FOAM_EXT_LIBBIN"
|
|
rmdir "$libdir" 2>/dev/null # Failed rmdir is uncritical
|
|
|
|
echo "Installing: $FOAM_EXT_LIBBIN/libmetis$EXT_SO"
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
echo "Starting build: $metisPACKAGE ($targetType)"
|
|
if [ "$optIntSize" != "$WM_LABEL_SIZE" ]
|
|
then
|
|
echo "Using int-$optIntSize instead of int-$WM_LABEL_SIZE"
|
|
fi
|
|
echo
|
|
(
|
|
# Configuration options:
|
|
unset configOpt
|
|
if [ "$targetType" = libso ]
|
|
then
|
|
configOpt="shared=1"
|
|
fi
|
|
|
|
cd "$METIS_SOURCE_DIR" || exit
|
|
export GIT_DIR="$PWD/.git" # Mask seeing our own git-repo
|
|
|
|
rm -rf "$METIS_ARCH_PATH"
|
|
rm -f "$FOAM_EXT_LIBBIN"/libmetis*
|
|
|
|
# Adjust metis IDXTYPEWIDTH (integer size)
|
|
sed -i -e 's=\(#define IDXTYPEWIDTH\).*=\1 '"$optIntSize"'=' \
|
|
include/metis.h
|
|
|
|
# No config option for the library location.
|
|
# - build normally and use mv to relocate it
|
|
|
|
make config $configOpt prefix="$METIS_ARCH_PATH" \
|
|
&& make -j $WM_NCOMPPROCS install \
|
|
&& echo "Built: metis" \
|
|
&& install
|
|
) || {
|
|
echo "Error building: metis"
|
|
exit 1
|
|
}
|
|
|
|
|
|
#------------------------------------------------------------------------------
|