mirror of
https://develop.openfoam.com/Development/ThirdParty-common.git
synced 2025-12-08 06:57:50 +00:00
ENH: improve flexibility of make scripts
- the various make scripts now also search hierarchical sources,
which makes it easier to organize sources. The secondary
sub-directory is the lower-case value of the package stripped of
trailing non-alphabet characters.
For example, searching for ParaView-v5.9.1
sources/
|-- adios
| |-- ...
| |-- ADIOS2-2.7.1
| \-- adios-1.13.1
|-- cgal
| |-- CGAL-4.12.2
| \-- CGAL-4.14.2
| ...
|-- openmpi
| |-- openmpi-4.0.3
| \-- openmpi-4.1.1
|-- paraview
| |-- ParaView-v5.6.1
| \-- ParaView-v5.9.1
\-- scotch
...
- additional out-of-source build options
FOAM_THIRD_PARTY_BUILDROOT :
Replace WM_THIRD_PARTY_DIR as the root for build/ and platforms/
FOAM_THIRD_PARTY_SOURCES :
Alternative to WM_THIRD_PARTY_DIR/sources/
- rationalise internal package variable names for easier maintenance
This commit is contained in:
135
makeLLVM
135
makeLLVM
@ -7,7 +7,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -39,14 +39,16 @@
|
||||
# ----------------------------------------------
|
||||
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
|
||||
#------------------------------------------------------------------------------
|
||||
# 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
|
||||
if : # Run from third-party directory
|
||||
then
|
||||
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
|
||||
}
|
||||
fi
|
||||
. "${WM_THIRD_PARTY_DIR:?}"/etc/tools/ThirdPartyFunctions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
[ "${WM_COMPILER#Clang}" = "$WM_COMPILER" ] && WM_COMPILER=Clang # Force clang
|
||||
@ -55,26 +57,26 @@ WM_COMPILER_TYPE=ThirdParty # Ensure we get the correct settings
|
||||
# LLVM/Clang version from OpenFOAM etc/config.sh file:
|
||||
_foamConfig compiler
|
||||
|
||||
llvmPACKAGE=$clang_version
|
||||
PACKAGE="$clang_version"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
usage() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
printVersions() { listPackageVersions llvm; exit 0; }
|
||||
printHelp() {
|
||||
cat<<USAGE
|
||||
|
||||
usage: ${0##*/} [OPTION] [llvm-VERSION]
|
||||
Usage: ${0##*/} [OPTION] [llvm-VERSION]
|
||||
options:
|
||||
-gcc Force use of gcc/g++
|
||||
-cmake PATH with cmake from the given path
|
||||
-help
|
||||
-list List available unpacked source versions
|
||||
-help Display usage help
|
||||
|
||||
* build llvm/clang
|
||||
${llvmPACKAGE:-'unspecified LLVM version'}
|
||||
* Build llvm/clang
|
||||
${PACKAGE:-[unspecified]}
|
||||
|
||||
USAGE
|
||||
showDownloadHint LLVM
|
||||
exit 1
|
||||
showDownloadHint llvm
|
||||
exit 0 # Clean exit
|
||||
}
|
||||
#------------------------------------------------------------------------------
|
||||
exportCompiler # Compiler info for CMake/configure
|
||||
@ -84,7 +86,8 @@ while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
'') ;; # Ignore empty
|
||||
-h | -help) usage ;;
|
||||
-h | -help*) printHelp;;
|
||||
-list) printVersions;;
|
||||
-gcc) useGcc ;;
|
||||
|
||||
-cmake)
|
||||
@ -92,11 +95,13 @@ do
|
||||
CMAKE_PATH="${2%%/}"
|
||||
shift
|
||||
;;
|
||||
|
||||
llvm/* | sources/llvm* |\
|
||||
llvm-[0-9]* | llvm-svn*)
|
||||
llvmPACKAGE="${1%%/}"
|
||||
PACKAGE="${1%%/}"
|
||||
;;
|
||||
[0-9]*)
|
||||
llvmPACKAGE="llvm-${1%%/}"
|
||||
PACKAGE="llvm-${1%%/}"
|
||||
;;
|
||||
*)
|
||||
die "unknown option/argument: '$1'"
|
||||
@ -105,97 +110,97 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
[ -n "$llvmPACKAGE" ] || die "The llvm-VERSION was not specified"
|
||||
if [ -z "$PACKAGE" ]
|
||||
then
|
||||
die "The LLVM package/version not specified"
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Build/install locations without a compiler name
|
||||
buildBASE=$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER_ARCH
|
||||
installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
||||
# !Build/install locations with arch name only (NO compiler name)!
|
||||
buildBASE="$(dirname "$buildBASE")/$WM_ARCH$WM_COMPILER_ARCH"
|
||||
installBASE="$(dirname "$installBASE")/$WM_ARCH$WM_COMPILER_ARCH"
|
||||
|
||||
# Build LLVM (clang)
|
||||
# LLVM_SOURCE_DIR : location of the original sources
|
||||
# LLVM_BUILD_DIR : location of the build
|
||||
# LLVM_ARCH_PATH : location of the installed program
|
||||
# - Strip any trailing '.src' from the proper names
|
||||
# *PACKAGE : name-version of the package
|
||||
# *SOURCEDIR : location of original sources
|
||||
# *PREFIXDIR : installation directory
|
||||
# Note: strip trailing '.src' from package name
|
||||
|
||||
LLVM_SOURCE_DIR=$sourceBASE/$llvmPACKAGE
|
||||
LLVM_BUILD_DIR=$buildBASE/${llvmPACKAGE%%.src}
|
||||
LLVM_ARCH_PATH=$installBASE/${llvmPACKAGE%%.src}
|
||||
PKG_SOURCE="$(findSourceDir "$PACKAGE")"
|
||||
PACKAGE="$(basename "$PACKAGE" .src)" # Strip of trailing .src
|
||||
PKG_PREFIX="$installBASE/$PACKAGE"
|
||||
export GIT_DIR="$PKG_SOURCE/.git" # Avoid seeing our own git-repo
|
||||
|
||||
#
|
||||
# Build LLVM
|
||||
#
|
||||
|
||||
# Building...
|
||||
echo "---------------"
|
||||
if [ -d $LLVM_ARCH_PATH ]
|
||||
if [ -d "$PKG_PREFIX" ]
|
||||
then
|
||||
echo "Already built: $llvmPACKAGE"
|
||||
elif [ -z "$CMAKE_PATH" ] && $LLVM_SOURCE_DIR/configure -help >/dev/null 2>&1
|
||||
echo "Already built: $PACKAGE"
|
||||
elif [ -z "$CMAKE_PATH" ] && "$PKG_SOURCE"/configure -help >/dev/null 2>&1
|
||||
then
|
||||
# configure can be used prior to 3.9.0
|
||||
# but use cmake if someone explicitly mentioned -cmake on the command-line
|
||||
|
||||
echo "Starting build: $llvmPACKAGE (using configure)"
|
||||
echo "Starting build: $PACKAGE (using configure)"
|
||||
echo
|
||||
(
|
||||
cd "$LLVM_SOURCE_DIR" || exit
|
||||
export GIT_DIR="$PWD/.git" # Mask seeing our own git-repo
|
||||
make distclean 2>/dev/null
|
||||
PKG_BUILD="$buildBASE/$PACKAGE"
|
||||
cd "$PKG_SOURCE" || exit
|
||||
make distclean 2>/dev/null || true
|
||||
|
||||
rm -rf $LLVM_BUILD_DIR
|
||||
mkdir -p $LLVM_BUILD_DIR
|
||||
cd $LLVM_BUILD_DIR
|
||||
rm -rf "$PKG_BUILD"
|
||||
mkdir -p "$PKG_BUILD"
|
||||
|
||||
set -x
|
||||
$LLVM_SOURCE_DIR/configure \
|
||||
--prefix=$LLVM_ARCH_PATH \
|
||||
cd "$PKG_BUILD" && set -x && \
|
||||
"$PKG_SOURCE"/configure \
|
||||
--prefix="$PKG_PREFIX" \
|
||||
--with-gcc-toolchain="$(command -v gcc | sed 's%/bin/gcc%%')" \
|
||||
--enable-optimized \
|
||||
--enable-shared \
|
||||
&& set +x \
|
||||
&& make -j $WM_NCOMPPROCS \
|
||||
&& make install \
|
||||
&& echo "Built: $llvmPACKAGE"
|
||||
&& echo "Built: $PACKAGE"
|
||||
) || {
|
||||
echo "Error building: $llvmPACKAGE"
|
||||
echo "Error building: $PACKAGE"
|
||||
exit 1
|
||||
}
|
||||
|
||||
else
|
||||
# CMake used with 3.9.0 and later
|
||||
|
||||
echo "Starting build: $llvmPACKAGE (using cmake)"
|
||||
echo "Starting build: $PACKAGE (using cmake)"
|
||||
echo
|
||||
(
|
||||
PKG_BUILD="$buildBASE/$PACKAGE"
|
||||
cd "$PKG_SOURCE" || exit
|
||||
|
||||
# Configuration options:
|
||||
unset configOpt
|
||||
|
||||
cd "$LLVM_SOURCE_DIR" || exit
|
||||
export GIT_DIR="$PWD/.git" # Mask seeing our own git-repo
|
||||
|
||||
if [ -f tools/openmp/CMakeLists.txt ]
|
||||
then
|
||||
configOpt="$configOpt -DLLVM_TOOL_OPENMP_BUILD=ON"
|
||||
fi
|
||||
|
||||
rm -rf $LLVM_BUILD_DIR
|
||||
mkdir -p $LLVM_BUILD_DIR
|
||||
cd $LLVM_BUILD_DIR
|
||||
rm -rf "$PKG_BUILD"
|
||||
mkdir -p "$PKG_BUILD"
|
||||
|
||||
cmake=$(findCMake)
|
||||
|
||||
set -x
|
||||
$cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=$LLVM_ARCH_PATH \
|
||||
cd "$PKG_BUILD" && set -x && \
|
||||
${cmake:?} \
|
||||
-DCMAKE_INSTALL_PREFIX="$PKG_PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_SHARED_LIBS=ON \
|
||||
$configOpt \
|
||||
$LLVM_SOURCE_DIR \
|
||||
"$PKG_SOURCE" \
|
||||
&& set +x \
|
||||
&& make -j $WM_NCOMPPROCS \
|
||||
&& make install \
|
||||
&& echo "Built: $llvmPACKAGE"
|
||||
&& echo "Built: $PACKAGE"
|
||||
) || {
|
||||
echo "Error building: $llvmPACKAGE"
|
||||
echo "Error building: $PACKAGE"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user