Files
ThirdParty-common/makeMesa
2016-08-01 10:45:10 +02:00

201 lines
5.4 KiB
Bash
Executable File

#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# 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
# makeMesa
#
# Description
# Build script for Mesa
#
# Note
# Building with mesa-12.0.1 failed to install an "osmesa.h" file,
# which renders it useless for off-screen VTK.
#
#------------------------------------------------------------------------------
mesaPACKAGE=mesa-11.2.2
#------------------------------------------------------------------------------
# run from third-party directory only
cd ${0%/*} || exit 1
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
echo " The environment variables are inconsistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
}
. etc/tools/ThirdPartyFunctions
#------------------------------------------------------------------------------
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: $Script [OPTION] [mesa-VERSION]
options:
-gcc force gcc/g++ instead of the values from \$WM_CC, \$WM_CXX
-help
* build Mesa with
${mesaPACKAGE:-'unspecified MESA version'}
USAGE
exit 1
}
#------------------------------------------------------------------------------
# ensure configure gets the correct C/C++ compiler
[ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
# Non-standard location for clang?
unset thirdPartyClang
if [ "$WM_COMPILER_TYPE" = ThirdParty -a "$WM_COMPILER" = Clang ]
then
thirdPartyClang=true
fi
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-gcc)
export CC=gcc # use gcc/g++
export CXX=g++
unset thirdPartyClang
;;
mesa-*)
mesaPACKAGE="${1%%/}"
;;
*)
die "unknown option/argument: '$1'"
;;
esac
shift
done
[ -n "$mesaPACKAGE" ] || die "The mesa-VERSION was not specified"
# nothing to build
if _foamIsNone "$mesaPACKAGE"
then
echo "Using mesa-none (skip ThirdParty build of MESA)"
exit 0
fi
if _foamIsSystem "$mesaPACKAGE"
then
echo "Using mesa-system (skip ThirdParty build of MESA)"
exit 0
fi
#------------------------------------------------------------------------------
# locate third-party clang as required
if [ "$thirdPartyClang" = true ]
then
thirdPartyClang=$(command -v clang) || {
echo "Error: could not properly locate clang"
exit 2
}
# root installation directory
thirdPartyClang=${thirdPartyClang%/bin/clang}
[ -d "$thirdPartyClang" ] || {
echo "Error: could not properly locate clang"
exit 2
}
fi
#------------------------------------------------------------------------------
#
# Build MESA
# For 64-bit
# - MESA itself will normally build into 'lib64'.
#
# MESA_SOURCE_DIR : location of the original sources
MESA_ARCH_PATH=$installBASE/$mesaPACKAGE
MESA_SOURCE_DIR=$WM_THIRD_PARTY_DIR/$mesaPACKAGE
(
# configuration options:
unset configOpt
if [ -d "$thirdPartyClang" ]
then
configOpt="$configOpt --with-llvm-prefix=$thirdPartyClang"
fi
# end of configuration options
# ----------------------------
buildDIR=$buildBASE/$mesaPACKAGE
cd $MESA_SOURCE_DIR || exit 1
# remove any existing build
rm -rf $MESA_ARCH_PATH
rm -rf $buildDIR
mkdir -p $buildDIR
cd $buildDIR
echo "----"
echo "Building $mesaPACKAGE"
echo " Source : $MESA_SOURCE_DIR"
echo " Target : $MESA_ARCH_PATH"
if [ -d "$thirdPartyClang" ]
then
echo " Clang : $thirdPartyClang"
fi
echo "----"
# possibly for older mesa versions (see paraview wiki)
# CXXFLAGS="-O2 -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
# CFLAGS="-O2 -DDEFAULT_SOFTWARE_DEPTH_BITS=31" \
## autoreconf -fi
set -x
$MESA_SOURCE_DIR/configure \
--prefix=$MESA_ARCH_PATH \
--disable-xvmc \
--disable-glx \
--disable-dri \
--disable-egl \
--enable-texture-float \
--enable-gallium-osmesa --with-gallium-drivers=swrast \
$configOpt \
&& make -j $WM_NCOMPPROCS \
&& make install \
&& echo "Built $mesaPACKAGE"
) || {
echo "Error building: MESA"
exit 1
}
# ----------------------------------------------------------------- end-of-file