Commit cd07d9f6 authored by mark's avatar mark
Browse files

ENH: provide makeMesa and makeVTK scripts

parent 5dd69004
#!/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
#!/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
# makeVTK
#
# Description
# Make and install VTK
# - place the VTK source under $WM_THIRD_PARTY_DIR/VTK-VERSION
#
# To use the VTK source from the ParaView source tree, simply make an
# appropriate link first. For example,
#
# ln -s ParaView-5.1.0/VTK VTK-7.1.0
#
#------------------------------------------------------------------------------
# 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
. etc/tools/ParaViewFunctions
. etc/tools/vtkFunctions
#------------------------------------------------------------------------------
#
# USER OPTIONS:
# ~~~~~~~~~~~~~
# MESA graphics support:
withMESA=false
MESA_INCLUDE="/usr/include/GL"
MESA_LIBRARY="/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
# Set the path to cmake
CMAKE_PATH=""
# New rendering backend (starting with vtk 7?).
# Default to auto-config based on VTK version
withGL2=auto
#
# NO FURTHER EDITING BELOW THIS LINE
#
#-----------------------------------------------------------------------------
Script=${0##*/}
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: $Script [OPTION] [vtk-VERSION] [CMAKE-OPTION]
options:
-rebuild for repeated builds (-make -install) *use with caution*
-gl2 with new rendering backend (if not already enabled)
-mesa with mesa (if not already enabled)
-osmesa with off-screen mesa only
-cmake PATH with the cmake version corresponding to the cmake path given
-gcc force g++ instead of the value from \$WM_CXX
-verbose verbose output in Makefiles
-version VER specify an alternative version (current value: $VTK_VERSION)
-buildType NAME specify the build type (default: Release)
-mesa-prefix DIR location of mesa installation
-mesa-include DIR location of mesa headers (current value: ${MESA_INCLUDE:-none})
-mesa-lib PATH path to mesa library (current value: ${MESA_LIBRARY:-none})
-help
The -no-FEATURE option can be disable these features (if not already disabled):
mesa
CMake options start with a capital letter and contain an '='.
For example,
$Script BUILD_TESTING=ON
to add tests and avoid building documentation
For finer control, the build stages can be selected or deselected individually:
-config -no-config
-make -no-make
-install -no-install
* Make and install VTK-$VTK_VERSION located under
\$WM_THIRD_PARTY_DIR/VTK-$VTK_VERSION
-> \$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/VTK-$VTK_VERSION
USAGE
exit 1
}
#------------------------------------------------------------------------------
# ensure CMake gets the correct C/C++ compiler
[ -n "$WM_CC" ] && export CC="$WM_CC"
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
#
# various building stages
#
unset runPATCH runCONFIG runMAKE runINSTALL
runDEFAULT=true
buildType=Release
withOSMESA=false
# parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
[0-9]* | vtk-[0-9]* | VTK-[0-9]*) # VTK version
setVtkVersion "${1%%/}"
;;
[A-Z]*=*) # cmake variables
addCMakeVariable "$1"
;;
-gcc)
export CC=gcc # use gcc/g++
export CXX=g++
;;
-config) # stage 1: config only
runCONFIG=true
unset runDEFAULT
;;
-no-config)
runCONFIG=false
;;
-make) # stage 2: make only
runMAKE=true
unset runDEFAULT
;;
-no-make)
runMAKE=false
;;
-install) # stage 3: install only
runINSTALL=true
unset runDEFAULT
;;
-no-install)
runINSTALL=false
;;
-rebuild) # shortcut for rebuilding
runMAKE=true
runINSTALL=true
unset runDEFAULT
;;
-gl2)
withGL2=true
;;
-no-gl2)
withGL2=false
;;
-mesa)
withMESA=true
;;
-osmesa)
withMESA=true
withOSMESA=true
;;
-no-mesa)
withMESA=false
withOSMESA=false
;;
-mesa-prefix)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
withMESA=true
MESA_INCLUDE="${2%%/}/include"
MESA_LIBRARY="${2%%/}/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so"
shift
;;
-mesa-include)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
MESA_INCLUDE="${2%%/}"
shift
;;
-mesa-lib)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
MESA_LIBRARY="${2%%/}"
shift
;;
-cmake)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
CMAKE_PATH="${2%%/}"
shift
;;
-verbose)
withVERBOSE=true
;;
-version)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
setVtkVersion "${2%%/}"
VTK_VERSION="${2%%/}"
shift
;;
-buildType)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
buildType="$2"
shift
;;
*)
die "unknown option/argument: '$1'"
;;
esac
shift
done
[ -n "$VTK_VERSION" ] || die "The vtk-VERSION was not specified"
# Version-specific adjustments
if [ "$withGL2" = auto ]
then
if [ "${VTK_VERSION%%.*}" -lt 7 ]
then
withGL2=false
else
withGL2=true
fi
fi
if [ "$runDEFAULT" = true ]
then
: ${runPATCH:=true}
: ${runCONFIG:=true}
: ${runMAKE:=true}
: ${runINSTALL:=true}
fi
# Set configure options
#~~~~~~~~~~~~~~~~~~~~~~
addVerbosity # verbose makefiles
addMesaSupport # set MESA-specific options
addGL2Support # new rendering backend
# set off-screen only options
if [ "$withOSMESA" = true ]
then
addCMakeVariable "VTK_USE_X:BOOL=OFF"
addCMakeVariable "OPENGL_INCLUDE_DIR=$MESA_INCLUDE"
addCMakeVariable "OPENGL_xmesa_INCLUDE_DIR=$MESA_INCLUDE"
addCMakeVariable "OPENGL_gl_LIBRARY=$MESA_LIBRARY"
addCMakeVariable "OPENGL_glu_LIBRARY=$MESA_LIBRARY"
fi
setVtkDirs # where things are or should be put
# Build and install
# ~~~~~~~~~~~~~~~~~
cat<<SUMMARY
Build stages selected
---------------------
-patch ${runPATCH:-false}
-config ${runCONFIG:-false}
-make ${runMAKE:-false}
-install ${runINSTALL:-false}
---------------------
Features selected
mesa ${withMESA:-false}
---------------------
Version information
version ${VTK_VERSION:-unknown}
build ${buildType:-Release}
---------------------
SUMMARY
[ "$runPATCH" = true ] && patchVTK
[ "$runCONFIG" = true ] && configVTK
[ "$runMAKE" = true ] && makeVTK
[ "$runINSTALL" = true ] && installVTK
echo
echo Done
#------------------------------------------------------------------------------
#!/bin/sh
# An example for building a particular combinations of VTK with off-screen mesa
vtk=vtk-7.1.0
mesa=mesa-11.2.2
./makeVTK \
$vtk \
-osmesa -mesa-prefix $WM_THIRD_PARTY_DIR/platforms/linux64Gcc/$mesa
#------------------------------------------------------------------------------
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment