# This script can be used to build and install SALOME modules from sources.
# Try build.sh -h for more details about usage.
#
+# Last update: 13/12/2013: porting SALOME build procedure to CMake
+# TODO:
+# - get back verbosity option which is currently switched off
+#
####################################################################################
+# set to 1 to print debug information for script
+if [ "${DEBUG_SCRIPT}" = "" ] ; then
+ DEBUG_SCRIPT=0
+fi
+
+# default installation directory
+def_install_dir="$(pwd)/INSTALL"
+# default verbosity level
+def_verbosity_level=0
+# default modules list
+def_modules=""
+def_modules="${def_modules} KERNEL GUI GEOM MED SMESH PARAVIS YACS HOMARD HEXABLOCK JOBMANAGER"
+def_modules="${def_modules} NETGENPLUGIN GHS3DPLUGIN BLSURFPLUGIN HexoticPLUGIN GHS3DPRLPLUGIN HEXABLOCKPLUGIN"
+def_modules="${def_modules} COMPONENT CALCULATOR PYCALCULATOR HELLO PYHELLO LIGHT PYLIGHT"
+def_modules="${def_modules} RANDOMIZER SIERPINSKY ATOMIC ATOMGEN ATOMSOLV DOCUMENTATION"
+
###############################################################
-# Prints usage information and exits
+# Function: Print usage information and exit
###############################################################
usage(){
echo ""
- echo "Description:"
- echo " Builds given SALOME modules by performing make and "
- echo " make install commands"
+ echo "Build specified SALOME module(s)"
echo ""
echo "Usage:"
- echo " build.sh [ <option> ] ... [ <module> [ <module> ... ] ]"
+ echo " $(basename $0) [ <option> ] ... [ <module> [ <module> ... ] ]"
echo ""
- echo "<module> 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 "<module> Modules to build, separated by space(s)."
+ echo " By default, all modules are built."
+ echo " Note, that modules given in the command lines are automatically"
+ echo " sorted according to the inter-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 "-h Print help on the information."
echo ""
- 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 "-d Delete build (and install) directories before calling CMake,"
+ echo " to force full rebuild of each specified module."
+ echo " Default: off."
echo ""
- echo "-d Delete build directories before calling configure, to force full"
- echo " rebuild and reinstall of the module."
- echo " Use this option carefully."
+ echo "-t Perform make dev_docs step to build developer documentation,"
+ echo " for those modules which support this feature."
+ echo " Default: off."
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 "-j <JOBS> Specify number of jobs (commands) to run simultaneously,"
+ echo " this option, when specified, passed directly to make."
echo ""
- echo "-t Performs make dev_docs step to build TUI documentation for those"
- echo " modules which support this. Default is off."
+ echo "-p <PREFIX> Specify installation directory."
+ echo " Default: ${def_install_dir}."
+# echo ""
+# echo "-v <LEVEL> Specify verbosity level:"
+# echo " 0 - show only errors;"
+# echo " 1 - show errors and warnings."
+# echo " Default: ${def_verbosity_level}."
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 "-D<OPT>=<VAL> Specify additional options to be passed to CMake command."
echo ""
- echo "-v <level> 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 "Examples:"
echo ""
- echo "-h Prints this help information."
+ echo " $(basename $0) -p /home/user/salome KERNEL MED GEOM"
echo ""
- echo "Note: If no keys are given script just performs make step."
+ echo " This will make KERNEL, GEOM and MED modules and install them to the "
+ echo " /home/user/salome directory."
+ echo " The modules will be built in the Release mode."
echo ""
- echo "Example:"
- echo " ./build.csh -o -p /home/user/salome -b KERNEL MED GEOM"
+ echo " $(basename $0) -DCMAKE_BUILD_TYPE=Debug -DSALOME_BUILD_GUI=OFF"
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 " This will build all modules without GUI support. Those modules, that do not"
+ echo " support compilation without GUI, won't be affected."
+ echo " The modules will be built in the Debug mode and installed to the default"
+ echo " location."
echo ""
+ exit 0
+}
+
+###############################################################
+# Function: Show error, print usage information and exit
+###############################################################
+error_exit()
+{
+ echo
+ echo "$(basename $0): $*"
+ echo
exit 1
}
-is_build_configure=0
-is_configure=0
-inst_with_gui=1
+###############################################################
+# Function: Get CMake options for the specified module
+###############################################################
+get_cmake_options()
+{
+ local def_options="-DCMAKE_BUILD_TYPE=Release"
+ case $1 in
+ KERNEL ) def_options="${def_options} -DSALOME_USE_LIBBATCH=ON -DSALOME_USE_SIMAN=ON" ;;
+ SMESH ) def_options="${def_options} -DSALOME_SMESH_USE_CGNS=ON -DSALOME_SMESH_USE_TBB=ON" ;;
+ esac
+ echo ${def_options}
+}
+
+###############################################################
+# Function: Check if module supports compilation without gui
+###############################################################
+supports_wogui()
+{
+ local res
+ case $1 in
+ KERNEL | GEOM | MED | SMESH | NETGENPLUGIN | GHS3DPLUGIN | GHS3DPRLPLUGIN | BLSURFPLUGIN | HexoticPLUGIN ) res=0 ;;
+ YACS | HEXABLOCK | HEXABLOCKPLUGIN ) res=0 ;;
+ * ) res=1 ;;
+ esac
+ return $res
+}
+
+###############################################################
+# Function: Check if module supports make dev_docs step
+###############################################################
+supports_build_tui()
+{
+ local res
+ case $1 in
+ KERNEL | GUI | GEOM | MED | SMESH | YACS | BLSURFPLUGIN | PYCALCULATOR ) res=0 ;;
+ * ) res=1 ;;
+ esac
+ return $res
+}
+
+###
+# set initial values for options
+###
+
is_delete=0
-verbose_level=2
-params=""
-modules="KERNEL GUI GEOM MED SMESH PARAVIS YACS NETGENPLUGIN GHS3DPLUGIN BLSURFPLUGIN HexoticPLUGIN GHS3DPRLPLUGIN COMPONENT CALCULATOR HELLO PYHELLO LIGHT PYLIGHT HEXABLOCK HEXABLOCKPLUGIN ATOMIC ATOMGEN ATOMSOLV HOMARD JOBMANAGER"
-optim=""
-is_install=1
-is_tui=0
-prefix=""
-def_install_dir="/INSTALL"
-
-#########################################################
-# parse parameters
-#########################################################
-while getopts ":hbcwdotv:p:" option ; do
- case $option in
- h ) usage ;;
- b ) is_build_configure=1 ; is_configure=1 ;;
- c ) is_configure=1 ;;
- w ) inst_with_gui=0 ;;
- d ) is_delete=1 ;;
- o ) optim="--enable-production=yes --disable-debug" ;;
- t ) is_tui=1 ;;
- v ) verbose_level=$OPTARG ;;
- p ) is_install=1 ; prefix=$OPTARG ;;
- ? ) usage ;;
+build_devdocs=0
+prefix=
+verbosity=${def_verbosity_level}
+nbjobs=
+cmake_options=
+
+###
+# parse command line
+###
+
+for o in "$@" ; do
+ case ${o} in
+ -* )
+ if [ "${wait_arg}" = "1" ] ; then
+ error_exit "option requires an argument -- ${wait_opt}"
+ fi
+ o=${o:1}
+ while [ "${o}" != "" ] ; do
+ oo=${o:0:1}
+ ov=${o:1}
+ case ${oo} in
+ h ) usage ;;
+ D ) cmake_option=${ov}
+ if [ "${cmake_option}" = "" ] ; then
+ error_exit "specify cmake option in -D<OPT>=<VAL> format"
+ fi
+ cmake_options="${cmake_options} -${o}"
+ break
+ ;;
+ p ) prefix=${ov}
+ if [ "${prefix}" = "" ] ; then
+ wait_arg=1
+ wait_opt=p
+ fi
+ break
+ ;;
+ v ) verbosity=${ov}
+ if [ "${verbosity}" = "" ] ; then
+ wait_arg=1
+ wait_opt=v
+ fi
+ break
+ ;;
+ j ) nbjobs=${ov}
+ if [ "${nbjobs}" = "" ] ; then
+ wait_arg=1
+ wait_opt=j
+ fi
+ break
+ ;;
+ d ) is_delete=1 ;;
+ t ) build_devdocs=1 ;;
+ * ) error_exit "unknown option -- ${oo}" ;;
+ esac
+ o=${o:1}
+ done
+ ;;
+ * )
+ echo ${def_modules} | grep -e "\<${o}\>" > /dev/null
+ if [ "$?" = "0" ] ; then
+ if [ "${wait_arg}" = "1" ] ; then
+ error_exit "option requires an argument -- ${wait_opt}"
+ fi
+ modules="${modules} ${o}"
+ elif [ "${wait_opt}" != "" ] ; then
+ case ${wait_opt} in
+ p ) prefix=${o} ;;
+ v ) verbosity=${o} ;;
+ j ) nbjobs=${o} ;;
+ * ) error_exit "unknown option -- ${wait_opt}" ;;
+ esac
+ wait_arg=0
+ wait_opt=
+ else
+ error_exit "unknown module -- ${o}"
+ fi
+ ;;
esac
done
-# shift to have the good number of other args
-shift $((OPTIND - 1))
+if [ "${wait_arg}" = "1" ] ; then
+ error_exit "option requires an argument -- ${wait_opt}"
+fi
-b_params=""
+###
+# check installation directory
+###
-for arg in $@ ; do
- known=0
- for m in $modules ; do
- if [ "$m" = "$arg" ] ; then known=1 ; break ; fi
- done
- if [ $known -eq 0 ] ; then
- echo
- echo '!!! Warning !!! Unknown module: '$arg'.'
- b_params="$b_params $arg"
- else
- params="$params $arg"
- fi
-done
+if [ "${prefix}" = "" ] ; then
+ echo
+ echo "Warning: installation directory is not set."
+ echo "All modules will be installed to ${def_install_dir}."
+ echo
+ prefix=${def_install_dir}
+elif [ "`echo ${prefix} | grep -E '^/'`" = "" ] ; then
+ prefix="$(pwd)/${prefix}"
+ echo
+ echo 'Warning: relative prefix is used.'
+ echo "All the modules will be installed to ${prefix}."
+ echo
+fi
-#########################################################
+###
# sort modules in proper order according to the dependancies
-#########################################################
-if [ "${params}" != "" ] ; then
- xparams=""
- for module in ${modules} ; do
+###
+
+if [ "${modules}" != "" ] ; then
+ xmodules=""
+ for module in ${def_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"
+ echo ${modules} | grep -e "\<${module}\>" > /dev/null
+ if [ "$?" = "0" ] ; then
+ xmodules="${xmodules} ${module}"
fi
done
- modules="$xparams $b_params"
-elif [ "${b_params}" != "" ] ; then
- modules="$b_params"
+ modules="${xmodules}"
+else
+ modules="${def_modules}"
fi
-echo
-echo ">>> The following modules will be built:"
-echo $modules
-echo
+###
+# print status information (for script debugging purposes)
+###
-#########################################################
+if [ "${DEBUG_SCRIPT}" = "1" ] ; then
+ echo
+ echo "====== debug script: options: begin ====="
+ echo "prefix=$prefix"
+ echo "verbosity=$verbosity"
+ echo "nbjobs=$nbjobs"
+ echo "cmake_options=$cmake_options"
+ echo "modules=$modules"
+ echo "is_delete=$is_delete"
+ echo "build_devdocs=$build_devdocs"
+ echo "====== debug script: options: end ======="
+ echo
+fi
+
+###
+# start build
+###
+
+echo "==========================================================================="
+echo "SALOME build started at `date`"
+echo "==========================================================================="
+
+###
# set environment
-#########################################################
-env_script=`dirname $0`/env_build.sh
-if [ ! -e $env_script ] ; then
- env_script=`dirname $0`/env_products.sh
+###
+
+# try env.sh
+env_script=`dirname $0`/env.sh
+if [ ! -e ${env_script} ] ; then
+ # ... if not found, try env_build.sh
+ env_script=`dirname $0`/env_build.sh
fi
-if [ ! -e $env_script ] ; then
- env_script=`dirname $0`/env.sh
+if [ ! -e ${env_script} ] ; then
+ # ... if not found, try env_products.sh
+ env_script=`dirname $0`/env_products.sh
fi
-if [ -e $env_script ] ; then
- echo
- echo ">>> Setting environment"
- source $env_script
+# source env file, if found
+if [ -e ${env_script} ] ; then
+ echo ". Source environment script ${env_script}"
+ source ${env_script}
else
echo
- 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.'
+ echo "Warning: environment is not set."
+ echo "No environment file ($(dirname $0)/env.sh, $(dirname $0)/env_build.sh, $(dirname $0)/env_products.sh) is found."
+ echo "Proceed with the current environment."
+ echo
fi
-BUILD_DIR=${PWD}
+BUILD_DIR=$(pwd)
LOG_DIR=${BUILD_DIR}/LOGS
-#########################################################
-# define installation prefix
-#########################################################
-if [ "$prefix" = "" ] ; then
- 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
- 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 through all specified modules
+###
-#########################################################
-# loop for all given modules
-#########################################################
-for module in ${modules}; do
- echo ">>> Processing ${module} module"
+for module in ${modules} ; do
+ echo "......................"
+ echo ".. ${module} module..."
- module_src=`printenv ${module}_SRC_DIR`
+ module_src=${module}_SRC_DIR
+ module_src=${!module_src}
module_build=${BUILD_DIR}/${module}_BUILD
-
- if [ "${module_src}" != "" ] ; then
- 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 ] || [ -e ${module_src}/CMakeLists.txt ] ; 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 ] && [ "${module}" != "PARAVIS" ] ; then
- echo '!!! Warning !!! Cannot find build_configure script in '${module_src}'.'
- else
- if [ "${module}" = "PARAVIS" ]; then
- echo '!!! Warning !!! build_configure step is not executed for '${module}'.'
- else
- #########################################################
- # call build_configure
- #########################################################
- mybuildconf_keys="${BUILDCONF_OPTS}"
- if [ $inst_with_gui -eq 0 ] ; then
- mybuildconf_keys="${mybuildconf_keys} --without-gui"
- fi
- cd ${module_src}
- ./build_configure ${mybuildconf_keys} >& ${LOG_DIR}/build_configure_${module}.log
- #########################################################
- # echo possible errors
- #########################################################
- if [ $verbose_level -gt 0 ] ; then
- cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" >&2
- fi
- fi
- fi
- fi
- #########################################################
- # deleting build directory if -d flag is given
- #########################################################
- if [ -e ${module_build} ] && [ $is_delete -eq 1 ] ; then
- echo "... Removing ${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} >& /dev/null
- if [ "$?" != "0" ] ; then
- echo
- echo '!!! Error !!! Cannot create build directory ${module_build}. Permission denied.'
- echo
- continue
- fi
- 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
- #########################################################
- # define installation directory (by using module's version
- # number); default is a build directory
- #########################################################
- vx=""
- 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
- elif [ -e ${module_src}/CMakeLists.txt ] ; then
- ver_maj=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MAJOR | sed -e "s%[A-Z_() ]%%g"`
- ver_min=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MINOR | sed -e "s%[A-Z_() ]%%g"`
- ver_maintenance=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MAINTENANCE | sed -e "s%[A-Z_() ]%%g"`
- vx="${ver_maj}.${ver_min}.${ver_maintenance}"
+ without_gui=0
+ if [ "${nbjobs}" != "" ] ; then nbjobs="-j${nbjobs}" ; fi
+
+ cd ${BUILD_DIR}
+
+ ###
+ # get CMake options to be applied to the module
+ ###
+
+ # get default CMake options
+ def_cmake_options=`get_cmake_options ${module}`
+
+ # process cmake options specified via command line
+ module_cmake_options=
+ for option in ${def_cmake_options} ; do
+ option_name=`echo $option | sed -e "s%^-D%%g;s%=.*$%%g"`
+ if [ "`echo ${cmake_options} | grep -e '-D${option_name}='`" = "" ] ; then
+ module_cmake_options="${module_cmake_options} ${option}"
fi
- if [ "$vx" != "" ] ; then
- vx="_$vx"
+ done
+ for option in ${cmake_options} ; do
+ option_name=`echo $option | sed -e "s%^-D%%g;s%=.*$%%g"`
+ if [ "${option_name}" != "CMAKE_INSTALL_PREFIX" ] ; then
+ module_cmake_options="${module_cmake_options} ${option}"
fi
- if [ "$prefix" = "" ] ; then
- px=${BUILD_DIR}${def_install_dir}/${module}${vx}
- else
- px=$prefix/${module}${vx}
+ if [ "${option}" = "-DSALOME_BUILD_GUI=OFF" ] ; then
+ without_gui=1
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 ] && [ "${module}" != "PARAVIS" ] ; then
- echo
- echo '!!! Warning !!! Can not find configure script in '${module_src}'.'
- echo
- else
- myconf_keys="${CONF_OPTS}"
- if [ $inst_with_gui -eq 0 ] ; then
- myconf_keys="${myconf_keys} --without-gui"
- fi
- if [ "${module}" = "MED" ] && [ "${METIS_ROOT_DIR}" != "" ] && [ "${SCOTCH_ROOT_DIR}" != "" ] ; then
- myconf_keys="${myconf_keys} --enable-splitter=yes --with-metis=${METIS_ROOT_DIR} --with-scotch=${SCOTCH_ROOT_DIR}"
- fi
- if [ "${module}" = "NETGENPLUGIN" ] && [ "$NETGEN_ROOT_DIR" != "" ] ; then
- myconf_keys="${myconf_keys} --with-netgen=${NETGEN_ROOT_DIR}"
- fi
+ done
- 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
- fi
+ ###
+ # check source directory
+ ###
- #########################################################
- # echo possible errors
- #########################################################
- if [ $verbose_level -gt 0 ] ; then
- cat ${LOG_DIR}/configure_${module}.log | grep ": error:" >&2
- fi
- if [ $verbose_level -gt 1 ] ; then
- cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" >&2
- fi
- fi
- fi
- #########################################################
- # perform make
- #########################################################
- echo "... Performing make"
- #########################################################
- # first clear dependencies
- #########################################################
- find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null
- #########################################################
- # then make
- #########################################################
- if [ "${module}" = "PARAVIS" ] ; then
- VTK_AUTOLOAD_PATH_BACKUP=${VTK_AUTOLOAD_PATH}
- test "${VTK_AUTOLOAD_PATH}" != "" && unset VTK_AUTOLOAD_PATH
- fi
- make >& ${LOG_DIR}/make_${module}.log
- sts=$?
- if [ "${module}" = "PARAVIS" ] ; then
- test "${VTK_AUTOLOAD_PATH_BACKUP}" != "" && export VTK_AUTOLOAD_PATH=${VTK_AUTOLOAD_PATH_BACKUP}
+ if [ "${module_src}" = "" ] ; then
+ echo "Error: cannot find module sources. ${module}_SRC_DIR environment variable is not set."
+ continue
+ fi
+
+ if [ ! -d ${module_src} ] ; then
+ echo "Error: cannot find module sources directory: ${module_src} does not exist."
+ continue
+ fi
+
+ ###
+ # remove build directory (if -d option is given)
+ ###
+
+ if [ "${is_delete}" = "1" ] && [ -d ${module_build} ] ; then
+ echo ".... Removing ${module_build}"
+ chmod -R +w ${module_build} >& /dev/null && rm -rf ${module_build} >& /dev/null
+ if [ "$?" != "0" ] ; then
+ echo "Warning: cannot remove build directory ${module_build}: permission denied."
fi
- #########################################################
- # 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 -Ei '[*][*][*].*error' >&2
- #########################################################
- # 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 ""} {print $0} END {print ""}' | grep "${module_src}/[A-Za-z_0-9./]*:" | sed s@"^${module_src}/src/"@@ >&2
+ fi
+
+ ###
+ # create build directory (if it does not exist)
+ ###
+
+ if [ ! -d ${module_build} ] ; then
+ echo ".... Creating ${module_build}"
+ mkdir -p ${module_build} >& /dev/null
+ if [ "$?" != "0" ] ; then
+ echo "Error: cannot create build directory ${module_build}: permission denied."
+ continue
fi
- if [ $verbose_level -gt 1 ] ; then
- 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
+
+ ###
+ # get installation directory for the module
+ ###
+
+ # get version id
+ vx=""
+ if [ -e ${module_src}/CMakeLists.txt ] ; then
+ ver_major=$(grep "SET(\${PROJECT_NAME_UC}_MAJOR_VERSION" ${module_src}/CMakeLists.txt | sed -e "s%.*\([0-9]\+\).*%\1%g")
+ ver_minor=$(grep "SET(\${PROJECT_NAME_UC}_MINOR_VERSION" ${module_src}/CMakeLists.txt | sed -e "s%.*\([0-9]\+\).*%\1%g")
+ ver_patch=$(grep "SET(\${PROJECT_NAME_UC}_PATCH_VERSION" ${module_src}/CMakeLists.txt | sed -e "s%.*\([0-9]\+\).*%\1%g")
+ vx="${ver_major}.${ver_minor}.${ver_patch}"
+ fi
+ if [ "${vx}" != "" ] ; then
+ vx="_${vx}"
+ fi
+
+ # set prefix
+ px="${prefix}/${module}${vx}"
+
+ ###
+ # run CMake
+ ###
+
+ echo ".... Running cmake"
+
+ # check presence of CMakeLists.txt
+ if [ ! -e ${module_src}/CMakeLists.txt ] ; then
+ echo "Error: ${module_src}/CMakeLists.txt does not exist."
+ continue
+ fi
+
+ # when building without gui support, check that module supports this option
+ if [ "${without_gui}" = "1" ] ; then
+ supports_wogui ${module}
+ if [ "$?" != "0" ] ; then
+ echo "Error: build without gui is not supported."
+ continue
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
- cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' >&2
- fi
+ fi
+
+ # run cmake
+ ( cd ${module_build} && cmake ${module_src} -DCMAKE_INSTALL_PREFIX=${px} ${module_cmake_options} >& ${LOG_DIR}/${module}_cmake.log )
+ sts=$?
+
+ # print errors/warnings
+ if [ ${verbosity} -gt 0 ] ; then
+ cat ${LOG_DIR}/${module}_cmake.log | grep -iE ": (warning|error):" >&2
+ else
+ cat ${LOG_DIR}/${module}_cmake.log | grep ": error:" >&2
+ fi
+
+ # stop if there were any errors
+ if [ "${sts}" != "0" ] ; then
+ echo "Error: cmake failed."
+ continue
+ fi
+
+ ###
+ # run make
+ ###
+
+ echo ".... Running make"
+
+ # run make
+ ( cd ${module_build} && make ${nbjobs} >& ${LOG_DIR}/${module}_make.log )
+ sts=$?
+
+ # print errors/warnings
+ #-------------------------------------------------------------------------
+ # 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++...
+ #-------------------------------------------------------------------------
+ cat ${LOG_DIR}/${module}_make.log | grep -Ei '[*][*][*].*error' >&2
+ if [ ${verbosity} -gt 0 ] ; then
+ cat ${LOG_DIR}/${module}_make.log | awk 'substr($0,0,1)!=" " {print ""} {print $0} END {print ""}' | grep -E ": warning|* Warning|${module_src}/[A-Za-z_0-9./]*:" | sed s@"^${module_src}/src/"@@ >&2
+ fi
+
+ # stop if there were any errors
+ if [ "${sts}" != "0" ] ; then
+ echo "Error: make failed."
+ continue
+ fi
+
+ ###
+ # run make dev_docs step (if -t option is given)
+ ###
+
+ if [ "${build_devdocs}" = "1" ] ; then
+ supports_build_tui ${module}
+ if [ "$?" = "0" ] ; then
+ echo ".... Running make dev_docs"
+ ( cd ${module_build} && make dev_docs >& ${LOG_DIR}/${module}_make_devdocs.log )
+ cat ${LOG_DIR}/${module}_make_devdocs.log | grep '[*][*][*]' >&2
fi
- cd ${module_build}
- #########################################################
- # perform make if -i or -p flags are given
- #########################################################
- if [ $is_install -eq 1 ] && [ $sts -eq 0 ] || [ "${module}" = "KERNEL" ] ; then
- #########################################################
- # deleting build directory if -d flag is given
- #########################################################
- if [ -e $px ] && [ $is_delete -eq 1 ] ; then
- echo "... Removing $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
- 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
+
+ ###
+ # remove install directory (if -d option is given)
+ ###
+
+ if [ "${is_delete}" = "1" ] && [ -d ${px} ] ; then
+ echo ".... Removing ${px}"
+ chmod -R +w ${px} >& /dev/null && rm -rf ${px} >& /dev/null
+ if [ "$?" != "0" ] ; then
+ echo "Warning: cannot remove install directory ${px}: permission denied."
fi
- echo ">>> Finished ${module} module"
- else
- echo
- echo '!!! Error !!! Cannot find module sources. '${module}'_SRC_DIR environment variable is not set.'
- echo
fi
+
+ ###
+ # run make install
+ ###
+
+ echo ".... Running make install"
+ ( cd ${module_build} && make install >& ${LOG_DIR}/${module}_make_install.log )
+ sts=$?
+
+ if [ "${sts}" != "0" ] ; then
+ echo "Error: make install failed."
+ continue
+ fi
+
+ ###
+ # set ${module}_ROOT_DIR environment variable
+ ###
+
+ export ${module}_ROOT_DIR=${px}
+
+ echo ".. Finished ${module} module"
done
-#########################################################
+
+###
# finalize
-#########################################################
+###
+
cd ${BUILD_DIR}
-echo
echo "==========================================================================="
echo "SALOME build finished at `date`"
echo "==========================================================================="
-echo