Salome HOME
Fix pb with Hexotic environment
[tools/install.git] / config_files / build.csh
index ec0b9c0e05cb41f6723997226eb9300a147a1a1d..10437d3456c96f49c76cd9ee03f1adc430dbee4e 100755 (executable)
@@ -6,7 +6,7 @@
 #  Author    : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
 #  Project   : SALOME
 #  Module    : Installation Wizard
-#  Copyright : 2002-2006 CEA
+#  Copyright : 2002-2008 CEA
 #
 #  This script is the part of the SALOME installation procedure.
 #
 
 set is_build_configure=0
 set is_configure=0
+set inst_with_gui=1
 set is_delete=0
 set verbose_level=2
 set params=""
-set b_params=""
-set modules=(KERNEL GUI GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT)
+set modules=(KERNEL GUI GEOM MED SMESH VISU PARAVIS YACS NETGENPLUGIN GHS3DPLUGIN BLSURFPLUGIN HexoticPLUGIN GHS3DPRLPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT PYLIGHT SIERPINSKY RANDOMIZER HEXABLOCK HEXABLOCKPLUGIN ATOMIC ATOMGEN ATOMSOLV HOMARD JOBMANAGER)
 set optim=""
-set is_install=0
+set is_install=1
 set is_help=0
 set is_tui=0
 set prefix=""
+set def_install_dir="/INSTALL"
+set b_params=""
 
 #########################################################
 # parse parameters
@@ -37,12 +39,12 @@ while ( ${%1} > 0 )
        set is_configure=1
     else if ( "$1" == "-c" ) then
        set is_configure=1
+    else if ( "$1" == "-w" ) then
+       set inst_with_gui=0
     else if ( "$1" == "-d" ) then
        set is_delete=1
     else if ( "$1" == "-o" ) then
        set optim="--enable-production=yes --disable-debug"
-    else if ( "$1" == "-i" ) then
-       set is_install=1
     else if ( "$1" == "-v" ) then
        shift
        set verbose_level=$1
@@ -55,12 +57,12 @@ while ( ${%1} > 0 )
     else if ( "$1" == "-t" ) then
        set is_tui=1
     else
-       set ckt=`echo ${modules} | grep $1`
+       set ckt=`echo ${modules} | grep -E "\<$1\>"`
        if ( "$ckt" != "" ) then
            set params="$params $1"
        else
            set b_params="$b_params $1"
-           echo "\!\!\! Warning \!\!\! Unknown module: $1. Skipping."
+           echo "\!\!\! Warning \!\!\! Unknown module: $1."
        endif
     endif
     shift
@@ -73,7 +75,7 @@ if ( $is_help == 1 ) then
 echo ""
 echo ""
 echo "Description:"
-echo "            Builds given SALOME modules by performing make and (optionally) make install commands"
+echo "            Builds given SALOME modules by performing make and make install commands"
 echo ""
 echo "Usage:"
 echo "            build.csh [ <option> ] ... [ <module> [ <module> ... ] ]"
@@ -89,8 +91,12 @@ echo "            This option forces configure (-c) key to be set. Default is of
 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 rebuild"
-echo "            (and reinstall if -i or -p option is used) of module."
+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 force full rebuild"
+echo "            and reinstall of the module."
 echo "            Use this option carefully."
 echo ""
 echo "-o          Build sources in optimized mode. Default is off that means debug mode."
@@ -101,8 +107,6 @@ echo ""
 echo "-t          Performs make dev_docs step to build TUI documentation for those modules"
 echo "            which support this. Default is off."
 echo ""
-echo "-i          Performs make install step. Default is off that means only make 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 ""
@@ -116,7 +120,7 @@ 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 "            ./build.csh -o -p /home/user/salome -b KERNEL MED GEOM"
 echo ""
 echo "            This will make KERNEL, GEOM and MED modules: build_configure, configure, make"
 echo "            and install procedures will be performed for all specified modules."
@@ -131,20 +135,17 @@ endif
 if ( "${params}" != "" ) then
     set xparams=""
     foreach module (${modules})
-       set ckt=`echo ${params} | grep ${module}`
+       set ckt=`echo ${params} | grep -E "\<${module}\>"`
        if ( "$ckt" != "" ) then
            set xparams="$xparams $module"
        endif
     end
-    set modules=($xparams)
-else
-    if ( "${b_params}" != "" ) then
-       echo "Nothing to be built. Exiting."
-       exit
-    endif
+    set modules=($xparams $b_params)
+else if ( "${b_params}" != "" ) then
+    set modules=($b_params)
 endif
 
-echo ">>> The following SALOME packages will be built:"
+echo ">>> The following modules will be built:"
 echo $modules
 
 #########################################################
@@ -154,11 +155,16 @@ set env_script=`dirname $0`/env_build.csh
 if ( ! -e $env_script ) then
     set env_script=`dirname $0`/env_products.csh
 endif
