Salome HOME
Add RANDOMIZER and SIERPINSKY modules.
[tools/install.git] / config_files / build.csh
index 7b8ea28e53bebd658429a34911aa042f2d829aa4..14b7a64417f96826cb837206b1e7216f4fb149b4 100755 (executable)
@@ -1,13 +1,23 @@
-#! /bin/csh -f
-##################################################################################################
-# Name       : build.csh
-# Description: Build and install SALOME modules from sources
-# Author     : Vadim SANDLER (VSR), Open CASCADE S.A.
-# Created    : 27.01.2005
-##################################################################################################
+#!/bin/csh -f
+
+####################################################################################
+#  File      : build.csh
+#  Created   : Thu Jan 27 09:50:55 2005
+#  Author    : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
+#  Project   : SALOME
+#  Module    : Installation Wizard
+#  Copyright : 2002-2007 CEA
+#
+#  This script is the part of the SALOME installation procedure.
+#
+#  This script can be used to build and install SALOME modules from sources.
+#  Try build.csh -h for more details about usage.
+#
+####################################################################################
 
 set is_build_configure=0
 set is_configure=0
+set med_with_gui=1
 set is_delete=0
 set verbose_level=2
 set params=""
@@ -16,6 +26,7 @@ set modules=(KERNEL GUI GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN COMP
 set optim=""
 set is_install=0
 set is_help=0
+set is_tui=0
 set prefix=""
 
 #########################################################
@@ -27,6 +38,8 @@ while ( ${%1} > 0 )
        set is_configure=1
     else if ( "$1" == "-c" ) then
        set is_configure=1
+    else if ( "$1" == "-w" ) then
+       set med_with_gui=0
     else if ( "$1" == "-d" ) then
        set is_delete=1
     else if ( "$1" == "-o" ) then
@@ -42,13 +55,15 @@ while ( ${%1} > 0 )
        set prefix=$1
     else if ( "$1" == "-h" ) then
        set is_help=1
+    else if ( "$1" == "-t" ) then
+       set is_tui=1
     else
        set ckt=`echo ${modules} | grep $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. Skipping."
        endif
     endif
     shift
@@ -61,13 +76,13 @@ if ( $is_help == 1 ) then
 echo ""
 echo ""
 echo "Description:"
-echo "            Builds given SALOME2 modules by performing make and (optionally) make install commands"
+echo "            Builds given SALOME modules by performing make and (optionally) make install commands"
 echo ""
 echo "Usage:"
 echo "            build.csh [ <option> ] ... [ <module> [ <module> ... ] ]"
 echo ""
 echo "<module>    Modules to build, separated by space(s)."
-echo "            If no modules are given - all SALOME2 modules are assumed."
+echo "            If no modules are given - all SALOME modules are assumed."
 echo "            Note, that modules given in command lines are automatically sorted in such order"
 echo "            to support correct modules dependencies."
 echo ""
@@ -77,6 +92,10 @@ 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 "-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 ""
 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 "            Use this option carefully."
@@ -86,6 +105,9 @@ echo "            Use this option together with -c or -b."
 echo "            This option can require -d option to be set (to ensure that previously"
 echo "            created build directories are removed to enforce rebuild in optimized mode)."
 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."
@@ -129,7 +151,7 @@ else
     endif
 endif
 
-echo "The following SALOME packages will be built:"
+echo ">>> The following SALOME packages will be built:"
 echo $modules
 
 #########################################################
@@ -140,15 +162,40 @@ if ( ! -e $env_script ) then
     set env_script=`dirname $0`/env_products.csh
 endif
 if ( -e $env_script ) then
-    echo "Setting environment"
+    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: file env_products.csh is not found."
 endif
 
 set BUILD_DIR=${PWD}
 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
+else
+    set is_absolute=`echo $prefix | grep -e "^/"`
+    if ( "$is_absolute" == "" ) then
+       set prefix=${BUILD_DIR}/$prefix
+       echo "\!\!\! Warning \!\!\! Relative prefix is used."
+       echo "All the modules will be installed to the $prefix"
+    endif
+endif
+
 #########################################################
 # create log directory
 #########################################################
@@ -158,13 +205,13 @@ endif
 
 echo "==========================================================================="
 echo "Starting SALOME build at `date`"
+echo "==========================================================================="
 
 #########################################################
 # loop for all given modules
 #########################################################
 foreach module (${modules})
-  echo "==========================================================================="
-  echo "Processing ${module} module"
+  echo ">>> Processing ${module} module"
 
   set module_src=`printenv ${module}_SRC_DIR`
   set module_build=${BUILD_DIR}/${module}_BUILD
@@ -176,7 +223,7 @@ foreach module (${modules})
     # check if sources directory exists
     #########################################################
     if ( ! -e ${module_src} ) then
-       echo "Error! Can't find sources directory: ${module_src} does not exist."
+       echo "\!\!\! Error \!\!\! Can't find sources directory: ${module_src} does not exist."
        continue
     endif
     #########################################################
@@ -191,23 +238,26 @@ foreach module (${modules})
     # configure script does not exist (first compilation?)
     #########################################################
     if ( $is_build_configure == 1 || $cfg_exist == 0 ) then
-       echo "------- Build configure ---------"
+       echo "... Performing build_configure"
        #########################################################
        # check if build_configure script exists
        #########################################################
        if ( ! -e ${module_src}/build_configure ) then
-           echo "Warning! Can not find build_configure script in ${module_src}."
+           echo "\!\!\! Warning \!\!\! Can not find build_configure script in ${module_src}."
        else
            #########################################################
            # call build_configure
            #########################################################
+           if ( $med_with_gui == 0 && "${module}" == "MED" ) then
+               set add_keys="--without-ihm"
+           endif
            cd ${module_src}
-           ./build_configure >& ${LOG_DIR}/build_configure_${module}.log
+           ./build_configure ${add_keys} >& ${LOG_DIR}/build_configure_${module}.log
            #########################################################
            # echo possible errors
            #########################################################
            if ( $verbose_level > 0 ) then
-               cat ${LOG_DIR}/build_configure_${module}.log | grep ": error:"
+               cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" >&2
            endif
        endif
     endif
@@ -215,7 +265,7 @@ foreach module (${modules})
     # deleting build directory if -d flag is given
     #########################################################
     if ( -e ${module_build} && $is_delete == 1 ) then
-       echo "Deleting ${module_build}"
+       echo "... Removing ${module_build}"
        rm -rf ${module_build}
     endif
     #########################################################
@@ -233,13 +283,28 @@ foreach module (${modules})
     if ( -e ${module_build}/Makefile ) then
        set mkfile_exist=1
     endif
+    #########################################################
+    # check if configure options are changed from the 
+    # previous launch
+    #########################################################
+    set opts_changed=0
+##    if ( -f ${module_build}/config.log ) then
+##     set old_prefix=`grep -e '^prefix=' ${module_build}/config.log | sed -e "s%^prefix='\(.*\)'%\1%"`
+##     if ( "$old_prefix" != "$prefix" ) then
+##         set opts_changed=1
+##     endif
+##    endif
     #########################################################
     # define installation directory (by using module's version
     # number); default is a build directory
     #########################################################
     set vx=""
-    if ( -e ${module_src}/bin/VERSION ) then
-       set vx=`awk -F: '{ if (NF > 1) print $NF; }' ${module_src}/bin/VERSION | tr -d '[:space:]'`
+    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
@@ -252,15 +317,18 @@ foreach module (${modules})
     # perform configure if -c flag is given or if 
     # Makefile does not exist (first compilation?)
     #########################################################
-    if ( $is_configure == 1 || $mkfile_exist == 0) then
-       echo "------- Configure ---------------"
+    if ( $is_configure == 1 || $mkfile_exist == 0 || $opts_changed == 1 ) then
+       echo "... Performing configure"
        #########################################################
        # check if configure script exists
        #########################################################
        if ( ! -e ${module_src}/configure ) then
-           echo "Warning! Can not find configure script in ${module_src}."
+           echo "\!\!\! Warning \!\!\! Can not find configure script in ${module_src}."
        else
-           if (  "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
+           if ( $med_with_gui == 0 && "${module}" == "MED" ) then
+               set add_keys="--without-ihm"
+           endif
+           if ( "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
                set add_keys="--with-netgen=${NETGENHOME}"
            endif
            ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
@@ -268,17 +336,17 @@ foreach module (${modules})
            # echo possible errors
            #########################################################
            if ( $verbose_level > 0 ) then
-               cat ${LOG_DIR}/configure_${module}.log | grep ": error:"
+               cat ${LOG_DIR}/configure_${module}.log | grep ": error:" >&2
            endif
            if ( $verbose_level > 1 ) then
-               cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:"
+               cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" >&2
            endif
        endif
     endif
     #########################################################
     # perform make
     #########################################################
-    echo "------- Make --------------------"
+    echo "... Performing make"
     #########################################################
     # first clear dependencies
     #########################################################
@@ -295,7 +363,7 @@ foreach module (${modules})
     #########################################################
     # print make errors
     #########################################################
-    cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]'
+    cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]' >&2
     #########################################################
     # print compiler errors and warnings
     # Note: here awk is used to concatenate together several lines of single
@@ -304,23 +372,36 @@ 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/"@@
+       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
     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/"@@
+       cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {printf $0} END {print ""}' | grep ": warning" | sed s@"^${module_src}/src/"@@ >&2
     endif
     #########################################################
+    # perform make dev_docs step if -t flag is given
+    #########################################################
+    if ( $is_tui == 1 && $sts == 0 && -d ${module_build}/doc ) then
+       cd ${module_build}/doc
+       set 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
+           cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' >&2
+       endif
+    endif
+    cd ${module_build}
+    #########################################################
     # perform make if -i or -p flags are given
     #########################################################
-    if ( $is_install == 1 && $sts == 0 ) then
-       echo "------- Make install ------------"
+    if ( $is_install == 1 && $sts == 0 || "${module}" == "KERNEL" ) then
        #########################################################
        # deleting build directory if -d flag is given
        #########################################################
        if ( -e $px && $is_delete == 1 ) then
-           echo "Deleting $px"
+           echo "... Removing $px"
            rm -rf $px
        endif
+       echo "... Performing make install"
        make install >& ${LOG_DIR}/make_install_${module}.log
        set sts=$status
        #########################################################
@@ -331,9 +412,9 @@ foreach module (${modules})
            setenv ${module}_ROOT_DIR $px
        endif
     endif
-    echo ""
+    echo ">>> Finished ${module} module"
   else
-    echo "Error! Can't find module sources. ${module}_SRC_DIR environment variable is not set."
+    echo "\!\!\! Error \!\!\! Can't find module sources. ${module}_SRC_DIR environment variable is not set."
   endif
 end
 #########################################################