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-2007 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 (optionally)"
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-ihm key to build_configure and configure"
42 echo " commands for MED module to build its sources without GUI."
43 echo " By default MED sources are built with GUI."
45 echo "-d Delete build directories before calling configure, to enforce full"
46 echo " rebuild (and reinstall if -i or -p option is used) of 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 "-i Performs make install step. Default is off that means only make"
62 echo "-p <prefix> Define the directory where to install modules after compilation."
63 echo " By default the directory where compilation is performed is used."
65 echo "-v <level> Verbose level (0-2, default 2): print information on build status:"
66 echo " 0: only 'make' errors"
67 echo " 1: 0 + compiler and other errors (build_configure, configure)"
68 echo " 2: 1 + compiler and other warnings "
70 echo "-h Prints this help information."
72 echo "Note: If no keys are given script just performs make step."
75 echo " ./build.csh -o -i -b KERNEL MED GEOM"
77 echo " This will make KERNEL, GEOM and MED modules: build_configure,"
78 echo " configure, make and install procedures will be performed for all"
79 echo " specified modules. The modules will be built in the optimized mode."
91 modules="KERNEL GUI GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN BLSURFPLUGIN HexoticPLUGIN GHS3DPRLPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT SIERPINSKY RANDOMIZER FILTER YACS MULTIPR"
97 #########################################################
99 #########################################################
100 while getopts ":hbcwdoitv:p:" option ; do
103 b ) is_build_configure=1 ; is_configure=1 ;;
104 c ) is_configure=1 ;;
105 w ) med_with_gui=0 ;;
107 o ) optim="--enable-production=yes --disable-debug" ;;
110 v ) verbose_level=$OPTARG ;;
111 p ) is_install=1 ; prefix=$OPTARG ;;
115 # shift to have the good number of other args
116 shift $((OPTIND - 1))
120 for m in $modules ; do
121 if [ "$m" == "$arg" ] ; then known=1 ; break ; fi
123 if [ $known -eq 1 ] ; then
124 params="$params $arg"
126 b_params="$b_params $arg"
128 echo '!!! Warning !!! Unknown module: '$arg'. Skipping.'
132 #########################################################
133 # sort modules in proper order according to the dependancies
134 #########################################################
135 if [ "${params}" != "" ] ; then
137 for module in ${modules} ; do
139 for p in $params ; do
140 if [ "$p" == "$module" ] ; then found=1 ; break ; fi
142 if [ $found -eq 1 ] ; then xparams="$xparams $module" ; fi
145 elif [ "${b_params}" != "" ] ; then
147 echo "Nothing to be built. Exiting."
153 echo ">>> The following SALOME packages will be built:"
156 #########################################################
158 #########################################################
159 env_script=`dirname $0`/env_build.sh
160 if [ ! -e $env_script ] ; then
161 env_script=`dirname $0`/env_products.sh
163 if [ -e $env_script ] ; then
165 echo ">>> Setting environment"
169 echo '!!! Warning !!! Environment is not set.'
170 echo 'Neither env_build.sh nor env_products.sh file is found.'
171 echo 'Proceed with the current environment.'
175 LOG_DIR=${BUILD_DIR}/LOGS
177 #########################################################
178 # define installation prefix
179 #########################################################
180 if [ "$prefix" == "" ] ; then
181 prefix=${BUILD_DIR}/INSTALL
182 if [ $is_install -eq 1 ] ; then
184 echo '!!! Warning !!! Installation directory is not set.'
185 echo "All the modules will be installed to the $prefix"
186 elif [ "`echo ${modules} | grep KERNEL`" != "" ] ; then
188 echo '!!! Warning !!! KERNEL module requires install step to be performed.'
189 echo "For this module -i option will be forced."
190 echo "The module(s) will be installed to the $prefix"
193 if [ "`echo $prefix | grep -E '^/'`" == "" ] ; then
194 prefix=${BUILD_DIR}/$prefix
196 echo '!!! Warning !!! Relative prefix is used.'
197 echo "All the modules will be installed to the $prefix."
201 #########################################################
202 # create log directory
203 #########################################################
204 if [ ! -e ${LOG_DIR} ] ; then
209 echo "==========================================================================="
210 echo "Starting SALOME build at `date`"
211 echo "==========================================================================="
214 #########################################################
215 # loop for all given modules
216 #########################################################
217 for module in ${modules}; do
218 echo ">>> Processing ${module} module"
220 module_src=`printenv ${module}_SRC_DIR`
221 module_build=${BUILD_DIR}/${module}_BUILD
223 if [ "${module_src}" != "" ] ; then
226 #########################################################
227 # check if sources directory exists
228 #########################################################
229 if [ ! -e ${module_src} ] ; then
231 echo '!!! Error !!! Cannot find module sources directory:'
232 echo "${module_src} does not exist."
236 #########################################################
237 # check if configure script exists
238 #########################################################
240 if [ -e ${module_src}/configure ] ; then
243 #########################################################
244 # perform build_configure if -b flag is given or if
245 # configure script does not exist (first compilation?)
246 #########################################################
247 if [ $is_build_configure -eq 1 ] || [ $cfg_exist -eq 0 ] ; then
248 echo "... Performing build_configure"
249 #########################################################
250 # check if build_configure script exists
251 #########################################################
252 if [ ! -e ${module_src}/build_configure ] ; then
253 echo '!!! Warning !!! Cannot find build_configure script in '${module_src}'.'
255 #########################################################
256 # call build_configure
257 #########################################################
258 if [ $med_with_gui -eq 0 ] && [ ${module} == "MED" ] ; then
259 add_keys="--without-ihm"
262 ./build_configure ${add_keys} >& ${LOG_DIR}/build_configure_${module}.log
263 #########################################################
264 # echo possible errors
265 #########################################################
266 if [ $verbose_level -gt 0 ] ; then
267 cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" >&2
271 #########################################################
272 # deleting build directory if -d flag is given
273 #########################################################
274 if [ -e ${module_build} ] && [ $is_delete -eq 1 ] ; then
275 echo "... Removing ${module_build}"
276 rm -rf ${module_build}
278 #########################################################
279 # creating build directory if it does not exist
280 #########################################################
281 if [ ! -e ${module_build} ] ; then
282 mkdir -p ${module_build}
285 #########################################################
286 # check if top Makefile exists in build directory, i.e.
287 # is it necessary to run configure script
288 #########################################################
290 if [ -e ${module_build}/Makefile ] ; then
293 #########################################################
294 # check if configure options are changed from the
296 #########################################################
298 ## if [ -f ${module_build}/config.log ] ; then
299 ## old_prefix=`grep -e '^prefix=' ${module_build}/config.log | sed -e "s%^prefix='\(.*\)'%\1%"`
300 ## if [ "$old_prefix" != "$prefix" ] ; then
304 #########################################################
305 # define installation directory (by using module's version
306 # number); default is a build directory
307 #########################################################
309 cfg_file=configure.ac
310 if [ ! -e ${module_src}/${cfg_file} ] ; then
311 cfg_file=configure.in.base
313 if [ -e ${module_src}/${cfg_file} ] ; then
314 vx=`grep -e "^VERSION=" ${module_src}/${cfg_file} | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
316 px=${BUILD_DIR}/${module}
317 if [ "$prefix" != "" ] ; then
320 if [ "$vx" != "" ] ; then
323 #########################################################
324 # perform configure if -c flag is given or if
325 # Makefile does not exist (first compilation?)
326 #########################################################
327 if [ $is_configure -eq 1 ] || [ $mkfile_exist -eq 0 ] || [ $opts_changed -eq 1 ] ; then
328 echo "... Performing configure"
329 #########################################################
330 # check if configure script exists
331 #########################################################
332 if [ ! -e ${module_src}/configure ] ; then
334 echo '!!! Warning !!! Can not find configure script in '${module_src}'.'
337 if [ $med_with_gui -eq 0 ] && [ "${module}" == "MED" ] ; then
338 add_keys="--without-ihm"
340 if [ "${module}" == "MED" ] && [ "${METISDIR}" != "" ] && [ "${SCOTCHDIR}" != "" ] ; then
341 add_keys="--enable-splitter=yes --with-metis=${METISDIR} --with-scotch=${SCOTCHDIR}"
343 if [ "${module}" == "NETGENPLUGIN" ] && [ "$NETGENHOME" != "" ] ; then
344 add_keys="--with-netgen=${NETGENHOME}"
346 ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
347 #########################################################
348 # echo possible errors
349 #########################################################
350 if [ $verbose_level -gt 0 ] ; then
351 cat ${LOG_DIR}/configure_${module}.log | grep ": error:" >&2
353 if [ $verbose_level -gt 1 ] ; then
354 cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" >&2
358 #########################################################
360 #########################################################
361 echo "... Performing make"
362 #########################################################
363 # first clear dependencies
364 #########################################################
365 find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null
366 make >& ${LOG_DIR}/make_${module}.log
368 #########################################################
369 # if make step is successful set the ${module}_ROOT_DIR
370 # environment variable
371 #########################################################
372 if [ $sts -eq 0 ] ; then
373 export ${module}_ROOT_DIR=${module_build}
375 #########################################################
377 #########################################################
378 cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]' >&2
379 #########################################################
380 # print compiler errors and warnings
381 # Note: here awk is used to concatenate together several lines of single
382 # error or warning message produced by stupid gnu compiler
383 # Actually, instead of that we could use 'fmessage length=n' option of g++...
384 #########################################################
385 if [ $verbose_level -gt 0 ] ; then
386 ###cat ${LOG_DIR}/make_${module}.log | grep ": error"
387 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
389 if [ $verbose_level -gt 1 ] ; then
390 cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {printf $0} END {print ""}' | grep ": warning" | sed s@"^${module_src}/src/"@@ >&2
392 #########################################################
393 # perform make dev_docs step if -t flag is given
394 #########################################################
395 if [ $is_tui -eq 1 ] && [ $sts -eq 0 ] && [ -d ${module_build}/doc ] ; then
396 cd ${module_build}/doc
397 dd=`cat Makefile | grep -E "dev_docs[[:space:]]*:"`
398 if [ "$dd" != "" ] ; then
399 echo "... Performing make dev_docs"
400 make dev_docs >& ${LOG_DIR}/make_dev_docs_${module}.log
401 cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' >&2
405 #########################################################
406 # perform make if -i or -p flags are given
407 #########################################################
408 if [ $is_install -eq 1 ] && [ $sts -eq 0 ] || [ "${module}" == "KERNEL" ] ; then
409 #########################################################
410 # deleting build directory if -d flag is given
411 #########################################################
412 if [ -e $px ] && [ $is_delete -eq 1 ] ; then
413 echo "... Removing $px"
416 echo "... Performing make install"
417 make install >& ${LOG_DIR}/make_install_${module}.log
419 #########################################################
420 # if make install step is successful set the
421 # ${module}_ROOT_DIR environment variable
422 #########################################################
423 if [ $sts -eq 0 ] ; then
424 export ${module}_ROOT_DIR=$px
427 echo ">>> Finished ${module} module"
430 echo '!!! Error !!! Cannot find module sources. '${module}'_SRC_DIR environment variable is not set.'
434 #########################################################
436 #########################################################
440 echo "==========================================================================="
441 echo "SALOME build finished at `date`"
442 echo "==========================================================================="