From: vsr Date: Mon, 25 Dec 2006 13:35:50 +0000 (+0000) Subject: Implement features: X-Git-Tag: V_3_2_4~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b77362690a460e431b4e4032bcdc5d47215f3f3a;p=tools%2Finstall.git Implement features: - install and build SALOME module sources - install all products from sources --- diff --git a/config_files/CALCULATOR_BIN.sh b/config_files/CALCULATOR_BIN.sh index e758e0c..f9d13b8 100755 --- a/config_files/CALCULATOR_BIN.sh +++ b/config_files/CALCULATOR_BIN.sh @@ -12,12 +12,14 @@ # #################################################################################### +VERSION="3.2.4" + check_version(){ if [ -n "${CALCULATOR_ROOT_DIR}" ]; then check_lib_version VERSION ${CALCULATOR_ROOT_DIR}/bin/salome if [ "$?" -eq "0" ]; then ver=`cat ${CALCULATOR_ROOT_DIR}/bin/salome/VERSION | awk -F: '{print $2}' | tr -d '[:space:]' ` - if [ "$ver" = "3.2.4" ]; then + if [ "$ver" = "${VERSION}" ]; then return 0 fi fi @@ -91,7 +93,7 @@ install_binary() make_env ${INSTALL_ROOT} ${INSTALL_WORK} "${PRODUCT_SEQUENCE}" ${PRODUCT_TYPE} source ${INSTALL_WORK}/$SHRC -check_jb tar xfz ${SOURCE_DIR}/CALCULATORbinariesV3.2.4.tar.gz -C ${INSTALL_ROOT} +check_jb tar xfz ${SOURCE_DIR}/CALCULATORbinariesV${VERSION}.tar.gz -C ${INSTALL_ROOT} # modify all *.la files export CALCULATOR_ROOT_DIR=${PRODUCT_DIR} @@ -111,8 +113,8 @@ export INSTALL_WORK=$2; export SOURCE_DIR=$3; export INSTALL_ROOT=$4; export PRODUCT_SEQUENCE=$5; -if [ $# == 6 ] ; then export PRODUCT_TYPE=$6 ; else export PRODUCT_TYPE="CalculatorBin" ; fi -export PRODUCT="CALCULATOR_3.2.4" +if [ $# == 6 ] ; then export PRODUCT_TYPE=$6 ; else export PRODUCT_TYPE="CALCULATORbin" ; fi +export PRODUCT="CALCULATOR_${VERSION}" export PRODUCT_DIR=${INSTALL_ROOT}/${PRODUCT} export PRODUCT_WORK=${INSTALL_WORK}/${PRODUCT} source ./common.sh diff --git a/config_files/CALCULATOR_SRC.sh b/config_files/CALCULATOR_SRC.sh index 68c1275..0aa49ac 100755 --- a/config_files/CALCULATOR_SRC.sh +++ b/config_files/CALCULATOR_SRC.sh @@ -12,12 +12,13 @@ # #################################################################################### +VERSION="3.2.4" + check_version(){ if [ -n "${CALCULATOR_SRC_DIR}" ]; then - check_lib_version VERSION ${CALCULATOR_SRC_DIR}/bin - if [ "$?" -eq "0" ]; then - ver=`cat ${CALCULATOR_SRC_DIR}/bin/VERSION | awk -F: '{print $2}' | tr -d '[:space:]' ` - if [ "$ver" = "3.2.4" ]; then + if [ -f ${CALCULATOR_SRC_DIR}/configure.in.base ]; then + ver=`grep -E "^VERSION=" ${CALCULATOR_SRC_DIR}/configure.in.base | awk -F= '{print $NF}' | tr -d '[:space:]' ` + if [ "$ver" = "${VERSION}" ]; then return 0 fi fi @@ -31,6 +32,7 @@ cat > ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ${INSTALL_WORK}/env_${PRODUCT_TYPE}.sh < ] ... [ [ ... ] ]" + echo "" + echo " Modules to build, separated by space(s)." + echo " If no modules are given - all SALOME modules are assumed." + echo " Note, that modules given in command lines are automatically" + echo " sorted in such order to support correct modules dependencies." + echo "" + echo "Options:" + echo "-b Perform build_configure command for all given modules." + echo " This option forces configure (-c) key to be set. Default is off." + echo "" + echo "-c Perform configure command for all given modules. Default is off." + echo "" + echo "-d Delete build directories before calling configure, to enforce full" + echo " rebuild (and reinstall if -i or -p option is used) of module." + echo " Use this option carefully." + echo "" + echo "-o Build sources in optimized mode. Default is off that means" + echo " debug mode." + echo " Use this option together with -c or -b." + echo " This option can require -d option to be set (to ensure that" + echo " previously created build directories are removed to enforce" + echo " rebuild in optimized mode)." + echo "" + echo "-t Performs make dev_docs step to build TUI documentation for those" + echo " modules which support this. Default is off." + echo "" + echo "-i Performs make install step. Default is off that means only make" + echo " step." + echo "" + echo "-p Define the directory where to install modules after compilation." + echo " By default the directory where compilation is performed is used." + echo "" + echo "-v Verbose level (0-2, default 2): print information on build status:" + echo " 0: only 'make' errors" + echo " 1: 0 + compiler and other errors (build_configure, configure)" + echo " 2: 1 + compiler and other warnings " + echo "" + echo "-h Prints this help information." + echo "" + echo "Note: If no keys are given script just performs make step." + echo "" + echo "Example:" + echo " ./build.csh -o -i -b KERNEL MED GEOM" + echo "" + echo " This will make KERNEL, GEOM and MED modules: build_configure," + echo " configure, make and install procedures will be performed for all" + echo " specified modules. The modules will be built in the optimized mode." + echo "" + exit 1 +} + +is_build_configure=0 +is_configure=0 +is_delete=0 +verbose_level=2 +params="" +b_params="" +modules="KERNEL GUI GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT" +optim="" +is_install=0 +is_tui=0 +prefix="" + +######################################################### +# parse parameters +######################################################### +while getopts ":hbcdoitv:p:" option ; do + case $option in + h ) usage ;; + b ) is_build_configure=1 ; is_configure=1 ;; + c ) is_configure=1 ;; + d ) is_delete=1 ;; + o ) optim="--enable-production=yes --disable-debug" ;; + i ) is_install=1 ;; + t ) is_tui=1 ;; + v ) verbose_level=$OPTARG ;; + p ) is_install=1 ; prefix=$OPTARG ;; + ? ) usage ;; + esac +done +# shift to have the good number of other args +shift $((OPTIND - 1)) + +for arg in $@ ; do + known=0 + for m in $modules ; do + if [ "$m" == "$arg" ] ; then known=1 ; break ; fi + done + if [ $known -eq 1 ] ; then + params="$params $arg" + else + b_params="$b_params $arg" + echo + echo '!!! Warning !!! Unknown module: '$arg'. Skipping.' + fi +done + +######################################################### +# sort modules in proper order according to the dependancies +######################################################### +if [ "${params}" != "" ] ; then + xparams="" + for module in ${modules} ; do + found=0 + for p in $params ; do + if [ "$p" == "$module" ] ; then found=1 ; break ; fi + done + if [ $found -eq 1 ] ; then xparams="$xparams $module" ; fi + done + modules="$xparams" +elif [ "${b_params}" != "" ] ; then + echo + echo "Nothing to be built. Exiting." + echo + exit 1 +fi + +echo +echo ">>> The following SALOME packages will be built:" +echo $modules + +######################################################### +# set environment +######################################################### +env_script=`dirname $0`/env_build.sh +if [ ! -e $env_script ] ; then + env_script=`dirname $0`/env_products.sh +fi +if [ -e $env_script ] ; then + echo + echo ">>> Setting environment" + source $env_script +else + echo + echo '!!! Warning !!! Environment is not set.' + echo 'Neither env_build.sh nor env_products.sh file is found.' + echo 'Proceed with the current environment.' +fi + +BUILD_DIR=${PWD} +LOG_DIR=${BUILD_DIR}/LOGS + +######################################################### +# define installation prefix +######################################################### +if [ "$prefix" == "" ] ; then + prefix=${BUILD_DIR}/INSTALL + if [ $is_install -eq 1 ] ; then + echo + echo '!!! Warning !!! Installation directory is not set.' + echo "All the modules will be installed to the $prefix" + elif [ "`echo ${modules} | grep KERNEL`" != "" ] ; then + echo + echo '!!! Warning !!! KERNEL module requires install step to be performed.' + echo "For this module -i option will be forced." + echo "The module(s) will be installed to the $prefix" + fi +else + if [ "`echo $prefix | grep -E '^/'`" == "" ] ; then + prefix=${BUILD_DIR}/$prefix + echo + echo '!!! Warning !!! Relative prefix is used.' + echo "All the modules will be installed to the $prefix." + fi +fi + +######################################################### +# create log directory +######################################################### +if [ ! -e ${LOG_DIR} ] ; then + mkdir -p ${LOG_DIR} +fi + +echo +echo "===========================================================================" +echo "Starting SALOME build at `date`" +echo "===========================================================================" +echo + +######################################################### +# loop for all given modules +######################################################### +for module in ${modules}; do + echo ">>> Processing ${module} module" + + module_src=`printenv ${module}_SRC_DIR` + module_build=${BUILD_DIR}/${module}_BUILD + + if [ "${module_src}" != "" ] ; then + add_keys="" + cd ${BUILD_DIR} + ######################################################### + # check if sources directory exists + ######################################################### + if [ ! -e ${module_src} ] ; then + echo + echo '!!! Error !!! Cannot find module sources directory:' + echo "${module_src} does not exist." + echo + continue + fi + ######################################################### + # check if configure script exists + ######################################################### + cfg_exist=0 + if [ -e ${module_src}/configure ] ; then + cfg_exist=1 + fi + ######################################################### + # perform build_configure if -b flag is given or if + # configure script does not exist (first compilation?) + ######################################################### + if [ $is_build_configure -eq 1 ] || [ $cfg_exist -eq 0 ] ; then + echo "... Performing build_configure" + ######################################################### + # check if build_configure script exists + ######################################################### + if [ ! -e ${module_src}/build_configure ] ; then + echo '!!! Warning !!! Cannot find build_configure script in '${module_src}'.' + else + ######################################################### + # call build_configure + ######################################################### + cd ${module_src} + ./build_configure >& ${LOG_DIR}/build_configure_${module}.log + ######################################################### + # echo possible errors + ######################################################### + if [ $verbose_level -gt 0 ] ; then + cat ${LOG_DIR}/build_configure_${module}.log | grep ": error:" + fi + fi + fi + ######################################################### + # deleting build directory if -d flag is given + ######################################################### + if [ -e ${module_build} ] && [ $is_delete -eq 1 ] ; then + echo "... Removing ${module_build}" + rm -rf ${module_build} + fi + ######################################################### + # creating build directory if it does not exist + ######################################################### + if [ ! -e ${module_build} ] ; then + mkdir -p ${module_build} + fi + cd ${module_build} + ######################################################### + # check if top Makefile exists in build directory, i.e. + # is it necessary to run configure script + ######################################################### + mkfile_exist=0 + if [ -e ${module_build}/Makefile ] ; then + mkfile_exist=1 + fi + ######################################################### + # check if configure options are changed from the + # previous launch + ######################################################### + opts_changed=0 +## if [ -f ${module_build}/config.log ] ; then +## old_prefix=`grep -e '^prefix=' ${module_build}/config.log | sed -e "s%^prefix='\(.*\)'%\1%"` +## if [ "$old_prefix" != "$prefix" ] ; then +## opts_changed=1 +## fi +## fi + ######################################################### + # define installation directory (by using module's version + # number); default is a build directory + ######################################################### + vx="" + cfg_file=configure.ac + if [ ! -e ${module_src}/${cfg_file} ] ; then + cfg_file=configure.in.base + fi + if [ -e ${module_src}/${cfg_file} ] ; then + vx=`grep -e "^VERSION=" ${module_src}/${cfg_file} | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'` + fi + px=${BUILD_DIR}/${module} + if [ "$prefix" != "" ] ; then + px=$prefix/${module} + fi + if [ "$vx" != "" ] ; then + px="$px"_"$vx" + fi + ######################################################### + # perform configure if -c flag is given or if + # Makefile does not exist (first compilation?) + ######################################################### + if [ $is_configure -eq 1 ] || [ $mkfile_exist -eq 0 ] || [ $opts_changed -eq 1 ] ; then + echo "... Performing configure" + ######################################################### + # check if configure script exists + ######################################################### + if [ ! -e ${module_src}/configure ] ; then + echo + echo '!!! Warning !!! Can not find configure script in '${module_src}'.' + echo + else + if [ "${module}" == "NETGENPLUGIN" ] && [ "$NETGENHOME" != "" ] ; then + add_keys="--with-netgen=${NETGENHOME}" + fi + ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log + ######################################################### + # echo possible errors + ######################################################### + if [ $verbose_level -gt 0 ] ; then + cat ${LOG_DIR}/configure_${module}.log | grep ": error:" + fi + if [ $verbose_level -gt 1 ] ; then + cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" + fi + fi + fi + ######################################################### + # perform make + ######################################################### + echo "... Performing make" + ######################################################### + # first clear dependencies + ######################################################### + find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null + make >& ${LOG_DIR}/make_${module}.log + sts=$? + ######################################################### + # if make step is successful set the ${module}_ROOT_DIR + # environment variable + ######################################################### + if [ $sts -eq 0 ] ; then + export ${module}_ROOT_DIR=${module_build} + fi + ######################################################### + # print make errors + ######################################################### + cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]' + ######################################################### + # print compiler errors and warnings + # Note: here awk is used to concatenate together several lines of single + # error or warning message produced by stupid gnu compiler + # Actually, instead of that we could use 'fmessage length=n' option of g++... + ######################################################### + if [ $verbose_level -gt 0 ] ; then + ###cat ${LOG_DIR}/make_${module}.log | grep ": error" + cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {printf $0} END {print ""}' | grep "${module_src}/[A-Za-z_0-9./]*:" | sed s@"^${module_src}/src/"@@ + fi + if [ $verbose_level -gt 1 ] ; then + cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {printf $0} END {print ""}' | grep ": warning" | sed s@"^${module_src}/src/"@@ + fi + ######################################################### + # perform make dev_docs step if -t flag is given + ######################################################### + if [ $is_tui -eq 1 ] && [ $sts -eq 0 ] && [ -d ${module_build}/doc ] ; then + cd ${module_build}/doc + dd=`cat Makefile | grep -E "dev_docs[[:space:]]*:"` + if [ "$dd" != "" ] ; then + echo "... Performing make dev_docs" + make dev_docs >& ${LOG_DIR}/make_dev_docs_${module}.log + fi + fi + cd ${module_build} + ######################################################### + # perform make if -i or -p flags are given + ######################################################### + if [ $is_install -eq 1 ] && [ $sts -eq 0 ] || [ "${module}" == "KERNEL" ] ; then + echo "... Performing make install" + ######################################################### + # deleting build directory if -d flag is given + ######################################################### + if [ -e $px ] && [ $is_delete -eq 1 ] ; then + echo "... Removing $px" + rm -rf $px + fi + make install >& ${LOG_DIR}/make_install_${module}.log + sts=$? + ######################################################### + # if make install step is successful set the + # ${module}_ROOT_DIR environment variable + ######################################################### + if [ $sts -eq 0 ] ; then + export ${module}_ROOT_DIR=$px + fi + fi + echo ">>> Finished ${module} module" + else + echo + echo '!!! Error !!! Cannot find module sources. '${module}'_SRC_DIR environment variable is not set.' + echo + fi +done +######################################################### +# finalize +######################################################### +cd ${BUILD_DIR} + +echo +echo "===========================================================================" +echo "SALOME build finished at `date`" +echo "===========================================================================" +echo diff --git a/config_files/common.sh b/config_files/common.sh index e4c88fb..ca95141 100755 --- a/config_files/common.sh +++ b/config_files/common.sh @@ -76,6 +76,7 @@ make_env() { install_root=$1; shift install_work=$1; + for i in $SHRC $CSHRC ; do if [ -e ${install_work}/$i ]; then rm ${install_work}/$i @@ -343,10 +344,13 @@ cp -f ${install_work}/_$CSHRC ${install_root}/env_products.csh cp -f ${install_work}/_$SHRC ${install_root}/env_products.sh rm -f ${install_work}/_$SHRC ${install_work}/_$CSHRC -### !!! copying build.csh script +### !!! copying build.csh and build.sh scripts if [ -e ./build.csh ]; then cp -f ./build.csh ${install_root} fi +if [ -e ./build.sh ]; then + cp -f ./build.sh ${install_root} +fi ### !!! copying release notes for p in `ls ../` ; do export pdf=`echo ${p} | sed s/[.]/" "/g | awk '{print $2}'`