From 897528da1a61083764a6b85b46c28402d390e3d7 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 29 Apr 2019 10:04:44 +0200 Subject: [PATCH] ENH: streamline handling of static/dynamic libs in detection scripts --- .../utilities/mesh/conversion/ccm/Allwmake | 4 +- .../mesh/manipulation/renumberMesh/Allwmake | 15 +- wmake/scripts/have_adios2 | 42 +++--- wmake/scripts/have_boost | 41 +++--- wmake/scripts/have_ccmio | 35 +++-- wmake/scripts/have_cgal | 42 +++--- wmake/scripts/have_fftw | 45 +++--- wmake/scripts/have_hypre | 41 +++--- wmake/scripts/have_kahip | 44 +++--- wmake/scripts/have_metis | 44 +++--- wmake/scripts/have_mgridgen | 48 +++---- wmake/scripts/have_petsc | 42 +++--- wmake/scripts/have_readline | 41 +++--- wmake/scripts/have_scotch | 112 ++++++--------- wmake/scripts/have_zoltan | 45 +++--- wmake/scripts/paraviewFunctions | 7 +- wmake/scripts/sysFunctions | 129 ++++++++++++------ 17 files changed, 341 insertions(+), 436 deletions(-) diff --git a/applications/utilities/mesh/conversion/ccm/Allwmake b/applications/utilities/mesh/conversion/ccm/Allwmake index 6306b021684..1fc0eea707d 100755 --- a/applications/utilities/mesh/conversion/ccm/Allwmake +++ b/applications/utilities/mesh/conversion/ccm/Allwmake @@ -6,13 +6,13 @@ cd ${0%/*} || exit 1 # Run from this directory #------------------------------------------------------------------------------ # Only build when the OpenFOAM libccm adaptor already exists -if [ -f $FOAM_LIBBIN/libccm$extLibso ] +if findLibrary "$FOAM_LIBBIN/libccm" > /dev/null then echo "==> build optional ccm conversion components" wmake $targetType ccmToFoam wmake $targetType foamToCcm else - echo "==> skip optional ccm conversion components (no libccm$extLibso)" + echo "==> skip optional ccm conversion components (no libccm)" fi #------------------------------------------------------------------------------ diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake b/applications/utilities/mesh/manipulation/renumberMesh/Allwmake index 4f75bd542c9..f89bab6e20b 100755 --- a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake +++ b/applications/utilities/mesh/manipulation/renumberMesh/Allwmake @@ -8,20 +8,17 @@ cd ${0%/*} || exit 1 # Run from this directory unset COMP_FLAGS LINK_FLAGS -if [ -f $FOAM_LIBBIN/libSloanRenumber$extLibso ] +if findLibrary "$FOAM_LIBBIN/libSloanRenumber" > /dev/null then - echo " found libSloanRenumber -- enabling sloan renumbering support." + echo " found libSloanRenumber -- enabling sloan renumbering support." export LINK_FLAGS="$LINK_FLAGS -lSloanRenumber" fi -if [ -f $FOAM_LIBBIN/libzoltanRenumber$extLibso ] +if findLibrary "$FOAM_LIBBIN/libzoltanRenumber" > /dev/null && have_zoltan then - if have_zoltan - then - echo " found libzoltanRenumber -- enabling zoltan renumbering support." - export COMP_FLAGS="$COMP_FLAGS -DHAVE_ZOLTAN" - export LINK_FLAGS="$LINK_FLAGS -lzoltanRenumber -L$ZOLTAN_LIB_DIR -lzoltan" - fi + echo " found libzoltanRenumber -- enabling zoltan renumbering support." + export COMP_FLAGS="$COMP_FLAGS -DHAVE_ZOLTAN" + export LINK_FLAGS="$LINK_FLAGS -lzoltanRenumber -L$ZOLTAN_LIB_DIR -lzoltan" fi wmake $targetType diff --git a/wmake/scripts/have_adios2 b/wmake/scripts/have_adios2 index 19b376258dc..55eb00f510d 100644 --- a/wmake/scripts/have_adios2 +++ b/wmake/scripts/have_adios2 @@ -54,7 +54,7 @@ echo_adios2() # -> HAVE_ADIOS2, ADIOS2_INC_DIR, ADIOS2_LIB_DIR have_adios2() { - local prefix header library static settings warn + local prefix header library incName libName settings warn # warn="==> skip adios2" # Setup @@ -66,12 +66,10 @@ have_adios2() return 2 fi - # Location + # Expected location, include/library names prefix="$ADIOS2_ARCH_PATH" - - # Header/library names - header="adios2.h" - library="libadios2$extLibso" + incName="adios2.h" + libName="libadios2" # ---------------------------------- if isNone "$prefix" @@ -80,40 +78,34 @@ have_adios2() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- + # OK export HAVE_ADIOS2=true export ADIOS2_ARCH_PATH="$prefix" diff --git a/wmake/scripts/have_boost b/wmake/scripts/have_boost index ba12fee2c4e..a618de0b16a 100644 --- a/wmake/scripts/have_boost +++ b/wmake/scripts/have_boost @@ -54,17 +54,15 @@ echo_boost() # -> HAVE_BOOST, BOOST_INC_DIR, BOOST_LIB_DIR have_boost() { - local prefix header library static settings warn + local prefix header library incName libName settings warn # warn="==> skip boost" # Setup - from the current environment - # Location + # Expected location, include/library names prefix="$BOOST_ARCH_PATH" - - # Header/library names - header="boost/version.hpp" - library="libboost_system$extLibso" + incName="boost/version.hpp" + libName="libboost_system" # ---------------------------------- if isNone "$prefix" @@ -73,40 +71,33 @@ have_boost() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- header="${header%/*}" # Strip one-level (include/boost/...) diff --git a/wmake/scripts/have_ccmio b/wmake/scripts/have_ccmio index ae2d13cb695..70ed1137eea 100644 --- a/wmake/scripts/have_ccmio +++ b/wmake/scripts/have_ccmio @@ -53,10 +53,10 @@ echo_ccmio() # -> HAVE_CCMIO, CCMIO_INC_DIR, CCMIO_LIB_DIR have_ccmio() { - local prefix header library static settings warn + local prefix header library incName libName settings warn warn="==> skip ccmio" - # Setup + # Setup if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio) then . "$settings" @@ -65,13 +65,11 @@ have_ccmio() return 2 fi - # Location - prefix="$CCMIO_ARCH_PATH" - - # Header/library names. + # Expected location, include/library names # Link with static libccmio only (fewer issues) - header="libccmio/ccmio.h" - static="libccmio$extLiba" + prefix="$CCMIO_ARCH_PATH" + incName="libccmio/ccmio.h" + libName="libccmio.a" # ---------------------------------- if isNone "$prefix" @@ -80,30 +78,29 @@ have_ccmio() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$static" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- # The libccmio uses int32_t. # The OpenFOAM adapter thus requires additional work for 64-bit labels. diff --git a/wmake/scripts/have_cgal b/wmake/scripts/have_cgal index 82339475885..2a98073a554 100644 --- a/wmake/scripts/have_cgal +++ b/wmake/scripts/have_cgal @@ -54,17 +54,15 @@ echo_cgal() # -> HAVE_CGAL, CGAL_INC_DIR, CGAL_LIB_DIR have_cgal() { - local prefix header library static settings warn + local prefix header library incName libName settings warn # warn="==> skip cgal" # Setup - from the current environment - # Location + # Expected location, include/library names prefix="$CGAL_ARCH_PATH" - - # Header/library names - header="CGAL/version.h" - library="libCGAL$extLibso" + incName="CGAL/version.h" + libName="libCGAL" # ---------------------------------- if isNone "$prefix" @@ -73,40 +71,34 @@ have_cgal() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- + header="${header%/*}" # Strip one-level (include/CGAL/...) # OK diff --git a/wmake/scripts/have_fftw b/wmake/scripts/have_fftw index 218175e3477..dde3fb12d1c 100644 --- a/wmake/scripts/have_fftw +++ b/wmake/scripts/have_fftw @@ -54,18 +54,15 @@ echo_fftw() # -> HAVE_FFTW, FFTW_INC_DIR, FFTW_LIB_DIR have_fftw() { - local prefix header library static settings warn + local prefix header library incName libName settings warn # warn="==> skip fftw" # Setup - from the current environment - # Location + # Expected location, include/library names prefix="$FFTW_ARCH_PATH" - - # Header/library names - header="fftw3.h" - library="libfftw3$extLibso" - static="libfftw3$extLiba" + incName="fftw3.h" + libName="libfftw3" # ---------------------------------- if isNone "$prefix" @@ -74,42 +71,34 @@ have_fftw() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$static" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- + # OK export HAVE_FFTW=true export FFTW_ARCH_PATH="$prefix" diff --git a/wmake/scripts/have_hypre b/wmake/scripts/have_hypre index 98c69716280..8169bab7b3b 100644 --- a/wmake/scripts/have_hypre +++ b/wmake/scripts/have_hypre @@ -54,7 +54,7 @@ echo_hypre() # -> HAVE_HYPRE, HYPRE_INC_DIR, HYPRE_LIB_DIR have_hypre() { - local prefix header library static settings warn + local prefix header library incName libName settings warn warn="==> skip hypre" # Setup - prefer current environment value? (TDB) @@ -69,12 +69,10 @@ have_hypre() fi fi - # Location + # Expected location, include/library names prefix="$HYPRE_ARCH_PATH" - - # Header/library names - header="HYPRE.h" - library="libHYPRE$extLibso" + incName="HYPRE.h" + libName="libHYPRE" # ---------------------------------- if isNone "$prefix" @@ -83,40 +81,33 @@ have_hypre() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- # OK export HAVE_HYPRE=true diff --git a/wmake/scripts/have_kahip b/wmake/scripts/have_kahip index f87ab85f19f..a53ad7e5d00 100644 --- a/wmake/scripts/have_kahip +++ b/wmake/scripts/have_kahip @@ -55,7 +55,7 @@ echo_kahip() # -> HAVE_KAHIP, KAHIP_ARCH_PATH, KAHIP_INC_DIR, KAHIP_LIB_DIR have_kahip() { - local prefix header library static settings warn + local prefix header library incName libName settings warn warn="==> skip kahip" # Setup @@ -67,13 +67,10 @@ have_kahip() return 1 fi - # Location + # Expected location, include/library names prefix="$KAHIP_ARCH_PATH" - - # Header/library names - header="kaHIP_interface.h" - library="libkahip$extLibso" - static="libkahip$extLiba" + incName="kaHIP_interface.h" + libName="libkahip" # ---------------------------------- if isNone "$prefix" @@ -82,42 +79,33 @@ have_kahip() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$static" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- # kahip itself is 32-bit int, but our interface itself handles some # 64-bit conversion (mesh size). diff --git a/wmake/scripts/have_metis b/wmake/scripts/have_metis index 1204fe3cb15..a72c1ecdf50 100644 --- a/wmake/scripts/have_metis +++ b/wmake/scripts/have_metis @@ -55,7 +55,7 @@ echo_metis() # -> HAVE_METIS, METIS_ARCH_PATH, METIS_INC_DIR, METIS_LIB_DIR have_metis() { - local prefix header library static settings warn + local prefix header library incName libName settings warn warn="==> skip metis" # Setup @@ -67,13 +67,10 @@ have_metis() return 2 fi - # Location + # Expected location, include/library names prefix="$METIS_ARCH_PATH" - - # Header/library names - header="metis.h" - library="libmetis$extLibso" - static="libmetis$extLiba" + incName="metis.h" + libName="libmetis" # ---------------------------------- if isNone "$prefix" @@ -82,42 +79,33 @@ have_metis() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$static" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- local good label diff --git a/wmake/scripts/have_mgridgen b/wmake/scripts/have_mgridgen index faf15036c17..8123e24a824 100644 --- a/wmake/scripts/have_mgridgen +++ b/wmake/scripts/have_mgridgen @@ -55,7 +55,7 @@ echo_mgridgen() # -> HAVE_MGRIDGEN, MGRIDGEN_ARCH_PATH, MGRIDGEN_INC_DIR, MGRIDGEN_LIB_DIR have_mgridgen() { - local prefix header library static settings warn + local prefix header library incName libName libName2 settings warn warn="==> skip mgridgen" # Setup @@ -67,13 +67,11 @@ have_mgridgen() return 2 fi - # Location + # Expected location, include/library names prefix="$MGRIDGEN_ARCH_PATH" - - # Header/library names - header="mgridgen.h" - library="libMGridGen$extLibso" - static="libmgrid$extLiba" + incName="mgridgen.h" + libName="libMGridGen" + libName2="libmgrid" # ---------------------------------- if isNone "$prefix" @@ -82,42 +80,36 @@ have_mgridgen() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$static" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName $libName2)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { #silent# [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib/$libName2" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName2" \ + ) || { #silent# [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- + local good label scalar # Ensure consistent sizes with OpenFOAM and mgridgen header diff --git a/wmake/scripts/have_petsc b/wmake/scripts/have_petsc index 301bb7cb01c..ead138b78e9 100644 --- a/wmake/scripts/have_petsc +++ b/wmake/scripts/have_petsc @@ -54,7 +54,7 @@ echo_petsc() # -> HAVE_PETSC, PETSC_INC_DIR, PETSC_LIB_DIR have_petsc() { - local prefix header library static settings warn + local prefix header library incName libName settings warn warn="==> skip petsc" # Setup - prefer current environment value? (TDB) @@ -69,12 +69,10 @@ have_petsc() fi fi - # Location + # Expected location, include/library names prefix="$PETSC_ARCH_PATH" - - # Header/library names - header="petsc.h" - library="libpetsc$extLibso" + incName="petsc.h" + libName="libpetsc" # ---------------------------------- if isNone "$prefix" @@ -83,40 +81,34 @@ have_petsc() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- + # TODO: check size of petsc integer vs label # OK diff --git a/wmake/scripts/have_readline b/wmake/scripts/have_readline index dc0b557db29..ff6e93de15d 100644 --- a/wmake/scripts/have_readline +++ b/wmake/scripts/have_readline @@ -52,15 +52,13 @@ echo_readline() # -> HAVE_LIBREADLINE, READLINE_INC_DIR, READLINE_LIB_DIR have_readline() { - local prefix header library static settings warn + local prefix header library incName libName settings warn # warn="==> skip readline" - # Location + # Expected location, include/library names prefix=system - - # Header/library names - header="readline/readline.h" - library="libreadline$extLibso" + incName="readline/readline.h" + libName="libreadline" # ---------------------------------- if isNone "$prefix" @@ -69,39 +67,34 @@ have_readline() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- + header="${header%/*}" # Strip one-level (include/readline/...) # OK diff --git a/wmake/scripts/have_scotch b/wmake/scripts/have_scotch index 8d17fa7f17f..42c68979485 100644 --- a/wmake/scripts/have_scotch +++ b/wmake/scripts/have_scotch @@ -61,7 +61,7 @@ echo_scotch() # -> HAVE_SCOTCH, SCOTCH_ARCH_PATH, SCOTCH_INC_DIR, SCOTCH_LIB_DIR have_scotch() { - local prefix header library static settings warn + local prefix header library incName libName settings warn warn="==> skip scotch" # Setup @@ -73,13 +73,10 @@ have_scotch() return 2 fi - # Location + # Expected location, include/library names prefix="$SCOTCH_ARCH_PATH" - - # Header/library names - header="scotch.h" - library="libscotch$extLibso" - static="libscotch$extLiba" + incName="scotch.h" + libName="libscotch" # ---------------------------------- if isNone "$prefix" @@ -88,50 +85,39 @@ have_scotch() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$static" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) - + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile \ - "/usr/local/include/scotch/$header" \ - "/usr/local/include/$header" \ - "/usr/include/scotch/$header" \ - "/usr/include/$header" \ - ) - - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ + "/usr/local/include/scotch/$incName" \ + "/usr/local/include/$incName" \ + "/usr/include/scotch/$incName" \ + "/usr/include/$incName" \ ) + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- + local good label # Ensure consistent sizes between OpenFOAM and scotch header @@ -189,7 +175,7 @@ have_scotch() # -> HAVE_PTSCOTCH, PTSCOTCH_ARCH_PATH, PTSCOTCH_INC_DIR, PTSCOTCH_LIB_DIR have_ptscotch() { - local prefix header library static settings warn + local prefix header library incName libName settings warn warn="==> skip ptscotch" if [ "$HAVE_SCOTCH" != true ] @@ -201,13 +187,10 @@ have_ptscotch() # Reuse old settings [ -n "$PTSCOTCH_ARCH_PATH" ] || PTSCOTCH_ARCH_PATH="$SCOTCH_ARCH_PATH" - # Location + # Expected location, include/library names prefix="$PTSCOTCH_ARCH_PATH" - - # Header/library names - header="ptscotch.h" - library="libptscotch$extLibso" - static="libptscotch$extLiba" + incName="ptscotch.h" + libName="libptscotch" # ---------------------------------- if isNone "$prefix" @@ -217,55 +200,44 @@ have_ptscotch() elif hasAbsdir "$prefix" then header=$(findFirstFile \ - "$prefix/include/$FOAM_MPI/$header" \ - "$prefix/include/$header" - ) - - library=$(findFirstFile \ - "$(thirdExtLib $FOAM_MPI/$library)" \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$static" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ + "$prefix/include/$FOAM_MPI/$incName" \ + "$prefix/include/$incName" ) - + library="$(findExtLib $FOAM_MPI/$libName $libName)" elif isSystem "$prefix" then prefix=/usr - header=$(findFirstFile \ - "/usr/local/include/ptscotch/$header" \ - "/usr/local/include/scotch/$header" \ - "/usr/local/include/$header" \ - "/usr/include/ptscotch/$header" \ - "/usr/include/scotch/$header" \ - "/usr/include/$header" \ + "/usr/local/include/ptscotch/$incName" \ + "/usr/local/include/scotch/$incName" \ + "/usr/local/include/$incName" \ + "/usr/include/ptscotch/$incName" \ + "/usr/include/scotch/$incName" \ + "/usr/include/$incName" \ ) - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- + # OK echo "ptscotch - $prefix" export HAVE_PTSCOTCH=true diff --git a/wmake/scripts/have_zoltan b/wmake/scripts/have_zoltan index 12efc04c906..8d0adba143a 100644 --- a/wmake/scripts/have_zoltan +++ b/wmake/scripts/have_zoltan @@ -54,7 +54,7 @@ echo_zoltan() # -> HAVE_ZOLTAN, ZOLTAN_INC_DIR, ZOLTAN_LIB_DIR have_zoltan() { - local prefix header library static settings warn + local prefix header library incName libName settings warn # warn="==> skip zoltan" # Setup @@ -66,13 +66,10 @@ have_zoltan() return 2 fi - # Location + # Expected location, include/library names prefix="$ZOLTAN_ARCH_PATH" - - # Header/library names - header="zoltan.h" - library="libzoltan$extLibso" - static="libzoltan$extLiba" + incName="zoltan.h" + libName="libzoltan" # ---------------------------------- if isNone "$prefix" @@ -81,42 +78,34 @@ have_zoltan() return 1 elif hasAbsdir "$prefix" then - header=$(findFirstFile "$prefix/include/$header") - - library=$(findFirstFile \ - "$(thirdExtLib $library)" \ - "$prefix/lib/$static" \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "$prefix/include/$incName") + library="$(findExtLib $libName)" elif isSystem "$prefix" then - prefix=/usr - header=$(findFirstFile "/usr/local/include/$header" "/usr/include/$header") - case "$header" in (/usr/local/*) prefix=/usr/local ;; esac - - library=$(findFirstFile \ - "$prefix/lib/$library" \ - "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ - ) + header=$(findFirstFile "/usr/local/include/$incName" "/usr/include/$incName") + prefix=$(sysPrefix "$header") else - unset prefix header library + unset prefix fi # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } - # Library found? - [ -n "$library" ] || { + # Library + [ -n "$library" ] || library=$(findLibrary \ + "$prefix/lib/$libName" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$libName" \ + ) || { [ -n "$warn" ] && echo "$warn (no library)" return 2 } + # ---------------------------------- + # OK export HAVE_ZOLTAN=true export ZOLTAN_ARCH_PATH="$prefix" diff --git a/wmake/scripts/paraviewFunctions b/wmake/scripts/paraviewFunctions index d098e0626c6..b528f22cf71 100644 --- a/wmake/scripts/paraviewFunctions +++ b/wmake/scripts/paraviewFunctions @@ -135,7 +135,7 @@ have_pvplugin_support() return 1 } - # Header/library names + # Include/library names header="pqServerManagerModel.h" if [ -n "$ParaView_DIR" ] @@ -173,13 +173,16 @@ have_pvplugin_support() ) fi + # ---------------------------------- - # Header found? + # Header [ -n "$header" ] || { [ -n "$warn" ] && echo "$warn (no header)" return 2 } + # ---------------------------------- + # OK export HAVE_PVPLUGIN_SUPPORT=true export FOAM_PV_PLUGIN_LIBBIN="$targetDir" diff --git a/wmake/scripts/sysFunctions b/wmake/scripts/sysFunctions index 3771a90d5df..08fc56e1959 100644 --- a/wmake/scripts/sysFunctions +++ b/wmake/scripts/sysFunctions @@ -16,16 +16,14 @@ # General system helper functions # # Functions provided -# isDarwin -# isNone -# isSystem -# isAbsdir, hasAbsdir +# isNone, isSystem, isAbsdir, hasAbsdir +# isDarwin, isWindows # findFirstFile -# thirdExtLib +# findLibrary +# findExtLib # -# Variables provided -# extLiba -# extLibso +# Internal variables used +# extLibraries # #------------------------------------------------------------------------------ @@ -34,37 +32,30 @@ then # Load once, but do not rely on this variable elsewhere WMAKE_SCRIPTS_SYSFUNCTIONS=loaded - # Static library extension (default=".a") - extLiba=".a" - - # Shared library extension (default=".so") - extLibso=".so" - - # Adjustments - case "$(uname -s 2>/dev/null)" in - Darwin) - extLibso=".dylib" - ;; - *) - ## Other. Eg, extLibso=".dll" or extLibso=".dll.a" - ;; - esac - - - # True if target OS is Darwin. - # Uses cached value from libso extension + # True if OS is Darwin. isDarwin() { - test "$extLibso" = ".dylib" + test Darwin = "$(uname -s 2>/dev/null)" } # True if target OS is Windows # Uses cached value from libso extension isWindows() { - test "$extLibso" = ".dll" || "$extLibso" = ".dll.a" + test MSwindows = "$WM_OSTYPE" } + # Static, dynamic library extensions + extLibraries=".a .so" + + if isDarwin + then + extLibraries=".a .dylib" + elif isWindows + then + extLibraries=".a .dll .dll.a" # including cross-compiling + fi + # True if '$1' begins with '/' isAbsdir() @@ -98,41 +89,89 @@ then } - # Check for the existence of any of the files + # Return system prefix (/usr, /usr/local, ...) based on hint provided + # Eg, + # sysPrefix "/usr/local/include/fftw3.h" -> "/usr/local" + # + # Without a hint, echoes "/usr" + sysPrefix() + { + case "$1" in + /usr/local/*) + echo "/usr/local" + ;; + *) + echo "/usr" + ;; + esac + } + + + # Check 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" ] + if [ -f "$file" ] && [ -r "$file" ] then - echo "$file" + echo "$file" # Found return 0 fi done return 2 } - # Check for existence of file in FOAM_EXT_LIBBIN, - # but not if either file or FOAM_EXT_LIBBIN are empty or - # if the FOAM_EXT_LIBBIN is not located in the ThirdParty directory + + # Check existence of library with ending '.a', '.so' ... + # + # On success, echoes the resolved file and returns 0, otherwise returns 2 + findLibrary() + { + local file ext + + for file + do + [ -n "$file" ] || continue + for ext in '' $extLibraries + do + if [ -f "$file$ext" ] && [ -r "$file$ext" ] + then + echo "$file$ext" # Found + return 0 + fi + done + done + + return 2 + } + + + # Check existence of library in FOAM_EXT_LIBBIN, but conditional + # on FOAM_EXT_LIBBIN being located in the ThirdParty directory # # On success, echoes the resolved file and returns 0, otherwise returns 2 - thirdExtLib() + findExtLib() { - local file="$FOAM_EXT_LIBBIN/$1" + local file - if [ -n "$1" ] && \ - [ -n "$FOAM_EXT_LIBBIN" ] && \ - [ -n "$WM_THIRD_PARTY_DIR" ] && \ - [ -f "$file" -a -r "$file" ] && \ - [ "${FOAM_EXT_LIBBIN#$WM_THIRD_PARTY_DIR}" != "$FOAM_EXT_LIBBIN" ] + if [ -n "$FOAM_EXT_LIBBIN" ] && \ + [ -n "$WM_THIRD_PARTY_DIR" ] && \ + [ "${FOAM_EXT_LIBBIN#$WM_THIRD_PARTY_DIR}" != "$FOAM_EXT_LIBBIN" ] then - echo "$file" - else - return 2 + for file + do + if file="$(findLibrary "$FOAM_EXT_LIBBIN/$file")" + then + echo "$file" + return 0 + fi + done fi + + return 2 } fi -- GitLab