+if ( ! -e $env_script ) then
+    set env_script=`dirname $0`/env.sh
+endif
 if ( -e $env_script ) then
     echo ">>> Setting environment"
     source $env_script
 else
-    echo "\!\!\! Warning \!\!\! Environment is not set: file env_products.csh is not found."
+    echo "\!\!\! Warning \!\!\! Environment is not set."
+    echo "No environment file (env_build.sh, env_products.sh, env.sh) is found."
+    echo "Proceed with the current environment."
 endif
 
 set BUILD_DIR=${PWD}
@@ -168,18 +174,8 @@ set LOG_DIR=${BUILD_DIR}/LOGS
 # define installation prefix
 #########################################################
 if ( "$prefix" == "" ) then
-    set prefix=${BUILD_DIR}/INSTALL
-    if ( $is_install == 1 ) then
-       echo "\!\!\! Warning \!\!\! Installation directory is not set."
-       echo "All the modules will be installed to the $prefix"
-    else
-       set is_kernel=`echo ${modules} | grep KERNEL`
-       if ( "$is_kernel" != "" ) then
-           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"
-       endif
-    endif
+    echo "\!\!\! Warning \!\!\! Installation directory is not set."
+    echo "All the modules will be installed to the ${BUILD_DIR}${def_install_dir}"
 else
     set is_absolute=`echo $prefix | grep -e "^/"`
     if ( "$is_absolute" == "" ) then
@@ -210,7 +206,6 @@ foreach module (${modules})
   set module_build=${BUILD_DIR}/${module}_BUILD
 
   if ( ${module_src} != "" ) then
-    set add_keys=""
     cd ${BUILD_DIR}
     #########################################################
     # check if sources directory exists
@@ -235,34 +230,53 @@ foreach module (${modules})
        #########################################################
        # check if build_configure script exists
        #########################################################
-       if ( ! -e ${module_src}/build_configure ) then
+       if ( ! -e ${module_src}/build_configure && "${module}" != "PARAVIS" ) then
            echo "\!\!\! Warning \!\!\! Can not find build_configure script in ${module_src}."
-       else
+           else
+           if ( "${module}" == "PARAVIS" ) then
+           echo "\!\!\! Warning \!\!\! build_configure step is not executed for ${module}."
+               else
            #########################################################
            # call build_configure
            #########################################################
+           if (! ($?BUILDCONF_OPTS) ) then
+           set mybuildconf_keys=""
+           else
+           set mybuildconf_keys="${BUILDCONF_OPTS}"
+           endif    
+           if ( $inst_with_gui == 0 ) then
+               set mybuildconf_keys="${mybuildconf_keys} --without-gui"
+           endif
            cd ${module_src}
-           ./build_configure >& ${LOG_DIR}/build_configure_${module}.log
+           ./build_configure ${mybuildconf_keys} >& ${LOG_DIR}/build_configure_${module}.log
            #########################################################
            # echo possible errors
            #########################################################
            if ( $verbose_level > 0 ) then
-               cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" > /dev/stderr
+               cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" >/dev/stderr
            endif
        endif
