]> SALOME platform Git repositories - tools/install.git/blob - config_files/Python-2.4.1.sh
Salome HOME
1) remove required size calculations for each product: just read its from XML and...
[tools/install.git] / config_files / Python-2.4.1.sh
1 #!/bin/bash -noprofile
2
3 ####################################################################################
4 #  File      : Python-2.4.1.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 "$PYTHONHOME"  ]; then
18    return 1
19 fi
20 isPython=`which python 2>/dev/null`
21 if [ -n "$isPython" ]; then
22   # version number is calculated as: <major>*10000+<minor>*100+<release>
23   # for Python 2.4.1 it is equal to 20401
24   ver=`python -V 2>&1`
25   ver=`echo $ver | awk '{print $2}' | awk -F. '{v1=0;v2=0;v3=0;if(NF>0)v1=$1;if(NF>1)v2=$2;if(NF>2)v3=$3;print v1*10000+v2*100+v3}'`
26   if [ $ver -eq 20401 ] ;  then 
27     return 0
28   fi
29 fi
30 return 1 
31 }
32
33 print_env_bin()
34 {
35 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF 
36 #$DELIM ${PRODUCT_TYPE} $DELIM
37 export PYTHONHOME=\${INSTALL_ROOT}/${PRODUCT}
38 export PATH=\${PYTHONHOME}/bin:\${PATH}
39 export LD_LIBRARY_PATH=\${PYTHONHOME}/lib:\${LD_LIBRARY_PATH}
40 export PYTHON_VERSION=\`python -c "import sys; print sys.version[:3]"\`
41 export PYTHON_INCLUDE=\${PYTHONHOME}/include/python\${PYTHON_VERSION}
42 export PYTHONPATH=\${PYTHONHOME}/lib/python\${PYTHON_VERSION}:\${PYTHONPATH}
43 ##
44 EOF
45 (test -w ${PRODUCT_DIR} && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh ${PRODUCT_DIR})
46 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}"
47 }
48
49 print_env_src()
50 {
51 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}_src.sh <<EOF
52 #$DELIM ${PRODUCT_TYPE}_src $DELIM
53 # nothing to do
54 ##
55 EOF
56 (test -w ${PRODUCT_DIR}_SRC && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}_src.sh ${PRODUCT_DIR}_SRC)
57 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}"
58 }
59
60 try_preinstalled(){
61 try_existing ${PRODUCT_DIR} ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}" ${PRODUCT_TYPE}
62 try_existing ${PRODUCT_DIR}_SRC ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}" ${PRODUCT_TYPE}_src
63 return $?
64 }
65
66 install_source()
67 {
68 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}" ${PRODUCT_TYPE}_src
69 source ${INSTALL_WORK}/$SHRC
70
71 if test `uname -m` = "x86_64" ; then
72     export PYTHON_ARCHIVE_PREFIX="-lib64"
73     export PYTHON_LIB_PREFIX="64"
74     export CFLAGS=-m64
75     export CXXFLAGS=-m64
76     PYTHON_CONFIGURE_OPTIONS="--with-threads --with-cxx=`which g++` --enable-shared CFLAGS=-m64 CXXFLAGS=-m64"
77 else
78     export PYTHON_ARCHIVE_PREFIX=""
79     PYTHON_CONFIGURE_OPTIONS="--with-threads --with-cxx=`which g++` --enable-shared"
80 fi
81
82 check_jb tar xfz ${SOURCE_DIR}/${PRODUCT}${PYTHON_ARCHIVE_PREFIX}.tar.gz -C ${INSTALL_ROOT}
83
84 # apply patch for 64-bit platforms
85 if test `uname -m` = "x86_64" ; then
86     if [ -f patches/Python-2.4.1-lib64.patch ] ; then
87         cp patches/Python-2.4.1-lib64.patch ${PRODUCT_DIR}_SRC 
88         ( cd ${PRODUCT_DIR}_SRC ;                \
89           patch -p1 < Python-2.4.1-lib64.patch ; \
90           rm -rf aclocal.m4 ;                    \
91           aclocal >& /dev/null ;                 \
92           autoconf >& /dev/null ;                \
93           aclocal >& /dev/null ;                 \
94           autoconf >& /dev/null )
95     fi
96 fi
97
98 # to generate environment scripts
99 try_preinstalled
100 }
101
102 install_source_and_build()
103 {
104 # install sources
105 install_source
106
107 # build sources
108 makedir ${PRODUCT_DIR}
109 cd ${PRODUCT_DIR}_SRC
110
111 check_job ${PRODUCT_DIR}/CONFIGURE.LOG \
112     ./configure --prefix=${PRODUCT_DIR} $PYTHON_CONFIGURE_OPTIONS
113
114 # vsr: force linking to libstdc++.so
115 sed -e 's%\(^LIBS=.*\)%\1 -lstdc++%g' Makefile > _Makefile
116 mv -f _Makefile Makefile
117 GCC=`which gcc`
118 cat >> ${PRODUCT_DIR}/MAKE.LOG <<EOF
119 used gcc=$GCC
120 EOF
121 check_job ${PRODUCT_DIR}/MAKE.LOG make 
122 check_job ${PRODUCT_DIR}/MAKINSTALL.LOG make install
123 (cd ${PRODUCT_DIR}/lib${PYTHON_LIB_PREFIX}/python2.4/config; ln -fs ../../libpython2.4.so.1.0 libpython2.4.so)
124
125 cd ${PRODUCT_DIR}/bin
126 for sc in idle pydoc smtpd.py ; do
127     if [ -e $sc ] ; then
128         sed -e "s%#\!.*python%#\!/usr/bin/env python%" "$sc" > _"$sc"
129         mv -f _"$sc" "$sc"
130         chmod a+x "$sc"
131     fi
132 done
133
134 if test `uname -m` = "x86_64" ; then
135     ( cd ${PRODUCT_DIR}; ln -sf lib64 lib )
136 fi
137
138 #du -sk ${PRODUCT_DIR}_SRC > ${PRODUCT_DIR}/size.log
139 cd ${PRODUCT_DIR};
140
141 # remove sources and temporary files after building
142 if [ ${REMOVE_SRC_TMP} == "TRUE" ] ; then
143     test -d ${PRODUCT_DIR}_SRC && rm -fr ${PRODUCT_DIR}_SRC
144 fi
145
146 # to generate environment scripts
147 try_preinstalled
148 }
149
150 install_binary()
151 {
152 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" "${INSTALL_PRODUCTS}" ${PRODUCT_TYPE}
153 source ${INSTALL_WORK}/$SHRC
154
155 check_jb tar xfz ${SOURCE_DIR}/${PRODUCT}.tar.gz -C ${INSTALL_ROOT}
156
157 (cd ${PRODUCT_DIR}/lib/python2.4/config; ln -fs ../../libpython2.4.so.1.0 libpython2.4.so)
158
159 cd ${PRODUCT_DIR}/bin
160 for sc in idle pydoc smtpd.py ; do
161     if [ -e $sc ] ; then
162         sed -e "s%#\!.*python%#\!/usr/bin/env python%" "$sc" > _"$sc"
163         mv -f _"$sc" "$sc"
164         chmod a+x "$sc"
165     fi
166 done
167
168 # to generate environment scripts
169 try_preinstalled
170 }
171
172 export PROCEDURE=$1;
173 export INSTALL_WORK=$2;
174 export SOURCE_DIR=$3;
175 export INSTALL_ROOT=$4;
176 export PRODUCT_SEQUENCE=$5;
177 export PRODUCT_TYPE=$6;
178 export INSTALL_PRODUCTS=$7;
179 shift
180 REMOVE_SRC_TMP=$8;
181 export PRODUCT="Python-2.4.1"
182 export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT}
183 export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT}
184 source ./common.sh
185 ${PROCEDURE}