]> SALOME platform Git repositories - tools/install.git/blob - config_files/VTK-4.2.6.sh
Salome HOME
Update for version 3.0.0
[tools/install.git] / config_files / VTK-4.2.6.sh
1 #!/bin/sh
2
3 check_version()
4 {
5 if [ -z "$VTKHOME" ]; then
6    return 1 
7 fi
8 check_lib_version libvtkCommon.so ${VTKHOME}/lib/vtk
9 if [ "$?" -eq "0" ]; then
10    return 0
11 fi
12 return 1
13 }
14
15 print_env()
16 {
17 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
18 #$DELIM ${PRODUCT_TYPE} $DELIM
19 export VTKHOME=\${INSTALL_ROOT}/${PRODUCT}
20 export PATH=\${VTKHOME}/bin:\${PATH}
21 export LD_LIBRARY_PATH=\${VTKHOME}/lib/vtk:\${LD_LIBRARY_PATH}
22 export PYTHONPATH=\${VTKHOME}/lib/vtk:\${VTKHOME}/lib/python\${PYTHON_VERSION}/site-packages/vtk_python:\${PYTHONPATH}
23 export TCLLIBPATH="\${VTKHOME}/lib/vtk/tcl \${TCLLIBPATH}"
24 ##
25 EOF
26 (test -w ${PRODUCT_DIR} && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh ${PRODUCT_DIR})
27 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
28 }
29
30 # looks for the native product and collects it's environment (used by make_env())
31 try_native(){
32 check_version
33 if [ $? -eq 0 ] ; then
34     python_version="`python -c 'import sys; print sys.version[:3]'`"
35     tmp="\${VTKHOME}/bin ${VTKHOME}/bin \${PATH} ${PATH}";  
36     path=`sort_path ${tmp}`
37     tmp="\${VTKHOME}/lib/vtk ${VTKHOME}/lib/vtk \${LD_LIBRARY_PATH} ${LD_LIBRARY_PATH}";  
38     ld_library_path=`sort_path ${tmp}`
39     tmp="\${VTKHOME}/lib/vtk:\${VTKHOME}/lib/python${PYTHON_VERSION}/site-packages/vtk_python ${VTKHOME}/lib/vtk:${VTKHOME}/lib/python${python_version}/site-packages/vtk_python \${PYTHONPATH} ${PYTHONPATH}";  
40     python_path=`sort_path ${tmp}`
41     cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
42 #$DELIM ${PRODUCT_TYPE} $DELIM
43 export VTKHOME=${VTKHOME}
44 export PATH=${path}
45 export LD_LIBRARY_PATH=${ld_library_path}
46 export PYTHONPATH=${python_path}
47 export TCLLIBPATH="\${VTKHOME}/lib/vtk/tcl \${TCLLIBPATH}"
48 ##
49 EOF
50     make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
51     return 0
52 fi
53 return 1;
54 }
55
56 try_preinstalled(){
57 try_existing ${PRODUCT_DIR} ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
58 return $?
59 }
60
61 install_source()
62 {
63 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
64 source ${INSTALL_WORK}/$SHRC
65
66 makedir ${PRODUCT_DIR}
67
68 check_jb tar xfz ${SOURCE_DIR}/cmake-1.6.6.tar.gz -C ${INSTALL_WORK}
69 cd ${INSTALL_WORK}/cmake-1.6.6
70 check_job ${PRODUCT_DIR}/CONFIGUREcmake.LOG ./configure
71 cat >> ${PRODUCT_DIR}/MAKEcmake.LOG <<EOF
72 used gcc=$GCC
73 EOF
74 check_job ${PRODUCT_DIR}/MAKEcmake.LOG make
75
76 check_jb tar xfz ${SOURCE_DIR}/VTK-4.2.6.tar.gz -C ${INSTALL_WORK}
77 cd ${PRODUCT_WORK}
78
79 # apply a small patch for VTK (needed for gcc-3.4)
80 sed -e "s%seekg(self->GetFile()->tellg()%seekg(static_cast<long>(self->GetFile()->tellg())%g" IO/vtkBMPReader.cxx > IO/vtkBMPReader.cxx.orig
81 mv -f IO/vtkBMPReader.cxx.orig IO/vtkBMPReader.cxx
82 sed -e "s%seekg(self->GetFile()->tellg()%seekg(static_cast<long>(self->GetFile()->tellg())%g" IO/vtkImageReader.cxx > IO/vtkImageReader.cxx.orig
83 mv -f IO/vtkImageReader.cxx.orig IO/vtkImageReader.cxx
84
85 # get Python and tcl/tk version
86 python_version="`python -c 'import sys; print sys.version[:3]'`"
87 tcl_version="`find ${TCLHOME}/lib -name 'libtcl*.so' | awk '/libtcl[0-9.]+.so/ { print $0}' | sed -e 's%^.*libtcl\([0-9\.]*\)\.so%\1%'`"
88     
89 VTK_CMAKE_OPTIONS=""
90 ### common VTK settings
91 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DBUILD_SHARED_LIBS:BOOL=ON"
92 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_BUILD_TYPE:STRING=Release"
93 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_CXX_COMPILER:STRING=`which g++`"
94 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_C_COMPILER:STRING=`which gcc`"
95 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_INSTALL_PREFIX:STRING=${PRODUCT_DIR}"
96 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_HYBRID:BOOL=ON"
97 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_PARALLEL:BOOL=ON"
98 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_PATENTED:BOOL=OFF" 
99 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_RENDERING:BOOL=ON"
100 ### Wrap Python settings
101 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_WRAP_PYTHON:BOOL=ON"
102 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DPYTHON_EXECUTABLE:STRING=${PYTHONHOME}/bin/python${python_version}"
103 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DPYTHON_INCLUDE_PATH:STRING=${PYTHONHOME}/include/python${python_version}"
104 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DPYTHON_LIBRARY:STRING=${PYTHONHOME}/lib/python${python_version}/config/libpython${python_version}.a"
105 ### Wrap Tcl settings
106 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_WRAP_TCL:BOOL=ON"
107 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_INCLUDE_PATH:STRING=${TCLHOME}/include"
108 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_LIBRARY:STRING=${TCLHOME}/lib/libtcl${tcl_version}.so"
109 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_STUB_LIBRARY:STRING=${TCLHOME}/lib/libtclstub${tcl_version}.a"
110 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_TCLSH:STRING=${TCLHOME}/bin/tclsh"
111 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_INCLUDE_PATH:STRING=${TCLHOME}/include"
112 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_LIBRARY:STRING=${TCLHOME}/lib/libtk${tcl_version}.so"
113 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_STUB_LIBRARY:STRING=${TCLHOME}/lib/libtkstub${tcl_version}.a"
114 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_WISH:STRING=${TCLHOME}/bin/wish"
115 ### if Mesa is pre-installed
116 if [ -n "$MESA_HOME" ]; then
117   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_INCLUDE_DIR:STRING=${MESA_HOME}/include"
118   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_gl_LIBRARY:STRING=${MESA_HOME}/lib/libGL.so"
119   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_glu_LIBRARY:STRING=${MESA_HOME}/lib/libGLU.so"
120   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_xmesa_INCLUDE_DIR:STRING=${MESA_HOME}/include"
121 fi
122
123 cat > ${PRODUCT_DIR}/CONFIGURE.LOG <<EOF
124 used VTK settings:
125 $VTK_CMAKE_OPTIONS
126 EOF
127 check_job ${PRODUCT_DIR}/CONFIGURE.LOG ${INSTALL_WORK}/cmake-1.6.6/Source/cmake . $VTK_CMAKE_OPTIONS
128
129 cat > ${PRODUCT_DIR}/MAKE.LOG <<EOF
130 used gcc=$GCC
131 EOF
132 check_job ${PRODUCT_DIR}/MAKE.LOG make
133
134 check_job ${PRODUCT_DIR}/INSTALL.LOG make install
135
136 cd ${PRODUCT_WORK}/Wrapping/Python
137 check_job ${PRODUCT_DIR}/SETUPPYTHON.LOG python setup.py install --prefix=${PRODUCT_DIR}
138
139 rm -fr ${PRODUCT_WORK} ${INSTALL_WORK}/cmake-1.6.6
140
141 # set correct symbolic links - bug of python wrappings installation
142 cd ${PRODUCT_DIR}/lib/python${python_version}/site-packages/vtk_python
143 ln -sf ../../../vtk/*Python*.so .
144
145 #du -sk ${PRODUCT_WORK} > ${PRODUCT_DIR}/size.log
146 rm -fr ${PRODUCT_WORK}
147 print_env
148 }
149
150 install_binary()
151 {
152 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
153 source ${INSTALL_WORK}/$SHRC
154
155 if [ -n "$MESA_HOME" ]; then
156   check_jb tar xfz ${SOURCE_DIR}/VTK-4.2.6-with-Mesa.tar.gz -C ${INSTALL_ROOT}
157 else
158   check_jb tar xfz ${SOURCE_DIR}/VTK-4.2.6.tar.gz -C ${INSTALL_ROOT}
159 fi
160
161 print_env
162 }
163
164 export PROCEDURE=$1;
165 export INSTALL_WORK=$2;
166 export SOURCE_DIR=$3;
167 export INSTALL_ROOT=$4;
168 export PRODUCT_SEQUENCE=$5;
169 if [ $# == 6 ] ; then export PRODUCT_TYPE=$6 ; else export PRODUCT_TYPE="vtk" ; fi
170 export PRODUCT="VTK-4.2.6"
171 export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT}
172 export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT}
173 source ./common.sh
174 $PROCEDURE