Salome HOME
Rollback products: qt -> 4.4.3, sip -> 4.7.7, PyQt -> 4.4.3, qwt -> 5.1.1, QScintilla...
[tools/install.git] / config_files / build.sh
index c6fd4dd7825e472aa8176429e2701481b4358a8f..56f8c5a74fed84bd4eedd63ae458286d2e2ffbf0 100755 (executable)
@@ -6,7 +6,7 @@
 #  Author    : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
 #  Project   : SALOME
 #  Module    : Installation Wizard
-#  Copyright : 2002-2007 CEA
+#  Copyright : 2002-2008 CEA
 #
 #  This script is the part of the SALOME installation procedure.
 #
@@ -38,12 +38,12 @@ usage(){
     echo ""
     echo "-c          Perform configure command for all given modules. Default is off."
     echo ""
-    echo "-w          Add --without-ihm key to build_configure and configure"
-    echo "            commands for MED module to build its sources without GUI."
-    echo "            By default MED sources are built with GUI."
+    echo "-w          Add --without-gui key to build_configure and configure commands"
+    echo "            to build SALOME module sources without GUI."
+    echo "            By default sources are built with GUI."
     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 "-d          Delete build directories before calling configure, to force full"
+    echo "            rebuild and reinstall of the module."
     echo "            Use this option carefully."
     echo ""
     echo "-o          Build sources in optimized mode. Default is off that means"
@@ -56,9 +56,6 @@ usage(){
     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 <prefix> Define the directory where to install modules after compilation."
     echo "            By default the directory where compilation is performed is used."
     echo ""
@@ -72,7 +69,7 @@ usage(){
     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 "            ./build.csh -o -p /home/user/salome -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"
@@ -83,29 +80,28 @@ usage(){
 
 is_build_configure=0
 is_configure=0
-med_with_gui=1
+inst_with_gui=1
 is_delete=0
 verbose_level=2
 params=""
-b_params=""
-modules="KERNEL GUI GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN BLSURFPLUGIN HexoticPLUGIN GHS3DPRLPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT SIERPINSKY RANDOMIZER FILTER YACS MULTIPR"
+modules="KERNEL GUI GEOM MED SMESH VISU YACS NETGENPLUGIN GHS3DPLUGIN BLSURFPLUGIN HexoticPLUGIN GHS3DPRLPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT PYLIGHT SIERPINSKY RANDOMIZER"
 optim=""
-is_install=0
+is_install=1
 is_tui=0
 prefix=""
+def_install_dir="/INSTALL"
 
 #########################################################
 # parse parameters
 #########################################################
-while getopts ":hbcwdoitv:p:" option ; do
+while getopts ":hbcwdotv:p:" option ; do
     case $option in
         h ) usage ;;
         b ) is_build_configure=1 ; is_configure=1 ;;
         c ) is_configure=1 ;;
-        w ) med_with_gui=0 ;;
+        w ) inst_with_gui=0 ;;
         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 ;;
@@ -115,17 +111,19 @@ done
 # shift to have the good number of other args
 shift $((OPTIND - 1))
 
+b_params=""
+
 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"
+    if [ $known -eq 0 ] ; then
        echo
-       echo '!!! Warning !!! Unknown module: '$arg'. Skipping.'
+       echo '!!! Warning !!! Unknown module: '$arg'.'
+       b_params="$b_params $arg"
+    else
+       params="$params $arg"
     fi
 done
 
@@ -139,19 +137,19 @@ if [ "${params}" != "" ] ; then
        for p in $params ; do
            if [ "$p" == "$module" ] ; then found=1 ; break ; fi
        done
-       if [ $found -eq 1 ] ; then xparams="$xparams $module" ; fi
+       if [ $found -eq 1 ] ; then 
+           xparams="$xparams $module"
+       fi
     done
-    modules="$xparams"
+    modules="$xparams $b_params"
 elif [ "${b_params}" != "" ] ; then