+       endif
     endif
     #########################################################
     # deleting build directory if -d flag is given
     #########################################################
     if ( -e ${module_build} && $is_delete == 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 "\!\!\! Warning \!\!\! Cannot remove build directory ${module_build}. Permission denied."
+       endif
     endif
     #########################################################
     # 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 "\!\!\! Error \!\!\! Cannot create build directory ${module_build}. Permission denied."
+           continue
+       endif
     endif
     cd ${module_build}
     #########################################################
@@ -289,19 +303,31 @@ foreach module (${modules})
     # number); default is a build directory
     #########################################################
     set vx=""
-    set cfg_file=configure.ac
-    if ( ! -e ${module_src}/${cfg_file} ) then
-       set cfg_file=configure.in.base
-    endif
-    if ( -e ${module_src}/${cfg_file} ) then
-       set vx=`grep -e "^VERSION=" ${module_src}/${cfg_file} | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
-    endif
-    set px=${BUILD_DIR}/${module}
-    if ( "$prefix" != "" ) then
-       set px=$prefix/${module}
+    if ( -e ${module_src}/configure.ac ) then
+       set vx=`grep -e "^AC_INIT" ${module_src}/configure.ac | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
+    else if ( -e ${module_src}/configure.in.base ) then
+       set vx=`grep -e "^VERSION=" ${module_src}/configure.in.base | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
+       if ( "$vx" == "" ) then
+           set vx=`grep -e "^AC_INIT" ${module_src}/configure.in.base | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
+       endif
+    else if ( -e ${module_src}/CMakeLists.txt ) then
+           set ver_maj=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MAJOR | sed -e "s%[A-Z_() ]%%g"`
+           set ver_min=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MINOR | sed -e "s%[A-Z_() ]%%g"`
+           set ver_maintenance=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MAINTENANCE | sed -e "s%[A-Z_() ]%%g"`
+           set vx="${ver_maj}.${ver_min}.${ver_maintenance}"
     endif
     if ( "$vx" != "" ) then
-       set px="$px"_"$vx"
+        set vx="_$vx"
+    endif
+    if ( "$prefix" == "" ) then
+        #set module_root_dir=`printenv ${module}_ROOT_DIR`
+       #if ( "$module_root_dir" != "" ) then
+       #    set px=$module_root_dir
+       #else
+            set px=${BUILD_DIR}${def_install_dir}/${module}${vx}
+       #endif
+    else
+       set px=${prefix}/${module}${vx}
     endif
     #########################################################
     # perform configure if -c flag is given or if 
@@ -312,21 +338,36 @@ foreach module (${modules})
        #########################################################
        # check if configure script exists
        #########################################################
-       if ( ! -e ${module_src}/configure ) then
+       if ( ! -e ${module_src}/configure  && "${module}" != "PARAVIS" ) then
            echo "\!\!\! Warning \!\!\! Can not find configure script in ${module_src}."
        else
-           if (  "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
-               set add_keys="--with-netgen=${NETGENHOME}"
+           if (! ($?BUILDCONF_OPTS) ) then
+           set myconf_keys=""
+           else
+           set myconf_keys="${CONF_OPTS}"
+           endif
+           if ( $inst_with_gui == 0 ) then
+               set myconf_keys="${myconf_keys} --without-gui"
+           endif
+           if ( "${module}" == "MED" && ($?METISDIR) && ($?SCOTCHDIR) ) then
+               set myconf_keys="${myconf_keys} --enable-splitter=yes --with-metis=${METISDIR} --with-scotch=${SCOTCHDIR}"
            endif
-           ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
+           if ( "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
+               set myconf_keys="${myconf_keys} --with-netgen=${NETGENHOME}"
+           endif
+               if ( "${module}" == "PARAVIS" )  then
+                   cd ${module_build}; cmake ${module_src} -DCMAKE_INSTALL_PREFIX=$px >& ${LOG_DIR}/configure_${module}.log
+               else
+                   ${module_src}/configure --prefix=$px ${optim} ${myconf_keys} >& ${LOG_DIR}/configure_${module}.log
+               endif
            #########################################################
            # echo possible errors
            #########################################################
            if ( $verbose_level > 0 ) then
-               cat ${LOG_DIR}/configure_${module}.log | grep ": error:" > /dev/stderr
+               cat ${LOG_DIR}/configure_${module}.log | grep ": error:" >/dev/stderr
            endif
            if ( $verbose_level > 1 ) then
-               cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" > /dev/stderr
+               cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" >/dev/stderr
            endif
        endif
     endif
@@ -344,13 +385,13 @@ foreach module (${modules})
     # if make step is successful set the ${module}_ROOT_DIR
     # environment variable
     #########################################################
-    if ( $sts == 0 ) then
-       setenv ${module}_ROOT_DIR ${module_build}
-    endif
+    #if ( $sts == 0 ) then
+       setenv ${module}_ROOT_DIR ${module_build}
+    #endif
     #########################################################
     # print make errors
     #########################################################
-    cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]' > /dev/stderr
+    cat ${LOG_DIR}/make_${module}.log | grep -Ei '[*][*][*].*error' >/dev/stderr
     #########################################################
     # print compiler errors and warnings
     # Note: here awk is used to concatenate together several lines of single
@@ -359,10 +400,10 @@ foreach module (${modules})
     #########################################################
     if ( $verbose_level > 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/"@@ > /dev/stderr
+       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/"@@ >/dev/stderr
     endif
     if ( $verbose_level > 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/"@@ > /dev/stderr
+       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/"@@ >/dev/stderr
     endif
     #########################################################
     # perform make dev_docs step if -t flag is given
@@ -373,7 +414,7 @@ foreach module (${modules})
        if ( "$dd" != "" ) then
            echo "... Performing make dev_docs"
            make dev_docs >& ${LOG_DIR}/make_dev_docs_${module}.log
-           cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' > /dev/stderr
+           cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' >/dev/stderr
        endif
     endif
     cd ${module_build}
@@ -386,7 +427,10 @@ foreach module (${modules})
        #########################################################
        if ( -e $px && $is_delete == 1 ) then
            echo "... Removing $px"
-           rm -rf $px
+           rm -rf $px >& /dev/null
+           if ( "$?" != "0" ) then
+               echo "\!\!\! Warning \!\!\! Cannot remove install directory ${px}. Permission denied."
+           endif
        endif
        echo "... Performing make install"
        make install >& ${LOG_DIR}/make_install_${module}.log