]> SALOME platform Git repositories - tools/install.git/blob - config_files/VTK-4.2.6.sh
Salome HOME
Remove HappyDoc dependencies
[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=""
88 tcl_includes=""
89 tcl_libs=""
90 tcldir="`where_tcl`"
91 if [ $? -eq 0 ] && [ -e ${tcldir}/tclConfig.sh ] ; then
92     tcl_version=`grep -e "TCL_VERSION=.*" ${tcldir}/tclConfig.sh | sed -e "s%TCL_VERSION=[\'|\"]\(.*\)[\'|\"]%\1%g"`
93     tcl_includes=`grep -e "TCL_INCLUDE_SPEC=.*" ${tcldir}/tclConfig.sh | sed -e "s%TCL_INCLUDE_SPEC=[\'|\"]-I\(.*\)[\'|\"]%\1%g"`
94     if [ -z "$tcl_includes" ] ; then tcl_includes=/usr/include ; fi
95     tcl_libs=`grep -e "TCL_PACKAGE_PATH=.*" ${tcldir}/tclConfig.sh | sed -e "s%TCL_PACKAGE_PATH=[\'|\"]\(.*\)[\'|\"]%\1%g"`
96 fi
97     
98 VTK_CMAKE_OPTIONS=""
99 ### common VTK settings
100 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DBUILD_SHARED_LIBS:BOOL=ON"
101 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_BUILD_TYPE:STRING=Release"
102 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_CXX_COMPILER:STRING=`which g++`"
103 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_C_COMPILER:STRING=`which gcc`"
104 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DCMAKE_INSTALL_PREFIX:STRING=${PRODUCT_DIR}"
105 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_HYBRID:BOOL=ON"
106 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_PARALLEL:BOOL=ON"
107 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_PATENTED:BOOL=OFF" 
108 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_USE_RENDERING:BOOL=ON"
109 ### Wrap Python settings
110 if [ "${python_version}" != "" ]; then
111 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_WRAP_PYTHON:BOOL=ON"
112 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DPYTHON_EXECUTABLE:STRING=${PYTHONHOME}/bin/python${python_version}"
113 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DPYTHON_INCLUDE_PATH:STRING=${PYTHONHOME}/include/python${python_version}"
114 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DPYTHON_LIBRARY:STRING=${PYTHONHOME}/lib/python${python_version}/config/libpython${python_version}.a"
115 fi
116 ### Wrap Tcl settings
117 if [ "${tcl_version}" != "" ] && [ "${tcl_includes}" != "" ] && [ "${tcl_libs}" != "" ] ; then
118 # suppose that tcl and tk are installed in the same dir
119 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DVTK_WRAP_TCL:BOOL=ON"
120 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_INCLUDE_PATH:STRING=${tcl_includes}"
121 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_LIBRARY:STRING=${tcl_libs}/libtcl${tcl_version}.so"
122 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_STUB_LIBRARY:STRING=${tcl_libs}/libtclstub${tcl_version}.a"
123 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTCL_TCLSH:STRING=${TCLHOME}/bin/tclsh${tcl_version}"
124 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_INCLUDE_PATH:STRING=${tcl_includes}"
125 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_LIBRARY:STRING=${tcl_libs}/libtk${tcl_version}.so"
126 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_STUB_LIBRARY:STRING=${tcl_libs}/libtkstub${tcl_version}.a"
127 VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DTK_WISH:STRING=${TCLHOME}/bin/wish${tcl_version}"
128 fi
129 ### if Mesa is pre-installed
130 if [ -n "$MESA_HOME" ]; then
131   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_INCLUDE_DIR:STRING=${MESA_HOME}/include"
132   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_gl_LIBRARY:STRING=${MESA_HOME}/lib/libGL.so"
133   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_glu_LIBRARY:STRING=${MESA_HOME}/lib/libGLU.so"
134   VTK_CMAKE_OPTIONS=$VTK_CMAKE_OPTIONS" -DOPENGL_xmesa_INCLUDE_DIR:STRING=${MESA_HOME}/include"
135 fi
136
137 cat > ${PRODUCT_DIR}/CONFIGURE.LOG <<EOF
138 used VTK settings:
139 $VTK_CMAKE_OPTIONS
140 EOF
141 check_job ${PRODUCT_DIR}/CONFIGURE.LOG ${INSTALL_WORK}/cmake-1.6.6/Source/cmake . $VTK_CMAKE_OPTIONS
142
143 cat > ${PRODUCT_DIR}/MAKE.LOG <<EOF
144 used gcc=$GCC
145 EOF
146 check_job ${PRODUCT_DIR}/MAKE.LOG make
147
148 check_job ${PRODUCT_DIR}/MAKEINSTALL.LOG make install
149
150 cd ${PRODUCT_WORK}/Wrapping/Python
151 check_job ${PRODUCT_DIR}/SETUPPYTHON.LOG python setup.py install --prefix=${PRODUCT_DIR}
152
153 #du -sk ${PRODUCT_WORK} > ${PRODUCT_DIR}/size.log
154 #du -sk ${INSTALL_WORK}/cmake-1.6.6 >> ${PRODUCT_DIR}/size.log
155 cd ${PRODUCT_DIR}; rm -fr ${PRODUCT_WORK} ${INSTALL_WORK}/cmake-1.6.6
156
157 # set correct symbolic links - bug of python wrappings installation
158 cd ${PRODUCT_DIR}/lib/python${python_version}/site-packages/vtk_python
159 ln -sf ../../../vtk/*Python*.so .
160
161 print_env
162 }
163
164 install_binary()
165 {
166 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
167 source ${INSTALL_WORK}/$SHRC
168
169 if [ -n "$MESA_HOME" ]; then
170   check_jb tar xfz ${SOURCE_DIR}/VTK-4.2.6-with-Mesa.tar.gz -C ${INSTALL_ROOT}
171 else
172   check_jb tar xfz ${SOURCE_DIR}/VTK-4.2.6.tar.gz -C ${INSTALL_ROOT}
173 fi
174
175 print_env
176 }
177
178 export PROCEDURE=$1;
179 export INSTALL_WORK=$2;
180 export SOURCE_DIR=$3;
181 export INSTALL_ROOT=$4;
182 export PRODUCT_SEQUENCE=$5;
183 if [ $# == 6 ] ; then export PRODUCT_TYPE=$6 ; else export PRODUCT_TYPE="vtk" ; fi
184 export PRODUCT="VTK-4.2.6"
185 export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT}
186 export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT}
187 source ./common.sh
188 $PROCEDURE