-    echo
-    echo "Nothing to be built. Exiting."
-    echo
-    exit 1
+    modules="$b_params"
 fi
 
 echo
-echo ">>> The following SALOME packages will be built:"
+echo ">>> The following modules will be built:"
 echo $modules
+echo
 
 #########################################################
 # set environment
@@ -160,6 +158,9 @@ 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
+    env_script=`dirname $0`/env.sh
+fi
 if [ -e $env_script ] ; then
     echo
     echo ">>> Setting environment"
@@ -167,7 +168,7 @@ if [ -e $env_script ] ; then
 else
     echo
     echo '!!! Warning !!! Environment is not set.'
-    echo 'Neither env_build.sh nor env_products.sh file is found.'
+    echo 'No environment file (env_build.sh, env_products.sh, env.sh) is found.'
     echo 'Proceed with the current environment.'
 fi
 
@@ -178,17 +179,9 @@ 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
+    echo
+    echo '!!! Warning !!! Installation directory is not set.'
+    echo "All the modules will be installed to the ${BUILD_DIR}${def_install_dir}"
 else
     if [ "`echo $prefix | grep -E '^/'`" == "" ] ; then
        prefix=${BUILD_DIR}/$prefix
@@ -221,7 +214,6 @@ for module in ${modules}; do
     module_build=${BUILD_DIR}/${module}_BUILD
     
     if [ "${module_src}" != "" ] ; then
-       add_keys=""
        cd ${BUILD_DIR}
         #########################################################
         # check if sources directory exists
@@ -255,11 +247,12 @@ for module in ${modules}; do
                #########################################################
                 # call build_configure
                #########################################################
-               if [ $med_with_gui -eq 0 ] && [ ${module} == "MED" ] ; then
-                   add_keys="--without-ihm"
+               mybuildconf_keys="${BUILDCONF_OPTS}"
+               if [ $inst_with_gui -eq 0 ] ; then
+                   mybuildconf_keys="${mybuildconf_keys} --without-gui"
                fi
                cd ${module_src}
-               ./build_configure ${add_keys} >& ${LOG_DIR}/build_configure_${module}.log
+               ./build_configure ${mybuildconf_keys} >& ${LOG_DIR}/build_configure_${module}.log
                #########################################################
                # echo possible errors
                #########################################################
@@ -273,13 +266,24 @@ for module in ${modules}; do
         #########################################################
        if [ -e ${module_build} ] && [ $is_delete -eq 1 ] ; then
            echo "... Removing ${module_build}"
-           rm -rf ${module_build}
+           chmod -R +w ${module_build} && rm -rf ${module_build} >& /dev/null
+           if [ "$?" != "0" ] ; then
+               echo
+               echo '!!! Warning !!! Cannot remove build directory ${module_build}. Permission denied.'
+               echo
+           fi
        fi
         #########################################################
         # creating build directory if it does not exist
         #########################################################
        if [ ! -e ${module_build} ] ; then
-           mkdir -p ${module_build}
+           mkdir -p ${module_build} >& /dev/null
+           if [ "$?" != "0" ] ; then
+               echo
+               echo '!!! Error !!! Cannot create build directory ${module_build}. Permission denied.'
+               echo
+               continue
+           fi
        fi
        cd ${module_build}
         #########################################################
@@ -306,19 +310,26 @@ for module in ${modules}; do
         # 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}
