]> SALOME platform Git repositories - tools/install.git/blob - config_files/VTK-4.2.6.sh
Salome HOME
1) remove required size calculations for each product: just read its from XML and...
[tools/install.git] / config_files / VTK-4.2.6.sh
1 #!/bin/bash -noprofile
2
3 ####################################################################################
4 #  File      : VTK-4.2.6.sh
5 #  Created   : Thu Dec 18 12:01:00 2002
6 #  Author    : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
7 #  Project   : SALOME
8 #  Module    : Installation Wizard
9 #  Copyright : 2002-2007 CEA
10 #
11 #  This script is the part of the SALOME installation procedure.
12 #
13 ####################################################################################
14
15 check_version()
16 {
17 if [ -z "$VTKHOME" ]; then
18    return 1 
19 fi
20 check_lib_version libvtkCommon.so ${VTKHOME}/lib/vtk
21 if [ "$?" -eq "0" ]; then
22    return 0
23 fi
24 return 1
25 }
26
27 print_env_bin()
28 {
29 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
30 #$DELIM ${PRODUCT_TYPE} $DELIM
31 export VTKHOME=\${INSTALL_ROOT}/${PRODUCT}
32 export PATH=\${VTKHOME}/bin:\${PATH}
33 export LD_LIBRARY_PATH=\${VTKHOME}/lib/vtk:\${LD_LIBRARY_PATH}
34 export PYTHONPATH=\${VTKHOME}/lib/vtk:\${VTKHOME}/lib/python\${PYTHON_VERSION}/site-packages/vtk_python:\${PYTHONPATH}
35 export TCLLIBPATH="\${VTKHOME}/lib/vtk/tcl \${TCLLIBPATH}"
36 ##
37 EOF
38 (test -w ${PRODUCT_DIR} && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh ${PRODUCT_DIR})
39 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}"
40 }
41
42 print_env_src()
43 {
44 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}_src.sh <<EOF
45 #$DELIM ${PRODUCT_TYPE}_src $DELIM
46 # nothing to do
47 ##
48 EOF
49 (test -w ${PRODUCT_DIR}_SRC && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}_src.sh ${PRODUCT_DIR}_SRC)
50 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}"
51 }
52
53 try_preinstalled(){
54 try_existing ${PRODUCT_DIR} ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}" ${PRODUCT_TYPE}
55 try_existing ${PRODUCT_DIR}_SRC ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}" ${PRODUCT_TYPE}_src
56 return $?
57 }
58
59 install_source()
60 {
61 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}" ${PRODUCT_TYPE}_src
62 source ${INSTALL_WORK}/$SHRC
63
64 makedir ${PRODUCT_DIR}_SRC
65
66 check_jb tar xfz ${SOURCE_DIR}/cmake-1.6.6.tar.gz -C ${PRODUCT_DIR}_SRC
67 check_jb tar xfz ${SOURCE_DIR}/${PRODUCT}.tar.gz -C ${PRODUCT_DIR}_SRC
68
69 # apply patches for 64-bit platforms
70 if test `uname -m` = "x86_64" ; then
71     if [ -f patches/cmake-1.6.6-lib64.patch ] ; then
72         cp patches/cmake-1.6.6-lib64.patch ${PRODUCT_DIR}_SRC/cmake-1.6.6_SRC
73         ( cd ${PRODUCT_DIR}_SRC/cmake-1.6.6_SRC ; patch -p1 < cmake-1.6.6-lib64.patch )
74     fi
75     if [ -f patches/vtk-4.2.6-lib64.patch ] ; then
76         cp patches/vtk-4.2.6-lib64.patch ${PRODUCT_DIR}_SRC/${PRODUCT}_SRC
77         ( cd ${PRODUCT_DIR}_SRC/${PRODUCT}_SRC ; patch -p1 < vtk-4.2.6-lib64.patch )
78     fi
79 fi
80 # apply patch: fix pb with importing Python vtk modules on some platforms
81 if [ -f patches/vtk-4.2.6-patented.patch ] ; then
82     cp patches/vtk-4.2.6-patented.patch ${PRODUCT_DIR}_SRC/${PRODUCT}_SRC
83     ( cd ${PRODUCT_DIR}_SRC/${PRODUCT}_SRC ; patch -p1 < vtk-4.2.6-patented.patch )
84 fi
85
86 # to generate environment scripts
87 try_preinstalled
88 }
89
90 install_source_and_build()
91 {
92 # install sources
93 install_source
94
95 # build sources
96 makedir ${PRODUCT_DIR}
97
98 cd ${PRODUCT_DIR}_SRC/cmake-1.6.6_SRC
99
100 check_job ${PRODUCT_DIR}/CONFIGUREcmake.LOG ./configure
101 cat >> ${PRODUCT_DIR}/MAKEcmake.LOG <<EOF
102 used gcc=$GCC
103 EOF
104 check_job ${PRODUCT_DIR}/MAKEcmake.LOG make
105
106 cd ${PRODUCT_DIR}_SRC/${PRODUCT}_SRC
107
108 # apply a small patch for VTK (needed for gcc-3.4)
109 sed -e "s%seekg(self->GetFile()->tellg()%seekg(static_cast<long>(self->GetFile()->tellg())%g" IO/vtkBMPReader.cxx > IO/vtkBMPReader.cxx.orig
110 mv -f IO/vtkBMPReader.cxx.orig IO/vtkBMPReader.cxx
111 sed -e "s%seekg(self->GetFile()->tellg()%seekg(static_cast<long>(self->GetFile()->tellg())%g" IO/vtkImageReader.cxx > IO/vtkImageReader.cxx.orig
112 mv -f IO/vtkImageReader.cxx.orig IO/vtkImageReader.cxx
113
114 # get Python and tcl/tk version
115 python_version="`python -c 'import sys; print sys.version[:3]'`"
116 tcl_version=""
117 tcl_includes=""
118 tcl_libs=""
119 tcldir="`where_tcl`"
120 if [ $? -eq 0 ] && [ -e ${tcldir}/tclConfig.sh ] ; then
121     tcl_version=`grep -e "TCL_VERSION=.*" ${tcldir}/tclConfig.sh | sed -e "s%TCL_VERSION=[\'|\"]\(.*\)[\'|\"]%\1%g"`
122     tcl_includes=`grep -e "TCL_INCLUDE_SPEC=.*" ${tcldir}/tclConfig.sh | sed -e "s%TCL_INCLUDE_SPEC=[\'|\"]-I\(.*\)[\'|\"]%\1%g"`
123     if [ -z "$tcl_includes" ] ; then tcl_includes=/usr/include ; fi
124     tcl_libs=`grep -e "TCL_PACKAGE_PATH=.*" ${tcldir}/tclConfig.sh | sed -e "s%TCL_PACKAGE_PATH=[\'|\"]\(.*\)[\'|\"]%\1%g"`
125 fi
126     
127 VTK_CMAKE_OPTIONS=""
128 ### common VTK settings
129 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DBUILD_SHARED_LIBS:BOOL=ON"
130 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_BUILD_TYPE:STRING=Release"
131 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_CXX_COMPILER:STRING=`which g++`"
132 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_C_COMPILER:STRING=`which gcc`"
133 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_INSTALL_PREFIX:STRING=${PRODUCT_DIR}"
134 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_HYBRID:BOOL=ON"
135 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_PARALLEL:BOOL=ON"
136 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_PATENTED:BOOL=OFF" 
137 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_RENDERING:BOOL=ON"
138   if test `uname -m` = "x86_64" ; then
139 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_CXX_FLAGS:STRING=-m64"
140 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_C_FLAGS:STRING=-m64"
141   fi
142
143 ### Wrap Python settings
144 if [ "${python_version}" != "" ]; then
145 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_WRAP_PYTHON:BOOL=ON"
146 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DPYTHON_EXECUTABLE:STRING=${PYTHONHOME}/bin/python${python_version}"
147 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DPYTHON_INCLUDE_PATH:STRING=${PYTHONHOME}/include/python${python_version}"
148 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DPYTHON_LIBRARY:STRING=${PYTHONHOME}/lib/python${python_version}/config/libpython${python_version}.a"
149 fi
150 ### Wrap Tcl settings
151 if [ "${tcl_version}" != "" ] && [ "${tcl_includes}" != "" ] && [ "${tcl_libs}" != "" ] ; then
152 # suppose that tcl and tk are installed in the same dir
153 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_WRAP_TCL:BOOL=ON"
154 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_INCLUDE_PATH:STRING=${tcl_includes}"
155 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_LIBRARY:STRING=${tcl_libs}/libtcl${tcl_version}.so"
156 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_STUB_LIBRARY:STRING=${tcl_libs}/libtclstub${tcl_version}.a"
157 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_TCLSH:STRING=${TCLHOME}/bin/tclsh${tcl_version}"
158 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_INCLUDE_PATH:STRING=${tcl_includes}"
159 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_LIBRARY:STRING=${tcl_libs}/libtk${tcl_version}.so"
160 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_STUB_LIBRARY:STRING=${tcl_libs}/libtkstub${tcl_version}.a"
161 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_WISH:STRING=${TCLHOME}/bin/wish${tcl_version}"
162 fi
163 ### if Mesa is pre-installed
164 if [ -n "$MESA_HOME" ]; then
165   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_INCLUDE_DIR:STRING=${MESA_HOME}/include"
166   if test `uname -m` = "x86_64" ; then
167       VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_gl_LIBRARY:STRING=${MESA_HOME}/lib64/libGL.so"
168       VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_glu_LIBRARY:STRING=${MESA_HOME}/lib64/libGLU.so"
169   else
170       VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_gl_LIBRARY:STRING=${MESA_HOME}/lib/libGL.so"
171       VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_glu_LIBRARY:STRING=${MESA_HOME}/lib/libGLU.so"
172   fi
173   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_xmesa_INCLUDE_DIR:STRING=${MESA_HOME}/include"
174 fi
175
176 cat > ${PRODUCT_DIR}/CONFIGURE.LOG <<EOF
177 used VTK settings:
178 $VTK_CMAKE_OPTIONS
179 EOF
180 check_job ${PRODUCT_DIR}/CONFIGURE.LOG ${PRODUCT_DIR}_SRC/cmake-1.6.6_SRC/Source/cmake . $VTK_CMAKE_OPTIONS
181
182 cat > ${PRODUCT_DIR}/MAKE.LOG <<EOF
183 used gcc=$GCC
184 EOF
185 check_job ${PRODUCT_DIR}/MAKE.LOG make
186
187 check_job ${PRODUCT_DIR}/MAKEINSTALL.LOG make install
188
189 cd ${PRODUCT_DIR}_SRC/${PRODUCT}_SRC/Wrapping/Python
190
191 check_job ${PRODUCT_DIR}/SETUPPYTHON.LOG python setup.py install --prefix=${PRODUCT_DIR}
192
193 # set correct symbolic links - bug of python wrappings installation
194   if test `uname -m` = "x86_64" ; then
195       cd ${PRODUCT_DIR}/lib64/python${python_version}/site-packages/vtk_python
196   else
197       cd ${PRODUCT_DIR}/lib/python${python_version}/site-packages/vtk_python
198   fi
199   ln -sf ../../../vtk/*Python*.so .
200
201   if test `uname -m` = "x86_64" ; then
202       cd ${PRODUCT_DIR}; ln -s lib64 lib
203   fi
204
205 #du -sk ${PRODUCT_DIR}_SRC > ${PRODUCT_DIR}/size.log
206 cd ${PRODUCT_DIR};
207
208 # remove sources and temporary files after building
209 if [ ${REMOVE_SRC_TMP} == "TRUE" ] ; then
210     test -d ${PRODUCT_DIR}_SRC && rm -fr ${PRODUCT_DIR}_SRC
211 fi
212
213 # to generate environment scripts
214 try_preinstalled
215 }
216
217 install_binary()
218 {
219 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}" ${PRODUCT_TYPE}
220 source ${INSTALL_WORK}/$SHRC
221
222 if [ -n "$MESA_HOME" ]; then
223   check_jb tar xfz ${SOURCE_DIR}/${PRODUCT}_with_Mesa.tar.gz -C ${INSTALL_ROOT}
224 else
225   check_jb tar xfz ${SOURCE_DIR}/${PRODUCT}.tar.gz -C ${INSTALL_ROOT}
226 fi
227
228 # to generate environment script for sources
229 try_preinstalled
230 }
231
232 export PROCEDURE=$1;
233 export INSTALL_WORK=$2;
234 export SOURCE_DIR=$3;
235 export INSTALL_ROOT=$4;
236 export PRODUCT_SEQUENCE=$5;
237 export PRODUCT_TYPE=$6;
238 export INSTALL_PRODUCTS=$7;
239 shift
240 REMOVE_SRC_TMP=$8;
241 export PRODUCT="VTK-4.2.6"
242 export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT}
243 export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT}
244 source ./common.sh
245 $PROCEDURE