#---------------------------------*- sh -*------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # Script # buildParaViewFunctions # # Description # ParaView build/install helper functions # #------------------------------------------------------------------------------ # ParaView_INST_DIR : location of the original sources # ParaView_DIR : location of the compiled output addCMakeVariable() { while [ -n "$1" ] do CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1" shift done } addVerbosity() { [ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE } addMpiSupport() { [ "$WITH_MPI" = ON ] || return OBJ_ADD="$OBJ_ADD-mpi" addCMakeVariable PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS } addPythonSupport() { [ "$WITH_PYTHON" = ON ] || return OBJ_ADD="$OBJ_ADD-py" if pythonBin=$(which python 2>/dev/null) then if [ -n "$PYTHON_LIBRARY" ] then # check $PYTHON_LIBRARY if it has been set if [ ! -e "$PYTHON_LIBRARY" ] then echo "*** Error: libpython not found at location specified " \ "by PYTHON_LIBRARY=$PYTHON_LIBRARY" fi else # Try to get $PYTHON_LIBRARY from dynamically linked binary PYTHON_LIBRARY=$(ldd $pythonBin | \ sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p') if [ ! -e "$PYTHON_LIBRARY" ] then echo "*** Error: Unable to determine path to python library." fi fi [ -e "$PYTHON_LIBRARY" ] || { echo " Please set the variable PYTHON_LIBRARY to the full" echo " path to (and including) libpython, or deactivate" echo " python support by setting WITH_PYTHON=OFF" exit 1 } pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/') pythonInclude=/usr/include/python$pythonMajor [ -e "$PYTHON_LIBRARY" ] || { echo " Please set the variable PYTHON_LIBRARY to the full" echo " path to (and including) libpython, or deactivate" echo " python support by setting WITH_PYTHON=OFF" exit 1 } # note - we could also allow for a PYTHON_INCLUDE variable ... [ -e "$pythonInclude" ] || { echo " No python include headers found" echo " Please install python headers or deactivate " echo " python support by setting WITH_PYTHON=OFF" exit 1 } addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY echo "----" echo "Python information:" echo " executable : $pythonBin" echo " version : $pythonMajor" echo " include path : $pythonInclude" echo " library : $PYTHON_LIBRARY" unset pythonBin pythonInclude pythonMajor else echo "*** Error: python not installed" echo "*** Deactivate python support by setting WITH_PYTHON=OFF" exit 1 fi } addMesaSupport() { [ "$WITH_MESA" = ON ] || return MESA_INCLUDE_DIR=/usr/include/GL MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ] then OBJ_ADD="$OBJ_ADD-mesa" addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY else echo "*** Error: no MESA information found" exit 1 fi } # # discover where things are or should be put # getPaths() { # set paraview environment for i in $PWD $WM_THIRD_PARTY_DIR do ParaView_INST_DIR=$i/$PARAVIEW_SRC [ -d $ParaView_INST_DIR ] && break done if [ ! -d "$ParaView_INST_DIR" ] then # last chance: maybe already in the paraview directory [ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD [ -d "$ParaView_INST_DIR" ] || { echo "did not find $PARAVIEW_SRC in these directories:" echo " PWD=$PWD" echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR" echo "abort build" exit 1 } fi # ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER echo "ParaView_DIR=$ParaView_DIR" } # configure via cmake, but don't actually build anything configParaView() { # remove any existing build folder and recreate rm -rf $ParaView_DIR mkdir -p $ParaView_DIR cd $ParaView_DIR echo "----" echo "Configuring $PARAVIEW_SRC" echo " MPI support : $WITH_MPI" echo " Python support : $WITH_PYTHON" echo " MESA support : $WITH_MESA" echo " Source : $ParaView_INST_DIR" echo " Target : $ParaView_DIR" echo "----" echo echo cmake \ -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \ $CMAKE_VARIABLES \ $ParaView_INST_DIR echo echo "----" echo # run cmake to create Makefiles cmake \ -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \ $CMAKE_VARIABLES \ $ParaView_INST_DIR } makeParaView() { # change to build/install folder cd $ParaView_DIR || exit 1 echo " Starting make" if [ -r /proc/cpuinfo ] then WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l) [ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8 make -j $WM_NCOMPPROCS else make fi make install echo " Done make" } # adjust hard-links # Note: use loop with grep to avoid touching too many files fixCMakeHardLinks() { fileSpec=$1 string=$2 envName=$3 echo -n " for \$$envName " for i in $(find . -type f -iname "$fileSpec") do if grep -q "$string" $i then echo -n "#" sed -i "s,$string,\$ENV{$envName},g" $i fi done echo } installParaView() { [ -e "$ParaView_DIR/bin/paraview" ] || { echo " Cannot install - no paraview binary found" return } # change to build/install folder cd $ParaView_DIR || exit 1 echo " Installing ParaView" echo " Replacing path hard links" # Replace local ParaView_INST_DIR path with ParaView_INST_DIR # environment variable fixCMakeHardLinks '*.cmake' "$ParaView_INST_DIR" ParaView_INST_DIR # Replace local MPI_ARCH_PATH path with MPI_ARCH_PATH # environment variable if [ "$WITH_MPI" = ON ] then fixCMakeHardLinks '*.cmake' "$MPI_ARCH_PATH" MPI_ARCH_PATH fi # Replace local CMAKE_HOME path with CMAKE_HOME # environment variable if [ -r "$CMAKE_HOME" ] then fixCMakeHardLinks '*cmake*' "$CMAKE_HOME" CMAKE_HOME fi # Replace local WM_COMPILER_DIR path with WM_COMPILER_DIR # environment variable fixCMakeHardLinks '*cmake*' "$WM_COMPILER_DIR" WM_COMPILER_DIR # create a softlink to the $ParaView_DIR/bin folder # - workaround for chosen install location echo " Creating lib/paraview-$PARAVIEW_MAJOR_VERSION soft link to 'bin'" rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION [ -d lib ] || mkdir lib ( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION ) # info on symlinks to screen echo "" echo " ---" echo " Installation complete" echo " Set environment variables:" echo " - ParaView_INST_DIR to $ParaView_INST_DIR" echo " - ParaView_DIR to $ParaView_DIR" echo " - PV_PLUGIN_PATH to $FOAM_LIBBIN" echo " Add $ParaView_DIR/bin to PATH" # echo " Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH" echo " ---" } # clear all the variables used before using any of the functions unset VERBOSE unset WITH_MPI unset WITH_MESA unset WITH_PYTHON unset PYTHON_LIBRARY unset CMAKE_VARIABLES unset OBJ_ADD # start with these general settings addCMakeVariable VTK_USE_TK=FALSE addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON addCMakeVariable VTK_USE_RPATH:BOOL=OFF addCMakeVariable CMAKE_BUILD_TYPE:STRING=Release # ----------------------------------------------------------------- end-of-file