3 ####################################################################################
5 # Created : Thu Jan 27 09:50:55 2005
6 # Author : Vadim SANDLER, Open CASCADE SAS (vadim.sandler@opencascade.com)
8 # Module : Installation Wizard
9 # Copyright : 2002-2012 CEA
11 # This script is the part of the SALOME installation procedure.
13 # This script can be used to build and install SALOME modules from sources.
14 # Try build.sh -h for more details about usage.
16 ####################################################################################
18 ###############################################################
19 # Prints usage information and exits
20 ###############################################################
24 echo " Builds given SALOME modules by performing make and "
25 echo " make install commands"
28 echo " build.sh [ <option> ] ... [ <module> [ <module> ... ] ]"
30 echo "<module> Modules to build, separated by space(s)."
31 echo " If no modules are given - all SALOME modules are assumed."
32 echo " Note, that modules given in command lines are automatically"
33 echo " sorted in such order to support correct modules dependencies."
36 echo "-b Perform build_configure command for all given modules."
37 echo " This option forces configure (-c) key to be set. Default is off."
39 echo "-c Perform configure command for all given modules. Default is off."
41 echo "-w Add --without-gui key to build_configure and configure commands"
42 echo " to build SALOME module sources without GUI."
43 echo " By default sources are built with GUI."
45 echo "-d Delete build directories before calling configure, to force full"
46 echo " rebuild and reinstall of the module."
47 echo " Use this option carefully."
49 echo "-o Build sources in optimized mode. Default is off that means"
51 echo " Use this option together with -c or -b."
52 echo " This option can require -d option to be set (to ensure that"
53 echo " previously created build directories are removed to enforce"
54 echo " rebuild in optimized mode)."
56 echo "-t Performs make dev_docs step to build TUI documentation for those"
57 echo " modules which support this. Default is off."
59 echo "-p <prefix> Define the directory where to install modules after compilation."
60 echo " By default the directory where compilation is performed is used."
62 echo "-v <level> Verbose level (0-2, default 2): print information on build status:"
63 echo " 0: only 'make' errors"
64 echo " 1: 0 + compiler and other errors (build_configure, configure)"
65 echo " 2: 1 + compiler and other warnings "
67 echo "-h Prints this help information."
69 echo "Note: If no keys are given script just performs make step."
72 echo " ./build.csh -o -p /home/user/salome -b KERNEL MED GEOM"
74 echo " This will make KERNEL, GEOM and MED modules: build_configure,"
75 echo " configure, make and install procedures will be performed for all"
76 echo " specified modules. The modules will be built in the optimized mode."
87 #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"
88 modules="KERNEL GUI GEOM MED SMESH VISU PARAVIS YACS NETGENPLUGIN GHS3DPLUGIN BLSURFPLUGIN HexoticPLUGIN GHS3DPRLPLUGIN PYHELLO"
93 def_install_dir="/INSTALL"
95 #########################################################
97 #########################################################
98 while getopts ":hbcwdotv:p:" option ; do
101 b ) is_build_configure=1 ; is_configure=1 ;;
102 c ) is_configure=1 ;;
103 w ) inst_with_gui=0 ;;
105 o ) optim="--enable-production=yes --disable-debug" ;;
107 v ) verbose_level=$OPTARG ;;
108 p ) is_install=1 ; prefix=$OPTARG ;;
112 # shift to have the good number of other args
113 shift $((OPTIND - 1))
119 for m in $modules ; do
120 if [ "$m" == "$arg" ] ; then known=1 ; break ; fi
122 if [ $known -eq 0 ] ; then
124 echo '!!! Warning !!! Unknown module: '$arg'.'
125 b_params="$b_params $arg"
127 params="$params $arg"
131 #########################################################
132 # sort modules in proper order according to the dependancies
133 #########################################################
134 if [ "${params}" != "" ] ; then
136 for module in ${modules} ; do
138 for p in $params ; do
139 if [ "$p" == "$module" ] ; then found=1 ; break ; fi
141 if [ $found -eq 1 ] ; then
142 xparams="$xparams $module"
145 modules="$xparams $b_params"
146 elif [ "${b_params}" != "" ] ; then
151 echo ">>> The following modules will be built:"
155 #########################################################
157 #########################################################
158 env_script=`dirname $0`/env_build.sh
159 if [ ! -e $env_script ] ; then
160 env_script=`dirname $0`/env_products.sh
162 if [ ! -e $env_script ] ; then
163 env_script=`dirname $0`/env.sh
165 if [ -e $env_script ] ; then
167 echo ">>> Setting environment"
171 echo '!!! Warning !!! Environment is not set.'
172 echo 'No environment file (env_build.sh, env_products.sh, env.sh) is found.'
173 echo 'Proceed with the current environment.'
177 LOG_DIR=${BUILD_DIR}/LOGS
179 #########################################################
180 # define installation prefix
181 #########################################################
182 if [ "$prefix" == "" ] ; then
184 echo '!!! Warning !!! Installation directory is not set.'
185 echo "All the modules will be installed to the ${BUILD_DIR}${def_install_dir}"
187 if [ "`echo $prefix | grep -E '^/'`" == "" ] ; then
188 prefix=${BUILD_DIR}/$prefix
190 echo '!!! Warning !!! Relative prefix is used.'
191 echo "All the modules will be installed to the $prefix."
195 #########################################################
196 # create log directory
197 #########################################################
198 if [ ! -e ${LOG_DIR} ] ; then
203 echo "==========================================================================="
204 echo "Starting SALOME build at `date`"
205 echo "==========================================================================="
208 #########################################################
209 # loop for all given modules
210 #########################################################
211 for module in ${modules}; do
212 echo ">>> Processing ${module} module"
214 module_src=`printenv ${module}_SRC_DIR`
215 module_build=${BUILD_DIR}/${module}_BUILD
217 if [ "${module_src}" != "" ] ; then
219 #########################################################
220 # check if sources directory exists
221 #########################################################
222 if [ ! -e ${module_src} ] ; then
224 echo '!!! Error !!! Cannot find module sources directory:'
225 echo "${module_src} does not exist."
229 #########################################################
230 # check if configure script exists
231 #########################################################
233 if [ -e ${module_src}/configure ] || [ -e ${module_src}/CMakeLists.txt ] ; then
236 #########################################################
237 # perform build_configure if -b flag is given or if
238 # configure script does not exist (first compilation?)
239 #########################################################
240 if [ $is_build_configure -eq 1 ] || [ $cfg_exist -eq 0 ] ; then
241 echo "... Performing build_configure"
242 #########################################################
243 # check if build_configure script exists
244 #########################################################
245 if [ ! -e ${module_src}/build_configure ] && [ "${module}" != "PARAVIS" ] ; then
246 echo '!!! Warning !!! Cannot find build_configure script in '${module_src}'.'
248 if [ "${module}" == "PARAVIS" ]; then
249 echo '!!! Warning !!! build_configure step is not executed for '${module}'.'
251 #########################################################
252 # call build_configure
253 #########################################################
254 mybuildconf_keys="${BUILDCONF_OPTS}"
255 if [ $inst_with_gui -eq 0 ] ; then
256 mybuildconf_keys="${mybuildconf_keys} --without-gui"
259 ./build_configure ${mybuildconf_keys} >& ${LOG_DIR}/build_configure_${module}.log
260 #########################################################
261 # echo possible errors
262 #########################################################
263 if [ $verbose_level -gt 0 ] ; then
264 cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" >&2
269 #########################################################
270 # deleting build directory if -d flag is given
271 #########################################################
272 if [ -e ${module_build} ] && [ $is_delete -eq 1 ] ; then
273 echo "... Removing ${module_build}"
274 chmod -R +w ${module_build} && rm -rf ${module_build} >& /dev/null
275 if [ "$?" != "0" ] ; then
277 echo '!!! Warning !!! Cannot remove build directory ${module_build}. Permission denied.'
281 #########################################################
282 # creating build directory if it does not exist
283 #########################################################
284 if [ ! -e ${module_build} ] ; then
285 mkdir -p ${module_build} >& /dev/null
286 if [ "$?" != "0" ] ; then
288 echo '!!! Error !!! Cannot create build directory ${module_build}. Permission denied.'
294 #########################################################
295 # check if top Makefile exists in build directory, i.e.
296 # is it necessary to run configure script
297 #########################################################
299 if [ -e ${module_build}/Makefile ] ; then
302 #########################################################
303 # check if configure options are changed from the
305 #########################################################
307 #########################################################
308 # define installation directory (by using module's version
309 # number); default is a build directory
310 #########################################################
312 if [ -e ${module_src}/configure.ac ] ; then
313 vx=`grep -e "^AC_INIT" ${module_src}/configure.ac | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
314 elif [ -e ${module_src}/configure.in.base ] ; then
315 vx=`grep -e "^VERSION=" ${module_src}/configure.in.base | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
316 if [ "$vx" == "" ] ; then
317 vx=`grep -e "^AC_INIT" ${module_src}/configure.in.base | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
319 elif [ -e ${module_src}/CMakeLists.txt ] ; then
320 ver_maj=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MAJOR | sed -e "s%[A-Z_() ]%%g"`
321 ver_min=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MINOR | sed -e "s%[A-Z_() ]%%g"`
322 ver_maintenance=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MAINTENANCE | sed -e "s%[A-Z_() ]%%g"`
323 vx="${ver_maj}.${ver_min}.${ver_maintenance}"
325 if [ "$vx" != "" ] ; then
328 if [ "$prefix" == "" ] ; then
329 px=${BUILD_DIR}${def_install_dir}/${module}${vx}
331 px=$prefix/${module}${vx}
333 #########################################################
334 # perform configure if -c flag is given or if
335 # Makefile does not exist (first compilation?)
336 #########################################################
337 if [ $is_configure -eq 1 ] || [ $mkfile_exist -eq 0 ] || [ $opts_changed -eq 1 ] ; then
338 echo "... Performing configure"
339 #########################################################
340 # check if configure script exists
341 #########################################################
342 if [ ! -e ${module_src}/configure ] && [ "${module}" != "PARAVIS" ] ; then
344 echo '!!! Warning !!! Can not find configure script in '${module_src}'.'
347 myconf_keys="${CONF_OPTS}"
348 if [ $inst_with_gui -eq 0 ] ; then
349 myconf_keys="${myconf_keys} --without-gui"
351 if [ "${module}" == "MED" ] && [ "${METISDIR}" != "" ] && [ "${SCOTCHDIR}" != "" ] ; then
352 myconf_keys="${myconf_keys} --enable-splitter=yes --with-metis=${METISDIR} --with-scotch=${SCOTCHDIR}"
354 if [ "${module}" == "NETGENPLUGIN" ] && [ "$NETGENHOME" != "" ] ; then
355 myconf_keys="${myconf_keys} --with-netgen=${NETGENHOME}"
358 if [ "${module}" == "PARAVIS" ] ; then
359 cd ${module_build}; cmake ${module_src} -DCMAKE_INSTALL_PREFIX=$px >& ${LOG_DIR}/configure_${module}.log
361 ${module_src}/configure --prefix=$px ${optim} ${myconf_keys} >& ${LOG_DIR}/configure_${module}.log
364 #########################################################
365 # echo possible errors
366 #########################################################
367 if [ $verbose_level -gt 0 ] ; then
368 cat ${LOG_DIR}/configure_${module}.log | grep ": error:" >&2
370 if [ $verbose_level -gt 1 ] ; then
371 cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" >&2
375 #########################################################
377 #########################################################
378 echo "... Performing make"
379 #########################################################
380 # first clear dependencies
381 #########################################################
382 find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null
383 #########################################################
385 #########################################################
386 if [ "${module}" == "PARAVIS" ] ; then
387 VTK_AUTOLOAD_PATH_BACKUP=${VTK_AUTOLOAD_PATH}
388 test "${VTK_AUTOLOAD_PATH}" != "" && unset VTK_AUTOLOAD_PATH
390 make >& ${LOG_DIR}/make_${module}.log
392 if [ "${module}" == "PARAVIS" ] ; then
393 test "${VTK_AUTOLOAD_PATH_BACKUP}" != "" && export VTK_AUTOLOAD_PATH=${VTK_AUTOLOAD_PATH_BACKUP}
395 #########################################################
396 # if make step is successful set the ${module}_ROOT_DIR
397 # environment variable
398 #########################################################
399 #if [ $sts -eq 0 ] ; then
400 # export ${module}_ROOT_DIR=${module_build}
402 #########################################################
404 #########################################################
405 cat ${LOG_DIR}/make_${module}.log | grep -Ei '[*][*][*].*error' >&2
406 #########################################################
407 # print compiler errors and warnings
408 # Note: here awk is used to concatenate together several lines of single
409 # error or warning message produced by stupid gnu compiler
410 # Actually, instead of that we could use 'fmessage length=n' option of g++...
411 #########################################################
412 if [ $verbose_level -gt 0 ] ; then
413 ###cat ${LOG_DIR}/make_${module}.log | grep ": error"
414 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
416 if [ $verbose_level -gt 1 ] ; then
417 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
419 #########################################################
420 # perform make dev_docs step if -t flag is given
421 #########################################################
422 if [ $is_tui -eq 1 ] && [ $sts -eq 0 ] && [ -d ${module_build}/doc ] ; then
423 cd ${module_build}/doc
424 dd=`cat Makefile | grep -E "dev_docs[[:space:]]*:"`
425 if [ "$dd" != "" ] ; then
426 echo "... Performing make dev_docs"
427 make dev_docs >& ${LOG_DIR}/make_dev_docs_${module}.log
428 cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' >&2
432 #########################################################
433 # perform make if -i or -p flags are given
434 #########################################################
435 if [ $is_install -eq 1 ] && [ $sts -eq 0 ] || [ "${module}" == "KERNEL" ] ; then
436 #########################################################
437 # deleting build directory if -d flag is given
438 #########################################################
439 if [ -e $px ] && [ $is_delete -eq 1 ] ; then
440 echo "... Removing $px"
441 rm -rf $px >& /dev/null
442 if [ "$?" != "0" ] ; then
444 echo '!!! Warning !!! Cannot remove install directory ${px}. Permission denied.'
448 echo "... Performing make install"
449 make install >& ${LOG_DIR}/make_install_${module}.log
451 #########################################################
452 # if make install step is successful set the
453 # ${module}_ROOT_DIR environment variable
454 #########################################################
455 if [ $sts -eq 0 ] ; then
456 export ${module}_ROOT_DIR=$px
459 echo ">>> Finished ${module} module"
462 echo '!!! Error !!! Cannot find module sources. '${module}'_SRC_DIR environment variable is not set.'
466 #########################################################
468 #########################################################
472 echo "==========================================================================="
473 echo "SALOME build finished at `date`"
474 echo "==========================================================================="