1 #---------------------------------*- sh -*-------------------------------------
3 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 #------------------------------------------------------------------------------
9 # This file is part of OpenFOAM.
11 # OpenFOAM is free software; you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by the
13 # Free Software Foundation; either version 2 of the License, or (at your
14 # option) any later version.
16 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 # You should have received a copy of the GNU General Public License
22 # along with OpenFOAM; if not, write to the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 # buildParaViewFunctions
29 # ParaView build/install helper functions
31 #------------------------------------------------------------------------------
33 # ParaView_INST_DIR : location of the original sources
34 # ParaView_DIR : location of the build (for the ParaViewConfig.cmake)
35 # and the installed program
39 # set CMake cache variables
45 CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1"
56 [ "$withVERBOSE" = true ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE
61 # define options for mpi support
65 [ "${withMPI:=false}" = true ] || return
66 OBJ_ADD="$OBJ_ADD-mpi"
68 addCMakeVariable PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON
69 addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include
70 addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so
71 addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun
72 addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS
77 # define options for python support
81 [ "${withPYTHON:=false}" = true ] || return
84 if pythonBin=$(which python 2>/dev/null)
86 if [ -n "$PYTHON_LIBRARY" ]
88 # check $PYTHON_LIBRARY if it has been set
89 if [ ! -e "$PYTHON_LIBRARY" ]
91 echo "*** Error: libpython not found at location specified " \
92 "by PYTHON_LIBRARY=$PYTHON_LIBRARY"
95 # Try to get $PYTHON_LIBRARY from dynamically linked binary
96 PYTHON_LIBRARY=$(ldd $pythonBin | \
97 sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p')
99 if [ ! -e "$PYTHON_LIBRARY" ]
101 echo "*** Error: Unable to determine path to python library."
105 [ -e "$PYTHON_LIBRARY" ] || {
106 echo " Please set the variable PYTHON_LIBRARY to the full"
107 echo " path to (and including) libpython, or deactivate"
108 echo " python support by setting withPYTHON=false"
112 pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/')
113 pythonInclude=/usr/include/python$pythonMajor
115 # note - we could also allow for a PYTHON_INCLUDE variable ...
116 [ -d "$pythonInclude" ] || {
117 echo " No python headers found in $pythonInclude/"
118 echo " Please install python headers or deactivate "
119 echo " python support by setting withPYTHON=false"
123 addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON
124 addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude
125 addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY
128 echo "Python information:"
129 echo " executable : $pythonBin"
130 echo " version : $pythonMajor"
131 echo " include path : $pythonInclude"
132 echo " library : $PYTHON_LIBRARY"
134 unset pythonBin pythonInclude pythonMajor
136 echo "*** Error: python not found"
137 echo "*** Deactivate python support by setting withPYTHON=false"
144 # define options for mesa support
148 [ "${withMESA:=false}" = true ] || return
150 if [ -d "$MESA_INCLUDE" -a -f "$MESA_LIBRARY" ]
152 OBJ_ADD="$OBJ_ADD-mesa"
154 addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON
155 addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE
156 addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY
159 echo "*** Error: no MESA information found"
160 echo "*** Deactivate MESA support by setting withMESA=false, or"
161 echo "*** correct the paths given by:"
162 echo "*** - MESA_INCLUDE ($MESA_INCLUDE)"
163 echo "*** - MESA_LIBRARY ($MESA_LIBRARY)"
170 [ "${withQTSUPPORT:=false}" = true ] || return
172 addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON"
174 if [ -n "$QMAKE_PATH" ]
176 addCMakeVariable QT_QMAKE_EXECUTABLE:FILEPATH=$QMAKE_PATH
182 # discover where things are or should be put
186 if [ ! -n "$ParaView_INST_DIR" ]
188 # set paraview environment
189 for i in $PWD $WM_THIRD_PARTY_DIR
191 ParaView_INST_DIR=$i/paraview-$ParaView_VERSION
192 [ -d $ParaView_INST_DIR ] && break
196 if [ ! -d "$ParaView_INST_DIR" ]
198 # last chance: maybe already in the paraview directory
199 if [ "${PWD##*/}" = "paraview-$ParaView_VERSION" ]
201 ParaView_INST_DIR=$PWD
204 [ -d "$ParaView_INST_DIR" ] || {
205 echo "did not find paraview-$ParaView_VERSION in these directories:"
207 echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
214 # set the major version "<digits>.<digits>"
215 ParaView_MAJOR_VERSION=$(echo $ParaView_VERSION | \
216 sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/')
218 # ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD
219 ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER
220 echo "ParaView_DIR=$ParaView_DIR"
225 # configure via cmake, but don't actually build anything
229 # remove any existing build folder and recreate
230 if [ -d $ParaView_DIR ]
232 echo "removing old build/install directory"
235 mkdir -p $ParaView_DIR
240 echo "Configuring paraview-$ParaView_VERSION (major version: $ParaView_MAJOR_VERSION)"
241 echo " MPI support : ${withMPI:-false}"
242 echo " Python support : ${withPYTHON:-false}"
243 echo " MESA support : ${withMESA:-false}"
244 echo " Qt dev support : ${withQTSUPPORT:-false}"
245 echo " Source : $ParaView_INST_DIR"
246 echo " Target : $ParaView_DIR"
250 -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
257 # run cmake to create Makefiles
259 -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
268 # also link bin/ to lib/paraview-* for development without installation
272 cd $ParaView_DIR || exit 1 # change to build folder
273 echo " Starting make"
275 if [ -r /proc/cpuinfo ]
277 WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
278 [ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8
280 time make -j $WM_NCOMPPROCS
286 echo " For quicker development, linking lib/paraview-$ParaView_MAJOR_VERSION/ -> bin/"
287 rm -rf lib/paraview-$ParaView_MAJOR_VERSION
288 mkdir lib 2>/dev/null
289 ( cd lib && ln -s ../bin paraview-$ParaView_MAJOR_VERSION )
294 # adjust hard-links (internal function)
295 # Note: use loop with grep to avoid touching too many files
303 echo "-- Replacing path hard links for \$$envName"
307 echo -n " $fileSpec: "
308 for i in $(find . -type f -iname "$fileSpec")
310 if grep -q "$string" $i
313 sed -i "s,$string,\$ENV{$envName},g" $i
322 # replace absolute paths with environment variables
323 # This triggers a partial (or even a full) rebuild, but might let us
324 # find our files later if we relocate the build
328 cd $ParaView_DIR || exit 1 # change to build folder
330 # Replace path with env variable: ParaView_DIR
331 fixHardLinks ParaView_DIR "$ParaView_DIR" '*.cmake'
333 # Replace path with env variable: ParaView_INST_DIR
334 fixHardLinks ParaView_INST_DIR "$ParaView_INST_DIR" '*.cmake'
336 # Replace path with env variable: MPI_ARCH_PATH
337 if [ "${withMPI:=false}" = true ]
339 fixHardLinks MPI_ARCH_PATH "$MPI_ARCH_PATH" '*.cmake'
342 # Replace path with env variable: CMAKE_HOME
343 if [ -r "$CMAKE_HOME" ]
345 fixHardLinks CMAKE_HOME "$CMAKE_HOME" '*cmake*'
348 # Replace path with env variable: WM_COMPILER_DIR
349 # (include cmake.check_cache)
350 # This triggers a complete rebuild (with cmake-2.6.2), but is likely
351 # needed when redistributing files
352 fixHardLinks WM_COMPILER_DIR "$WM_COMPILER_DIR" '*cmake*'
357 # make html documentation (mostly just for the readers/writers)
361 cd $ParaView_DIR || exit 1 # change to build folder
362 echo " Creating html documentation"
364 make HTMLDocumentation
369 # actually install the program
373 cd $ParaView_DIR || exit 1 # change to build folder
374 echo " Installing ParaView to $ParaView_DIR"
376 echo "disabled 'make install' for now, just use links"
378 # about.txt may be missing
379 paraviewLibDir="$ParaView_DIR/lib/paraview-$ParaView_MAJOR_VERSION"
380 if [ -d "$paraviewLibDir" -a ! -e "$paraviewLibDir/about.txt" ]
382 echo "paraview-$ParaView_MAJOR_VERSION installed - $(date)" > $paraviewLibDir/about.txt
387 Installation complete
388 Set environment variables:
390 export ParaView_INST_DIR=$ParaView_INST_DIR
391 export ParaView_DIR=$ParaView_DIR
392 export PV_PLUGIN_PATH=$FOAM_LIBBIN
393 export PATH=\$ParaView_DIR/bin:\$PATH
399 # clear all the variables used before using any of the functions
400 unset withMPI withQTSUPPORT withVERBOSE
401 unset withMESA MESA_INCLUDE MESA_LIBRARY
402 unset withPYTHON PYTHON_INCLUDE PYTHON_LIBRARY
403 unset CMAKE_VARIABLES
406 # start with these general settings
407 addCMakeVariable VTK_USE_TK=FALSE
408 addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON VTK_USE_RPATH:BOOL=OFF
409 addCMakeVariable CMAKE_BUILD_TYPE:STRING=Release
411 # include development files in "make install"
412 addCMakeVariable PARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON
414 # ----------------------------------------------------------------- end-of-file