mirror of
https://develop.openfoam.com/Development/ThirdParty-common.git
synced 2025-12-08 06:57:50 +00:00
- similar functionality in etc/tools/ThirdPartyFunctions to improve the independence of ThirdParty while reducing clutter in the callers. - add useGcc function for convenience - mask seeing our own git-repo when building STYLE: various items - eliminate old user-editable configuration in files - now command-line only. - use *_BUILD_DIR instead of *_BINARY_DIR for more clarity of the purpose - drop use of '-q' option for wmakeCheckPwd (already has stderr redirect) - drop checkVersion for makeParaView since it stopped working properly with newer paraview version CONFIG: update list of versions
395 lines
9.9 KiB
Bash
Executable File
395 lines
9.9 KiB
Bash
Executable File
#!/bin/sh
|
|
#------------------------------------------------------------------------------
|
|
# ========= |
|
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
# \\ / O peration |
|
|
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
|
#------------------------------------------------------------------------------
|
|
# License
|
|
# This file is part of OpenFOAM.
|
|
#
|
|
# OpenFOAM is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
# for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
# Script
|
|
# makeGcc
|
|
#
|
|
# Description
|
|
# Build script gcc and gmp, mpfr, mpc.
|
|
#
|
|
# To force building against the system gmp/mpfr/mpc libraries,
|
|
# use a corresponding '*-system' version. For example,
|
|
#
|
|
# makeGcc gmp-system
|
|
#
|
|
# or use the '-system' options to use system libraries everywhere.
|
|
#
|
|
# The WM_COMPILER value can also be used specify a known gcc version.
|
|
# For example (also compiling against system gmp/mpfr/mpc),
|
|
#
|
|
# WM_COMPILER=Gcc51 ./makeGcc -system
|
|
#
|
|
# ----------------------------------------------
|
|
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
|
|
#------------------------------------------------------------------------------
|
|
# Run from third-party directory only
|
|
cd ${0%/*} && 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
|
|
#------------------------------------------------------------------------------
|
|
|
|
[ "${WM_COMPILER#Gcc}" = "$WM_COMPILER" ] && WM_COMPILER=Gcc # Force gcc
|
|
WM_COMPILER_TYPE=ThirdParty # Ensure we get the correct settings
|
|
|
|
# Default GCC, mpfr, gmp and mpc versions from OpenFOAM etc/config.sh file:
|
|
_foamEtc config.sh/compiler
|
|
|
|
gmpPACKAGE=${gmp_version:-gmp-system}
|
|
mpfrPACKAGE=${mpfr_version:-mpfr-system}
|
|
mpcPACKAGE=${mpc_version:-mpc-system}
|
|
gccPACKAGE=$gcc_version
|
|
|
|
#------------------------------------------------------------------------------
|
|
usage() {
|
|
exec 1>&2
|
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
|
cat<<USAGE
|
|
|
|
usage: ${0##*/} [OPTION] [gcc-VERSION] [gmp-VERSION] [mpfr-VERSION] [mpc-VERSION]
|
|
options:
|
|
-multilib for 64-bit systems with 32-bit support required
|
|
-no-multilib for 64-bit systems without 32-bit support (DEFAULT)
|
|
-no-threadsafe disable mpfr thread-safe (default is auto-detect)
|
|
-system use system versions for gmp/mpfr/mpc
|
|
-help
|
|
|
|
* build combinations of gmp, mpfr, mpc and gcc
|
|
$gmpPACKAGE
|
|
$mpfrPACKAGE
|
|
$mpcPACKAGE
|
|
${gccPACKAGE:-'unspecified GCC version'}
|
|
|
|
USAGE
|
|
exit 1
|
|
}
|
|
#------------------------------------------------------------------------------
|
|
# Build 32-bit libraries on 64-bit systems (normally not needed)
|
|
optMultilib=disable
|
|
unset optThreadSafe # unset=auto
|
|
|
|
# Parse options
|
|
while [ "$#" -gt 0 ]
|
|
do
|
|
case "$1" in
|
|
'') ;; # Ignore empty
|
|
-h | -help) usage ;;
|
|
|
|
-multi*)
|
|
optMultilib=enable
|
|
;;
|
|
-no-multi*)
|
|
optMultilib=disable
|
|
;;
|
|
-no-thread*)
|
|
optThreadSafe=disable
|
|
;;
|
|
-sys*)
|
|
gmpPACKAGE="gmp-system"
|
|
mpfrPACKAGE="mpfr-system"
|
|
mpcPACKAGE="mpc-system"
|
|
;;
|
|
gmp-[4-9]* | gmp-system)
|
|
gmpPACKAGE="${1%%/}"
|
|
;;
|
|
mpfr-[2-9]* | mpfr-system)
|
|
mpfrPACKAGE="${1%%/}"
|
|
;;
|
|
mpc-[0-9]* | mpc-system)
|
|
mpcPACKAGE="${1%%/}"
|
|
;;
|
|
gcc-[4-9]* | gcc-system)
|
|
gccPACKAGE="${1%%/}"
|
|
;;
|
|
*)
|
|
die "unknown option/argument: '$1'"
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
[ -n "$gccPACKAGE" ] || die "The gcc-VERSION was not specified"
|
|
|
|
cat<<SUMMARY
|
|
GCC configuration
|
|
------------------
|
|
GCC = $gccPACKAGE
|
|
GMP = $gmpPACKAGE
|
|
MPFR = $mpfrPACKAGE
|
|
MPC = $mpcPACKAGE
|
|
------------------
|
|
SUMMARY
|
|
|
|
# Set 32 or 64 bit ABI
|
|
case "$WM_ARCH_OPTION" in
|
|
32 | 64)
|
|
ABI=$WM_ARCH_OPTION
|
|
;;
|
|
*)
|
|
die "The WM_ARCH_OPTION ($WM_ARCH_OPTION) must be 32 or 64"
|
|
;;
|
|
esac
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
# Build/install without compiler name
|
|
buildBASE=$WM_THIRD_PARTY_DIR/build/$WM_ARCH$WM_COMPILER_ARCH
|
|
installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH
|
|
|
|
GCC_ARCH_PATH=$installBASE/$gccPACKAGE
|
|
GMP_ARCH_PATH=$installBASE/$gmpPACKAGE
|
|
MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
|
|
MPC_ARCH_PATH=$installBASE/$mpcPACKAGE
|
|
|
|
# Prefix <dir> to LD_LIBRARY_PATH, if it exists. 0 on success, 1 on failure
|
|
addLib()
|
|
{
|
|
if [ -d "$1" ]
|
|
then
|
|
export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
|
|
# ================
|
|
# Build GMP
|
|
# ================
|
|
echo "---------------"
|
|
if [ -d $GMP_ARCH_PATH ]
|
|
then
|
|
echo "Already built: $gmpPACKAGE"
|
|
elif _foamIsSystem $GMP_ARCH_PATH
|
|
then
|
|
echo "Using gmp-system"
|
|
else
|
|
echo "Starting build: $gmpPACKAGE"
|
|
echo
|
|
(
|
|
sourceDIR=$sourceBASE/$gmpPACKAGE
|
|
buildDIR=$buildBASE/$gmpPACKAGE
|
|
|
|
cd $sourceDIR || exit 1
|
|
export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
|
|
make distclean 2>/dev/null
|
|
|
|
rm -rf $buildDIR
|
|
mkdir -p $buildDIR
|
|
cd $buildDIR
|
|
|
|
set -x
|
|
$sourceDIR/configure ABI=$ABI \
|
|
--prefix=$GMP_ARCH_PATH \
|
|
--libdir=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
|
|
--enable-cxx \
|
|
&& set +x \
|
|
&& make -j $WM_NCOMPPROCS \
|
|
&& make install \
|
|
&& echo "Built: $gmpPACKAGE"
|
|
) || {
|
|
echo "Error building: $gmpPACKAGE"
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
if addLib "$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
|
|
then
|
|
configGMP=$(cat <<CONFIG_OPTIONS
|
|
--with-gmp-include=$GMP_ARCH_PATH/include
|
|
--with-gmp-lib=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
|
|
CONFIG_OPTIONS
|
|
)
|
|
else
|
|
unset configGMP
|
|
fi
|
|
|
|
|
|
# ================
|
|
# Build MPFR
|
|
# ================
|
|
echo "---------------"
|
|
if [ -d $MPFR_ARCH_PATH ]
|
|
then
|
|
echo "Already built: $mpfrPACKAGE"
|
|
elif _foamIsSystem $MPFR_ARCH_PATH
|
|
then
|
|
echo "Using mpfr-system"
|
|
else
|
|
echo "Starting build: $mpfrPACKAGE"
|
|
echo
|
|
(
|
|
sourceDIR=$sourceBASE/$mpfrPACKAGE
|
|
buildDIR=$buildBASE/$mpfrPACKAGE
|
|
|
|
cd $sourceDIR || exit 1
|
|
export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
|
|
make distclean 2>/dev/null
|
|
|
|
rm -rf $buildDIR
|
|
mkdir -p $buildDIR
|
|
cd $buildDIR
|
|
|
|
unset configOpt
|
|
# explicitly enable/disable thread-safe
|
|
[ -n "$optThreadSafe" ] && configOpt="--${optThreadSafe}-thread-safe"
|
|
|
|
set -x
|
|
$sourceDIR/configure ABI=$ABI \
|
|
--prefix=$MPFR_ARCH_PATH \
|
|
--libdir=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
|
|
$configGMP $configOpt \
|
|
&& set +x \
|
|
&& make -j $WM_NCOMPPROCS \
|
|
&& make install \
|
|
&& echo "Built: $mpfrPACKAGE"
|
|
) || {
|
|
echo "Error building: $mpfrPACKAGE"
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
if addLib "$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
|
|
then
|
|
configMPFR=$(cat <<CONFIG_OPTIONS
|
|
--with-mpfr-include=$MPFR_ARCH_PATH/include \
|
|
--with-mpfr-lib=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
|
|
CONFIG_OPTIONS
|
|
)
|
|
else
|
|
unset configMPFR
|
|
fi
|
|
|
|
|
|
# ================
|
|
# Build MPC
|
|
# ================
|
|
echo "---------------"
|
|
if [ -d $MPC_ARCH_PATH ]
|
|
then
|
|
echo "Already built: $mpcPACKAGE"
|
|
elif _foamIsSystem $MPC_ARCH_PATH
|
|
then
|
|
echo "Using mpc-system"
|
|
else
|
|
echo "Starting build: $mpcPACKAGE"
|
|
echo
|
|
(
|
|
sourceDIR=$sourceBASE/$mpcPACKAGE
|
|
buildDIR=$buildBASE/$mpcPACKAGE
|
|
|
|
cd $sourceDIR || exit 1
|
|
export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
|
|
make distclean 2>/dev/null
|
|
|
|
rm -rf $buildDIR
|
|
mkdir -p $buildDIR
|
|
cd $buildDIR
|
|
|
|
set -x
|
|
$sourceDIR/configure ABI=$ABI \
|
|
--prefix=$MPC_ARCH_PATH \
|
|
--libdir=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH \
|
|
$configGMP $configMPFR \
|
|
&& set +x \
|
|
&& make -j $WM_NCOMPPROCS \
|
|
&& make install \
|
|
&& echo "Built: $mpcPACKAGE"
|
|
) || {
|
|
echo "Error building: $mpcPACKAGE"
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
if addLib "$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
|
|
then
|
|
configMPC=$(cat <<CONFIG_OPTIONS
|
|
--with-mpc-include=$MPC_ARCH_PATH/include \
|
|
--with-mpc-lib=$MPC_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
|
|
CONFIG_OPTIONS
|
|
)
|
|
else
|
|
unset configMPC
|
|
fi
|
|
|
|
|
|
# ================
|
|
# Build GCC
|
|
# ================
|
|
# may need 32-bit glibc-devel headers to compile
|
|
# E.g. on ubuntu install g++-multilib
|
|
# or specify -no-multilib on the command-line
|
|
#
|
|
echo "---------------"
|
|
if [ -d $GCC_ARCH_PATH ]
|
|
then
|
|
echo "Already built: $gccPACKAGE"
|
|
elif _foamIsSystem $GCC_ARCH_PATH
|
|
then
|
|
echo "Using gcc-system"
|
|
else
|
|
echo "Starting build: $gccPACKAGE"
|
|
echo
|
|
(
|
|
sourceDIR=$sourceBASE/$gccPACKAGE
|
|
buildDIR=$buildBASE/$gccPACKAGE
|
|
|
|
cd $sourceDIR || exit 1
|
|
export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
|
|
make distclean 2>/dev/null
|
|
|
|
rm -rf $buildDIR
|
|
mkdir -p $buildDIR
|
|
cd $buildDIR
|
|
|
|
unset configOpt
|
|
# with/without multi-lib (32-bit support on 64-bit systems)
|
|
[ -n "$optMultilib" ] && configOpt="--${optMultilib}-multilib"
|
|
|
|
set -x
|
|
$sourceDIR/configure \
|
|
--prefix=$GCC_ARCH_PATH \
|
|
--with-pkgversion=OpenFOAM \
|
|
--enable-languages=c,c++ \
|
|
--enable-__cxa_atexit \
|
|
--enable-libstdcxx-allocator=new \
|
|
--with-system-zlib \
|
|
$configGMP $configMPFR $configMPC $configOpt \
|
|
MAKEINFO=missing \
|
|
&& set +x \
|
|
&& make -j $WM_NCOMPPROCS \
|
|
&& make install \
|
|
&& echo "Built: $gccPACKAGE"
|
|
) || {
|
|
echo "Error building: $gccPACKAGE"
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
|
|
#------------------------------------------------------------------------------
|