mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve handling of ThirdParty packages
- generalize some of the library extensions (.so vs .dylib).
Provide as wmake 'sysFunctions'
- added note about unsupported/incomplete system support
- centralize detection of ThirdParty packages into wmake/ subdirectory
by providing a series of scripts in the spirit of GNU autoconfig.
For example,
have_boost, have_readline, have_scotch, ...
Each of the `have_<package>` scripts will generally provide the
following type of functions:
have_<package> # detection
no_<package> # reset
echo_<package> # echoing
and the following type of variables:
HAVE_<package> # unset or 'true'
<package>_ARCH_PATH # root for <package>
<package>_INC_DIR # include directory for <package>
<package>_LIB_DIR # library directory for <package>
This simplifies the calling scripts:
if have_metis
then
wmake metisDecomp
fi
As well as reducing clutter in the corresponding Make/options:
EXE_INC = \
-I$(METIS_INC_DIR) \
-I../decompositionMethods/lnInclude
LIB_LIBS = \
-L$(METIS_LIB_DIR) -lmetis
Any additional modifications (platform-specific or for an external build
system) can now be made centrally.
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Parse arguments for library compilation
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
decompose/Allwmake $targetType $*
|
||||
reconstruct/Allwmake $targetType $*
|
||||
wmake $targetType distributed
|
||||
|
||||
@ -1,221 +1,15 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Parse arguments for library compilation
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
. $WM_PROJECT_DIR/wmake/scripts/have_kahip
|
||||
. $WM_PROJECT_DIR/wmake/scripts/have_metis
|
||||
. $WM_PROJECT_DIR/wmake/scripts/have_scotch
|
||||
|
||||
: ${FOAM_EXT_LIBBIN:=/usr/lib$WM_COMPILER_LIB_ARCH} # Extra safety
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
: ${FOAM_EXT_LIBBIN:=/usr/lib$WM_COMPILER_LIB_ARCH} # Extra safety?
|
||||
export FOAM_EXT_LIBBIN
|
||||
|
||||
# Check for the existence of any of the files
|
||||
# On success, echoes the file found and returns 0, otherwise returns 2
|
||||
findFirstFile()
|
||||
{
|
||||
local file
|
||||
for file
|
||||
do
|
||||
if [ -f "$file" -a -r "$file" ]
|
||||
then
|
||||
echo "$file"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 2
|
||||
}
|
||||
|
||||
|
||||
# Test for kahip.
|
||||
# - return 0 and export KAHIP_ARCH_PATH on success
|
||||
hasKahip()
|
||||
{
|
||||
local warning="==> skip kahip"
|
||||
local header label settings
|
||||
|
||||
unset KAHIP_ARCH_PATH KAHIP_VERSION
|
||||
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/kahip) || {
|
||||
echo "$warning (no config.sh/kahip settings)"
|
||||
return 1
|
||||
}
|
||||
|
||||
. $settings
|
||||
if [ -z "$KAHIP_ARCH_PATH" -o "${KAHIP_ARCH_PATH##*-}" = none ]
|
||||
then
|
||||
echo "$warning (not available)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Header
|
||||
header=$(findFirstFile \
|
||||
$KAHIP_ARCH_PATH/include/kaHIP_interface.h \
|
||||
/usr/include/kaHIP_interface.h \
|
||||
) || {
|
||||
echo "$warning (no header)"
|
||||
return 2 # file not found
|
||||
}
|
||||
|
||||
# Library
|
||||
[ "${KAHIP_ARCH_PATH##*-}" = system ] || \
|
||||
findFirstFile \
|
||||
$FOAM_EXT_LIBBIN/libkahip.so \
|
||||
$KAHIP_ARCH_PATH/lib/libkahip.a \
|
||||
$KAHIP_ARCH_PATH/lib/libkahip.so \
|
||||
$KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libkahip.a \
|
||||
$KAHIP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libkahip.so \
|
||||
> /dev/null || {
|
||||
echo "$warning (missing library)"
|
||||
return 2
|
||||
}
|
||||
|
||||
# kahip itself is 32-bit int, but our interface itself handles some
|
||||
# 64-bit conversion (mesh size).
|
||||
|
||||
export KAHIP_ARCH_PATH
|
||||
echo "kahip (label=32) - $KAHIP_ARCH_PATH"
|
||||
}
|
||||
|
||||
|
||||
# Test for metis.
|
||||
# - return 0 and export METIS_ARCH_PATH on success
|
||||
hasMetis()
|
||||
{
|
||||
local warning="==> skip metis"
|
||||
local header label settings
|
||||
|
||||
unset METIS_ARCH_PATH METIS_VERSION
|
||||
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis) || {
|
||||
echo "$warning (no config.sh/metis settings)"
|
||||
return 1
|
||||
}
|
||||
|
||||
. $settings
|
||||
if [ -z "$METIS_ARCH_PATH" -o "${METIS_ARCH_PATH##*-}" = none ]
|
||||
then
|
||||
echo "$warning (not available)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Header
|
||||
header=$(findFirstFile \
|
||||
$METIS_ARCH_PATH/include/metis.h \
|
||||
/usr/include/metis.h \
|
||||
) || {
|
||||
echo "$warning (no header)"
|
||||
return 2 # file not found
|
||||
}
|
||||
|
||||
# Library
|
||||
[ "${METIS_ARCH_PATH##*-}" = system ] || \
|
||||
findFirstFile \
|
||||
$FOAM_EXT_LIBBIN/libmetis.so \
|
||||
$METIS_ARCH_PATH/lib/libmetis.a \
|
||||
$METIS_ARCH_PATH/lib/libmetis.so \
|
||||
$METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmetis.a \
|
||||
$METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmetis.so \
|
||||
> /dev/null || {
|
||||
echo "$warning (missing library)"
|
||||
return 2
|
||||
}
|
||||
|
||||
# Ensure consistent sizes between OpenFOAM and metis header
|
||||
# Extract IDXTYPEWIDTH from metis.h: regex as per ThirdParty Allwmake
|
||||
label=$(sed -ne 's/^.*#define *IDXTYPEWIDTH *\([1-9][0-9]\).*/\1/p' $header)
|
||||
: ${label:=unknown}
|
||||
|
||||
if [ "$WM_LABEL_SIZE" = "$label" ]
|
||||
then
|
||||
echo "Metis (label=$label) - $METIS_ARCH_PATH"
|
||||
export METIS_ARCH_PATH
|
||||
else
|
||||
echo "$warning (label=$WM_LABEL_SIZE, metis.h has '$label')"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Test for scotch.
|
||||
# - return 0 and export SCOTCH_ARCH_PATH, SCOTCH_VERSION on success
|
||||
hasScotch()
|
||||
{
|
||||
local warning="==> skip scotch"
|
||||
local header label settings
|
||||
|
||||
unset SCOTCH_ARCH_PATH SCOTCH_VERSION
|
||||
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch) || {
|
||||
echo "$warning (no config.sh/scotch settings)"
|
||||
return 1
|
||||
}
|
||||
|
||||
. $settings
|
||||
if [ -z "$SCOTCH_ARCH_PATH" -o "${SCOTCH_ARCH_PATH##*-}" = none ]
|
||||
then
|
||||
echo "$warning (not available)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Header
|
||||
header=$(findFirstFile \
|
||||
$SCOTCH_ARCH_PATH/include/scotch.h \
|
||||
/usr/include/scotch/scotch.h \
|
||||
/usr/include/scotch.h
|
||||
) || {
|
||||
echo "$warning (no header)"
|
||||
return 2 # file not found
|
||||
}
|
||||
|
||||
# Library
|
||||
[ "${SCOTCH_ARCH_PATH##*-}" = system ] || \
|
||||
findFirstFile \
|
||||
$FOAM_EXT_LIBBIN/libscotch.so \
|
||||
$SCOTCH_ARCH_PATH/lib/libscotch.a \
|
||||
$SCOTCH_ARCH_PATH/lib/libscotch.so \
|
||||
$SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libscotch.a \
|
||||
$SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libscotch.so \
|
||||
> /dev/null || {
|
||||
echo "$warning (missing library)"
|
||||
return 2
|
||||
}
|
||||
|
||||
# Ensure consistent sizes between OpenFOAM and scotch header
|
||||
# extract 'typedef int64_t SCOTCH_Num' or equivalent
|
||||
label=$(sed -ne \
|
||||
's/^.*typedef *\([^ ]*\) *SCOTCH_Num.*/\1/ip' \
|
||||
"$header")
|
||||
|
||||
: ${label:=unknown}
|
||||
|
||||
# No SCOTCH_VERSION set? Try to obtain from header
|
||||
# extract #define SCOTCH_VERSION, SCOTCH_RELEASE, SCOTCH_PATCHLEVEL
|
||||
[ -n "$SCOTCH_VERSION" ] || \
|
||||
SCOTCH_VERSION=$(
|
||||
eval $(
|
||||
sed -ne \
|
||||
's/^ *#define *SCOTCH_\(VERSION\|RELEASE\|PATCHLEVEL\) *\([0-9][0-9]*\).*$/\1=\2/p' \
|
||||
"$header"
|
||||
)
|
||||
|
||||
set -- $VERSION $RELEASE $PATCHLEVEL
|
||||
IFS="."
|
||||
[ "$#" -gt 0 ] && echo "scotch-$*"
|
||||
)
|
||||
|
||||
# Failsafe value
|
||||
: ${SCOTCH_VERSION:=scotch}
|
||||
|
||||
case "$WM_LABEL_SIZE:$label" in
|
||||
(32:int32_t | 32:int | 64:int64_t | 64:long)
|
||||
echo "Scotch (label=$label) - $SCOTCH_ARCH_PATH"
|
||||
export SCOTCH_ARCH_PATH SCOTCH_VERSION
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "$warning (label='$WM_LABEL_SIZE', scotch.h has '$label')"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Define how to create an mpi-versioned library of $targetType
|
||||
# compile into qualified directory
|
||||
@ -244,7 +38,7 @@ wmakeMpiLib()
|
||||
|
||||
wmakeLnInclude -u decompositionMethods
|
||||
|
||||
if hasScotch
|
||||
if have_scotch
|
||||
then
|
||||
wmake $targetType scotchDecomp
|
||||
if [ -d "$FOAM_LIBBIN/$FOAM_MPI" ]
|
||||
@ -253,12 +47,12 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
if hasMetis
|
||||
if have_metis
|
||||
then
|
||||
wmake $targetType metisDecomp
|
||||
fi
|
||||
|
||||
if hasKahip
|
||||
if have_kahip
|
||||
then
|
||||
wmake $targetType kahipDecomp
|
||||
fi
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
EXE_INC = \
|
||||
-I$(KAHIP_ARCH_PATH)/include \
|
||||
-I$(KAHIP_INC_DIR) \
|
||||
-I../decompositionMethods/lnInclude
|
||||
|
||||
/*
|
||||
* The $(KAHIP_ARCH_PATH)/lib$WM_COMPILER_LIB_ARCH path is provided
|
||||
* to support central, non-thirdparty installations.
|
||||
*
|
||||
* KaHIP is often compiled with openmp, but may be missing the
|
||||
* link dependency for openmp.
|
||||
* KaHIP is usually compiled with openmp, but may be missing the
|
||||
* openmp link dependency.
|
||||
*/
|
||||
LIB_LIBS = \
|
||||
-L$(KAHIP_ARCH_PATH)/lib \
|
||||
-L$(KAHIP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
|
||||
-L$(FOAM_EXT_LIBBIN) $(LINK_OPENMP) -lkahip
|
||||
-L$(KAHIP_LIB_DIR) $(LINK_OPENMP) -lkahip
|
||||
|
||||
@ -1,14 +1,6 @@
|
||||
EXE_INC = \
|
||||
/* -DFULLDEBUG -g -O0 */ \
|
||||
-I$(METIS_ARCH_PATH)/include \
|
||||
-I$(METIS_INC_DIR) \
|
||||
-I../decompositionMethods/lnInclude
|
||||
|
||||
/*
|
||||
* The $(METIS_ARCH_PATH)/lib$WM_COMPILER_LIB_ARCH path is provided
|
||||
* to support central, non-thirdparty installations
|
||||
*/
|
||||
LIB_LIBS = \
|
||||
-L$(METIS_ARCH_PATH)/lib \
|
||||
-L$(METIS_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
|
||||
-L$(FOAM_EXT_LIBBIN) \
|
||||
-lmetis
|
||||
-L$(METIS_LIB_DIR) -lmetis
|
||||
|
||||
@ -3,21 +3,16 @@ sinclude $(RULES)/mplib$(WM_MPLIB)
|
||||
|
||||
EXE_INC = \
|
||||
$(PFLAGS) $(PINC) \
|
||||
-I../decompositionMethods/lnInclude \
|
||||
-I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
|
||||
-I$(SCOTCH_ARCH_PATH)/include \
|
||||
-I/usr/include/scotch \
|
||||
-I../decompositionMethods/lnInclude
|
||||
-I$(SCOTCH_INC_DIR)
|
||||
|
||||
/*
|
||||
* The '-lscotch' is a slight hack:
|
||||
* ptscotch 6 requires scotch linked in, but does not declare the dependency
|
||||
*
|
||||
* The $(SCOTCH_ARCH_PATH)/lib$WM_COMPILER_LIB_ARCH path is provided
|
||||
* to support central, non-thirdparty installations
|
||||
*/
|
||||
LIB_LIBS = \
|
||||
-L$(SCOTCH_ARCH_PATH)/lib \
|
||||
-L$(SCOTCH_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
|
||||
-L$(SCOTCH_LIB_DIR) \
|
||||
-L$(FOAM_EXT_LIBBIN) \
|
||||
-L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) \
|
||||
-lptscotch \
|
||||
|
||||
@ -7,18 +7,8 @@ sinclude $(RULES)/mplib$(WM_MPLIB)
|
||||
|
||||
EXE_INC = \
|
||||
$(PFLAGS) $(PINC) \
|
||||
-I$(SCOTCH_ARCH_PATH)/include \
|
||||
-I/usr/include/scotch \
|
||||
-I$(SCOTCH_INC_DIR) \
|
||||
-I../decompositionMethods/lnInclude
|
||||
|
||||
/*
|
||||
* The $(SCOTCH_ARCH_PATH)/lib$WM_COMPILER_LIB_ARCH path is provided
|
||||
* to support central, non-thirdparty installations
|
||||
*/
|
||||
LIB_LIBS = \
|
||||
-L$(SCOTCH_ARCH_PATH)/lib \
|
||||
-L$(SCOTCH_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
|
||||
-L$(FOAM_EXT_LIBBIN) \
|
||||
-lscotch \
|
||||
-lscotcherrexit \
|
||||
-lrt
|
||||
-L$(SCOTCH_LIB_DIR) -lscotch -lscotcherrexit -lrt
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
# Parse arguments for library compilation
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
wmake $targetType reconstruct
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user