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)
8 # Module : Installation Wizard
9 # Copyright : 2002-2007 CEA
11 # This script is the part of the SALOME installation procedure.
13 ####################################################################################
17 if [ -z "$PYTHONHOME" ]; then
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
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
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}
45 (test -w ${PRODUCT_DIR} && cp ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh ${PRODUCT_DIR})
46 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
49 # looks for the native product and collects it's environment (used by make_env())
51 pythonhome="`find_in_path python ${PATH}`"
52 if [ -z "${pythonhome}" ] ; then
53 pythonhome="`find_in_path python /usr/bin`"
55 if [ -n "${pythonhome}" ] ; then
56 pythonhome=`cd ${pythonhome}/..; pwd`
57 # get version number: <major>, <minor> and <release>
58 # <major> and <minor> numbers are checked strickly, but <release> number can be larger than required one
59 # version number is calculated as: <major>*10000+<minor>*100+<release>
60 # for Python 2.4.1 it is equal to 20401
62 maj_ver=`echo $ver | awk '{print $2}' | awk -F. '{if(NF>0) print $1; else print 0}'`
63 min_ver=`echo $ver | awk '{print $2}' | awk -F. '{if(NF>1) print $2; else print 0}'`
64 rel_ver=`echo $ver | awk '{print $2}' | awk -F. '{if(NF>2) print $3; else print 0}'`
65 let ver=$maj_ver*10000+$min_ver*100+$rel_ver
66 if [ $ver -ge 20401 ] ; then
67 tmp="\${PYTHONHOME}/bin ${pythonhome}/bin \${PATH} ${PATH}";
68 path=`sort_path ${tmp}`
69 tmp="\${PYTHONHOME}/lib/python\${PYTHON_VERSION} ${pythonhome}/lib/python${maj_ver}.${min_ver} \${PYTHONPATH} ${PYTHONPATH}";
70 pythonpath=`sort_path ${tmp}`
71 tmp="\${PYTHONHOME}/lib ${pythonhome}/lib \${LD_LIBRARY_PATH} ${LD_LIBRARY_PATH}";
72 ld_library_path=`sort_path ${tmp}`
73 cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh <<EOF
74 #$DELIM ${PRODUCT_TYPE} $DELIM
75 export PYTHONHOME=${pythonhome}
77 export LD_LIBRARY_PATH=${ld_library_path}
78 export PYTHON_VERSION=\`python -c "import sys; print sys.version[:3]"\`
79 export PYTHON_INCLUDE=\${PYTHONHOME}/include/python\${PYTHON_VERSION}
80 export PYTHONPATH=${pythonpath}
83 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}"
84 ####### THIS COULD BE USED FOR STRICT COMPARISON ##############################
85 # if [ $maj_ver -eq 2 ] && [ $min_ver -eq 4 ] && [ $rel_ver -eq 1 ] ; then
86 ######################################################################################
87 if [ $maj_ver -eq 2 ] && [ $min_ver -eq 4 ] && [ $rel_ver -ge 1 ] ; then
98 try_existing ${PRODUCT_DIR} ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
104 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
105 source ${INSTALL_WORK}/$SHRC
107 makedir ${PRODUCT_DIR}
109 if test `uname -m` = "x86_64" ; then
110 export PYTHON_ARCHIVE_PREFIX="-lib64"
111 export PYTHON_LIB_PREFIX="64"
114 PYTHON_CONFIGURE_OPTIONS="--with-threads --with-cxx=`which g++` --enable-shared CFLAGS=-m64 CXXFLAGS=-m64"
116 export PYTHON_ARCHIVE_PREFIX=""
117 PYTHON_CONFIGURE_OPTIONS="--with-threads --with-cxx=`which g++` --enable-shared"
120 check_jb tar xfz ${SOURCE_DIR}/Python-2.4.1${PYTHON_ARCHIVE_PREFIX}.tar.gz -C ${INSTALL_WORK}
122 # apply patch for 64-bit platforms
123 if test `uname -m` = "x86_64" ; then
124 if [ -f patches/Python-2.4.1-lib64.patch ] ; then
125 cp patches/Python-2.4.1-lib64.patch ${PRODUCT_WORK}
126 ( cd ${PRODUCT_WORK} ; \
127 patch -p1 < Python-2.4.1-lib64.patch ; \
128 rm -rf aclocal.m4 ; \
129 aclocal >& /dev/null ; \
130 autoconf >& /dev/null ; \
131 aclocal >& /dev/null ; \
132 autoconf >& /dev/null )
138 check_job ${PRODUCT_DIR}/CONFIGURE.LOG \
139 ./configure --prefix=${PRODUCT_DIR} $PYTHON_CONFIGURE_OPTIONS
141 # vsr: force linking to libstdc++.so
142 sed -e 's%\(^LIBS=.*\)%\1 -lstdc++%g' Makefile > _Makefile
143 mv -f _Makefile Makefile
145 cat >> ${PRODUCT_DIR}/MAKE.LOG <<EOF
148 check_job ${PRODUCT_DIR}/MAKE.LOG make
149 check_job ${PRODUCT_DIR}/MAKINSTALL.LOG make install
150 (cd ${PRODUCT_DIR}/lib${PYTHON_LIB_PREFIX}/python2.4/config; ln -fs ../../libpython2.4.so.1.0 libpython2.4.so)
152 cd ${PRODUCT_DIR}/bin
153 for sc in idle pydoc smtpd.py ; do
155 sed -e "s%#\!.*python%#\!/usr/bin/env python%" "$sc" > _"$sc"
161 if test `uname -m` = "x86_64" ; then
162 ( cd ${PRODUCT_DIR}; ln -sf lib64 lib )
165 #du -sk ${PRODUCT_WORK} > ${PRODUCT_DIR}/size.log
166 cd ${PRODUCT_DIR}; rm -fr ${PRODUCT_WORK}
172 make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE}
173 source ${INSTALL_WORK}/$SHRC
175 check_jb tar xfz ${SOURCE_DIR}/Python-2.4.1.tar.gz -C ${INSTALL_ROOT}
177 (cd ${PRODUCT_DIR}/lib/python2.4/config; ln -fs ../../libpython2.4.so.1.0 libpython2.4.so)
179 cd ${PRODUCT_DIR}/bin
180 for sc in idle pydoc smtpd.py ; do
182 sed -e "s%#\!.*python%#\!/usr/bin/env python%" "$sc" > _"$sc"
192 export INSTALL_WORK=$2;
193 export SOURCE_DIR=$3;
194 export INSTALL_ROOT=$4;
195 export PRODUCT_SEQUENCE=$5;
196 if [ $# == 6 ] ; then export PRODUCT_TYPE=$6 ; else export PRODUCT_TYPE="python" ; fi
197 export PRODUCT="Python-2.4.1"
198 export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT}
199 export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT}