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 [ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE
61 # define options for mpi support
65 [ "$WITH_MPI" = ON ] || 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 [ "$WITH_PYTHON" = ON ] || 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 WITH_PYTHON=OFF"
112 pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/')
113 pythonInclude=/usr/include/python$pythonMajor
115 [ -e "$PYTHON_LIBRARY" ] || {
116 echo " Please set the variable PYTHON_LIBRARY to the full"
117 echo " path to (and including) libpython, or deactivate"
118 echo " python support by setting WITH_PYTHON=OFF"
122 # note - we could also allow for a PYTHON_INCLUDE variable ...
123 [ -e "$pythonInclude" ] || {
124 echo " No python include headers found"
125 echo " Please install python headers or deactivate "
126 echo " python support by setting WITH_PYTHON=OFF"
130 addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON
131 addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude
132 addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY
135 echo "Python information:"
136 echo " executable : $pythonBin"
137 echo " version : $pythonMajor"
138 echo " include path : $pythonInclude"
139 echo " library : $PYTHON_LIBRARY"
141 unset pythonBin pythonInclude pythonMajor
143 echo "*** Error: python not installed"
144 echo "*** Deactivate python support by setting WITH_PYTHON=OFF"
151 # define options for mesa support
155 [ "$WITH_MESA" = ON ] || return
157 if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ]
159 OBJ_ADD="$OBJ_ADD-mesa"
161 addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON
162 addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR
163 addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY
166 echo "*** Error: no MESA information found"
167 echo "*** Deactivate MESA support by setting WITH_MESA=OFF, or"
168 echo "*** correct paths given by:"
169 echo "*** - MESA_INCLUDE_DIR ($MESA_INCLUDE_DIR)"
170 echo "*** - MESA_LIBRARY ($MESA_LIBRARY)"
177 # discover where things are or should be put
181 # set paraview environment
182 for i in $PWD $WM_THIRD_PARTY_DIR
184 ParaView_INST_DIR=$i/$PARAVIEW_SRC
185 [ -d $ParaView_INST_DIR ] && break
188 if [ ! -d "$ParaView_INST_DIR" ]
190 # last chance: maybe already in the paraview directory
191 [ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD
193 [ -d "$ParaView_INST_DIR" ] || {
194 echo "did not find $PARAVIEW_SRC in these directories:"
196 echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
202 # ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD
203 ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER
204 echo "ParaView_DIR=$ParaView_DIR"
209 # configure via cmake, but don't actually build anything
213 # remove any existing build folder and recreate
214 if [ -d $ParaView_DIR ]
216 echo "removing old build/install directory"
219 mkdir -p $ParaView_DIR
224 echo "Configuring $PARAVIEW_SRC"
225 echo " MPI support : $WITH_MPI"
226 echo " Python support : $WITH_PYTHON"
227 echo " MESA support : $WITH_MESA"
228 echo " Source : $ParaView_INST_DIR"
229 echo " Target : $ParaView_DIR"
233 -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
240 # run cmake to create Makefiles
242 -DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
251 # also link bin/ to lib/paraview-* for development without installation
255 cd $ParaView_DIR || exit 1 # change to build folder
256 echo " Starting make"
258 if [ -r /proc/cpuinfo ]
260 WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
261 [ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8
263 time make -j $WM_NCOMPPROCS
269 echo " For quicker development, linking lib/paraview-$PARAVIEW_MAJOR_VERSION/ -> bin/"
270 rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION
271 mkdir lib 2>/dev/null
272 ( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION )
277 # adjust hard-links (internal function)
278 # Note: use loop with grep to avoid touching too many files
286 echo "-- Replacing path hard links for \$$envName"
290 echo -n " $fileSpec: "
291 for i in $(find . -type f -iname "$fileSpec")
293 if grep -q "$string" $i
296 sed -i "s,$string,\$ENV{$envName},g" $i
305 # replace absolute paths with environment variables
306 # This triggers a partial (or even a full) rebuild, but might let us
307 # find our files later if we relocate the build
311 cd $ParaView_DIR || exit 1 # change to build folder
313 # Replace path with env variable: ParaView_DIR
314 fixHardLinks ParaView_DIR "$ParaView_DIR" '*.cmake'
316 # Replace path with env variable: ParaView_INST_DIR
317 fixHardLinks ParaView_INST_DIR "$ParaView_INST_DIR" '*.cmake'
319 # Replace path with env variable: MPI_ARCH_PATH
320 if [ "$WITH_MPI" = ON ]
322 fixHardLinks MPI_ARCH_PATH "$MPI_ARCH_PATH" '*.cmake'
325 # Replace path with env variable: CMAKE_HOME
326 if [ -r "$CMAKE_HOME" ]
328 fixHardLinks CMAKE_HOME "$CMAKE_HOME" '*cmake*'
331 # Replace path with env variable: WM_COMPILER_DIR
332 # (include cmake.check_cache)
333 # This triggers a complete rebuild (with cmake-2.6.2), but is likely
334 # needed when redistributing files
335 fixHardLinks WM_COMPILER_DIR "$WM_COMPILER_DIR" '*cmake*'
340 # make html documentation (mostly just for the readers/writers)
344 cd $ParaView_DIR || exit 1 # change to build folder
345 echo " Creating html documentation"
347 make HTMLDocumentation
352 # actually install the program
356 cd $ParaView_DIR || exit 1 # change to build folder
357 echo " Installing ParaView to $ParaView_DIR"
359 echo "disabled 'make install' for now, just use links"
361 # about.txt may be missing
362 paraviewLibDir="$ParaView_DIR/lib/paraview-$PARAVIEW_MAJOR_VERSION"
363 if [ -d "$paraviewLibDir" -a ! -e "$paraviewLibDir/about.txt" ]
365 echo "paraview-$PARAVIEW_MAJOR_VERSION installed - $(date)" > $paraviewLibDir/about.txt
370 Installation complete
371 Set environment variables:
373 export ParaView_INST_DIR=$ParaView_INST_DIR
374 export ParaView_DIR=$ParaView_DIR
375 export PV_PLUGIN_PATH=$FOAM_LIBBIN
376 export PATH=\$ParaView_DIR/bin:\$PATH
382 # clear all the variables used before using any of the functions
384 unset WITH_MPI WITH_MESA
385 unset WITH_PYTHON PYTHON_LIBRARY
386 unset CMAKE_VARIABLES
389 # start with these general settings
390 addCMakeVariable VTK_USE_TK=FALSE
391 addCMakeVariable BUILD_SHARED_LIBS:BOOL=ON VTK_USE_RPATH:BOOL=OFF
392 addCMakeVariable CMAKE_BUILD_TYPE:STRING=Release
394 # include development files in "make install"
395 addCMakeVariable PARAVIEW_INSTALL_DEVELOPMENT:BOOL=ON
397 # ----------------------------------------------------------------- end-of-file