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.csh [ <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 "-d Delete build directories before calling configure, to enforce full"
42 echo " rebuild (and reinstall if -i or -p option is used) of module."
43 echo " Use this option carefully."
45 echo "-o Build sources in optimized mode. Default is off that means"
47 echo " Use this option together with -c or -b."
48 echo " This option can require -d option to be set (to ensure that"
49 echo " previously created build directories are removed to enforce"
50 echo " rebuild in optimized mode)."
52 echo "-t Performs make dev_docs step to build TUI documentation for those"
53 echo " modules which support this. Default is off."
55 echo "-i Performs make install step. Default is off that means only make"
58 echo "-p <prefix> Define the directory where to install modules after compilation."
59 echo " By default the directory where compilation is performed is used."
61 echo "-v <level> Verbose level (0-2, default 2): print information on build status:"
62 echo " 0: only 'make' errors"
63 echo " 1: 0 + compiler and other errors (build_configure, configure)"
64 echo " 2: 1 + compiler and other warnings "
66 echo "-h Prints this help information."
68 echo "Note: If no keys are given script just performs make step."
71 echo " ./build.csh -o -i -b KERNEL MED GEOM"
73 echo " This will make KERNEL, GEOM and MED modules: build_configure,"
74 echo " configure, make and install procedures will be performed for all"
75 echo " specified modules. The modules will be built in the optimized mode."
86 modules="KERNEL GUI GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT"
92 #########################################################
94 #########################################################
95 while getopts ":hbcdoitv:p:" option ; do
98 b ) is_build_configure=1 ; is_configure=1 ;;
101 o ) optim="--enable-production=yes --disable-debug" ;;
104 v ) verbose_level=$OPTARG ;;
105 p ) is_install=1 ; prefix=$OPTARG ;;
109 # shift to have the good number of other args
110 shift $((OPTIND - 1))
114 for m in $modules ; do
115 if [ "$m" == "$arg" ] ; then known=1 ; break ; fi
117 if [ $known -eq 1 ] ; then
118 params="$params $arg"
120 b_params="$b_params $arg"
122 echo '!!! Warning !!! Unknown module: '$arg'. Skipping.'
126 #########################################################
127 # sort modules in proper order according to the dependancies
128 #########################################################
129 if [ "${params}" != "" ] ; then
131 for module in ${modules} ; do
133 for p in $params ; do
134 if [ "$p" == "$module" ] ; then found=1 ; break ; fi
136 if [ $found -eq 1 ] ; then xparams="$xparams $module" ; fi
139 elif [ "${b_params}" != "" ] ; then
141 echo "Nothing to be built. Exiting."
147 echo ">>> The following SALOME packages will be built:"
150 #########################################################
152 #########################################################
153 env_script=`dirname $0`/env_build.sh
154 if [ ! -e $env_script ] ; then
155 env_script=`dirname $0`/env_products.sh
157 if [ -e $env_script ] ; then
159 echo ">>> Setting environment"
163 echo '!!! Warning !!! Environment is not set.'
164 echo 'Neither env_build.sh nor env_products.sh file is found.'
165 echo 'Proceed with the current environment.'
169 LOG_DIR=${BUILD_DIR}/LOGS
171 #########################################################
172 # define installation prefix
173 #########################################################
174 if [ "$prefix" == "" ] ; then
175 prefix=${BUILD_DIR}/INSTALL
176 if [ $is_install -eq 1 ] ; then
178 echo '!!! Warning !!! Installation directory is not set.'
179 echo "All the modules will be installed to the $prefix"
180 elif [ "`echo ${modules} | grep KERNEL`" != "" ] ; then
182 echo '!!! Warning !!! KERNEL module requires install step to be performed.'
183 echo "For this module -i option will be forced."
184 echo "The module(s) will be installed to the $prefix"
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
220 #########################################################
221 # check if sources directory exists
222 #########################################################
223 if [ ! -e ${module_src} ] ; then
225 echo '!!! Error !!! Cannot find module sources directory:'
226 echo "${module_src} does not exist."
230 #########################################################
231 # check if configure script exists
232 #########################################################
234 if [ -e ${module_src}/configure ] ; then
237 #########################################################
238 # perform build_configure if -b flag is given or if
239 # configure script does not exist (first compilation?)
240 #########################################################
241 if [ $is_build_configure -eq 1 ] || [ $cfg_exist -eq 0 ] ; then
242 echo "... Performing build_configure"
243 #########################################################
244 # check if build_configure script exists
245 #########################################################
246 if [ ! -e ${module_src}/build_configure ] ; then
247 echo '!!! Warning !!! Cannot find build_configure script in '${module_src}'.'
249 #########################################################
250 # call build_configure
251 #########################################################
253 ./build_configure >& ${LOG_DIR}/build_configure_${module}.log
254 #########################################################
255 # echo possible errors
256 #########################################################
257 if [ $verbose_level -gt 0 ] ; then
258 cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" > /dev/stderr
262 #########################################################
263 # deleting build directory if -d flag is given
264 #########################################################
265 if [ -e ${module_build} ] && [ $is_delete -eq 1 ] ; then
266 echo "... Removing ${module_build}"
267 rm -rf ${module_build}
269 #########################################################
270 # creating build directory if it does not exist
271 #########################################################
272 if [ ! -e ${module_build} ] ; then
273 mkdir -p ${module_build}
276 #########################################################
277 # check if top Makefile exists in build directory, i.e.
278 # is it necessary to run configure script
279 #########################################################
281 if [ -e ${module_build}/Makefile ] ; then
284 #########################################################
285 # check if configure options are changed from the
287 #########################################################
289 ## if [ -f ${module_build}/config.log ] ; then
290 ## old_prefix=`grep -e '^prefix=' ${module_build}/config.log | sed -e "s%^prefix='\(.*\)'%\1%"`
291 ## if [ "$old_prefix" != "$prefix" ] ; then
295 #########################################################
296 # define installation directory (by using module's version
297 # number); default is a build directory
298 #########################################################
300 cfg_file=configure.ac
301 if [ ! -e ${module_src}/${cfg_file} ] ; then
302 cfg_file=configure.in.base
304 if [ -e ${module_src}/${cfg_file} ] ; then
305 vx=`grep -e "^VERSION=" ${module_src}/${cfg_file} | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
307 px=${BUILD_DIR}/${module}
308 if [ "$prefix" != "" ] ; then
311 if [ "$vx" != "" ] ; then
314 #########################################################
315 # perform configure if -c flag is given or if
316 # Makefile does not exist (first compilation?)
317 #########################################################
318 if [ $is_configure -eq 1 ] || [ $mkfile_exist -eq 0 ] || [ $opts_changed -eq 1 ] ; then
319 echo "... Performing configure"
320 #########################################################
321 # check if configure script exists
322 #########################################################
323 if [ ! -e ${module_src}/configure ] ; then
325 echo '!!! Warning !!! Can not find configure script in '${module_src}'.'
328 if [ "${module}" == "NETGENPLUGIN" ] && [ "$NETGENHOME" != "" ] ; then
329 add_keys="--with-netgen=${NETGENHOME}"
331 ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
332 #########################################################
333 # echo possible errors
334 #########################################################
335 if [ $verbose_level -gt 0 ] ; then
336 cat ${LOG_DIR}/configure_${module}.log | grep ": error:" > /dev/stderr
338 if [ $verbose_level -gt 1 ] ; then
339 cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" > /dev/stderr
343 #########################################################
345 #########################################################
346 echo "... Performing make"
347 #########################################################
348 # first clear dependencies
349 #########################################################
350 find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null
351 make >& ${LOG_DIR}/make_${module}.log
353 #########################################################
354 # if make step is successful set the ${module}_ROOT_DIR
355 # environment variable
356 #########################################################
357 if [ $sts -eq 0 ] ; then
358 export ${module}_ROOT_DIR=${module_build}
360 #########################################################
362 #########################################################
363 cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]' > /dev/stderr
364 #########################################################
365 # print compiler errors and warnings
366 # Note: here awk is used to concatenate together several lines of single
367 # error or warning message produced by stupid gnu compiler
368 # Actually, instead of that we could use 'fmessage length=n' option of g++...
369 #########################################################
370 if [ $verbose_level -gt 0 ] ; then
371 ###cat ${LOG_DIR}/make_${module}.log | grep ": error"
372 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
374 if [ $verbose_level -gt 1 ] ; then
375 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
377 #########################################################
378 # perform make dev_docs step if -t flag is given
379 #########################################################
380 if [ $is_tui -eq 1 ] && [ $sts -eq 0 ] && [ -d ${module_build}/doc ] ; then
381 cd ${module_build}/doc
382 dd=`cat Makefile | grep -E "dev_docs[[:space:]]*:"`
383 if [ "$dd" != "" ] ; then
384 echo "... Performing make dev_docs"
385 make dev_docs >& ${LOG_DIR}/make_dev_docs_${module}.log
386 cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' > /dev/stderr
390 #########################################################
391 # perform make if -i or -p flags are given
392 #########################################################
393 if [ $is_install -eq 1 ] && [ $sts -eq 0 ] || [ "${module}" == "KERNEL" ] ; then
394 #########################################################
395 # deleting build directory if -d flag is given
396 #########################################################
397 if [ -e $px ] && [ $is_delete -eq 1 ] ; then
398 echo "... Removing $px"
401 echo "... Performing make install"
402 make install >& ${LOG_DIR}/make_install_${module}.log
404 #########################################################
405 # if make install step is successful set the
406 # ${module}_ROOT_DIR environment variable
407 #########################################################
408 if [ $sts -eq 0 ] ; then
409 export ${module}_ROOT_DIR=$px
412 echo ">>> Finished ${module} module"
415 echo '!!! Error !!! Cannot find module sources. '${module}'_SRC_DIR environment variable is not set.'
419 #########################################################
421 #########################################################
425 echo "==========================================================================="
426 echo "SALOME build finished at `date`"
427 echo "==========================================================================="