+       if [ -e ${module_src}/configure.ac ] ; then
+           vx=`grep -e "^AC_INIT" ${module_src}/configure.ac | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
+       elif [ -e ${module_src}/configure.in.base ] ; then
+           vx=`grep -e "^VERSION=" ${module_src}/configure.in.base | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
+           if [ "$vx" == "" ] ; then
+               vx=`grep -e "^AC_INIT" ${module_src}/configure.in.base | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
+           fi
        fi
        if [ "$vx" != "" ] ; then
-           px="$px"_"$vx"
+           vx="_$vx"
+       fi
+       if [ "$prefix" == "" ] ; then
+           #module_root_dir=`printenv ${module}_ROOT_DIR`
+           #if [ "$module_root_dir" != "" ] ; then
+           #    px=$module_root_dir
+           #else
+               px=${BUILD_DIR}${def_install_dir}/${module}${vx}
+           #fi
+       else
+           px=$prefix/${module}${vx}
        fi
         #########################################################
         # perform configure if -c flag is given or if 
@@ -334,16 +345,17 @@ for module in ${modules}; do
                echo '!!! Warning !!! Can not find configure script in '${module_src}'.'
                echo
            else
-               if [ $med_with_gui -eq 0 ] && [ "${module}" == "MED" ] ; then
-                   add_keys="--without-ihm"
+               myconf_keys="${CONF_OPTS}"
+               if [ $inst_with_gui -eq 0 ] ; then
+                   myconf_keys="${myconf_keys} --without-gui"
                fi
-               if [  "${module}" == "MED" ] && [ "${METISDIR}" != "" ] && [ "${SCOTCHDIR}" != "" ] ; then
-                   add_keys="--enable-splitter=yes --with-metis=${METISDIR} --with-scotch=${SCOTCHDIR}"
+               if [ "${module}" == "MED" ] && [ "${METISDIR}" != "" ] && [ "${SCOTCHDIR}" != "" ] ; then
+                   myconf_keys="${myconf_keys} --enable-splitter=yes --with-metis=${METISDIR} --with-scotch=${SCOTCHDIR}"
                fi
                if [ "${module}" == "NETGENPLUGIN" ] && [ "$NETGENHOME" != "" ] ; then
-                   add_keys="--with-netgen=${NETGENHOME}"
+                   myconf_keys="${myconf_keys} --with-netgen=${NETGENHOME}"
                fi
-               ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
+               ${module_src}/configure --prefix=$px ${optim} ${myconf_keys} >& ${LOG_DIR}/configure_${module}.log
                #########################################################
                # echo possible errors
                #########################################################
@@ -369,13 +381,13 @@ for module in ${modules}; do
         # if make step is successful set the ${module}_ROOT_DIR
         # environment variable
         #########################################################
-        if [ $sts -eq 0 ] ; then
-           export ${module}_ROOT_DIR=${module_build}
-       fi
+        #if [ $sts -eq 0 ] ; then
+       #    export ${module}_ROOT_DIR=${module_build}
+       #fi
         #########################################################
         # print make errors
         #########################################################
-       cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]' >&2
+       cat ${LOG_DIR}/make_${module}.log | grep -Ei '[*][*][*].*error' >&2
         #########################################################
         # print compiler errors and warnings
         # Note: here awk is used to concatenate together several lines of single
@@ -384,10 +396,10 @@ for module in ${modules}; do
         #########################################################
        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/"@@ >&2
+           cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {print $0} END {print ""}' | grep "${module_src}/[A-Za-z_0-9./]*:" | sed s@"^${module_src}/src/"@@ >&2
        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/"@@ >&2
+           cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {print $0} END {print ""}' | grep -E ": warning|* Warning" | sed s@"^${module_src}/src/"@@ >&2
        fi
         #########################################################
         # perform make dev_docs step if -t flag is given
@@ -411,7 +423,12 @@ for module in ${modules}; do
            #########################################################
            if [ -e $px ] && [ $is_delete -eq 1 ] ; then
                echo "... Removing $px"
-               rm -rf $px
+               rm -rf $px >& /dev/null
+               if [ "$?" != "0" ] ; then
+                   echo
+                   echo '!!! Warning !!! Cannot remove install directory ${px}. Permission denied.'
+                   echo
+               fi
            fi
            echo "... Performing make install"
            make install >& ${LOG_DIR}/make_install_${module}.log