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-2008 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.csh -h for more details about usage.
16 ####################################################################################
18 set is_build_configure=0
24 set modules=(KERNEL GUI GEOM MED SMESH VISU PARAVIS YACS NETGENPLUGIN GHS3DPLUGIN BLSURFPLUGIN HexoticPLUGIN GHS3DPRLPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT PYLIGHT SIERPINSKY RANDOMIZER MULTIPR ATOMIC ATOMGEN ATOMSOLV JOBMANAGER)
30 set def_install_dir="/INSTALL"
33 #########################################################
35 #########################################################
37 if ( "$1" == "-b" ) then
38 set is_build_configure=1
40 else if ( "$1" == "-c" ) then
42 else if ( "$1" == "-w" ) then
44 else if ( "$1" == "-d" ) then
46 else if ( "$1" == "-o" ) then
47 set optim="--enable-production=yes --disable-debug"
48 else if ( "$1" == "-v" ) then
51 else if ( "$1" == "-p" ) then
55 else if ( "$1" == "-h" ) then
57 else if ( "$1" == "-t" ) then
60 set ckt=`echo ${modules} | grep -E "\<$1\>"`
61 if ( "$ckt" != "" ) then
62 set params="$params $1"
64 set b_params="$b_params $1"
65 echo "\!\!\! Warning \!\!\! Unknown module: $1."
71 #########################################################
72 # if -h option is given - print help info and exit
73 #########################################################
74 if ( $is_help == 1 ) then
78 echo " Builds given SALOME modules by performing make and make install commands"
81 echo " build.csh [ <option> ] ... [ <module> [ <module> ... ] ]"
83 echo "<module> Modules to build, separated by space(s)."
84 echo " If no modules are given - all SALOME modules are assumed."
85 echo " Note, that modules given in command lines are automatically sorted in such order"
86 echo " to support correct modules dependencies."
89 echo "-b Perform build_configure command for all given modules."
90 echo " This option forces configure (-c) key to be set. Default is off."
92 echo "-c Perform configure command for all given modules. Default is off."
94 echo "-w Add --without-gui key to build_configure and configure commands"
95 echo " to build SALOME module sources without GUI."
96 echo " By default sources are built with GUI."
98 echo "-d Delete build directories before calling configure, to force full rebuild"
99 echo " and reinstall of the module."
100 echo " Use this option carefully."
102 echo "-o Build sources in optimized mode. Default is off that means debug mode."
103 echo " Use this option together with -c or -b."
104 echo " This option can require -d option to be set (to ensure that previously"
105 echo " created build directories are removed to enforce rebuild in optimized mode)."
107 echo "-t Performs make dev_docs step to build TUI documentation for those modules"
108 echo " which support this. Default is off."
110 echo "-p <prefix> Define the directory where to install modules after compilation."
111 echo " By default the directory where compilation is performed is used."
113 echo "-v <level> Verbose level (0-2, default 2): print information on build status:"
114 echo " 0: only 'make' errors"
115 echo " 1: 0 + compiler and other errors (including build_configure, configure)"
116 echo " 2: 1 + compiler and other warnings "
118 echo "-h Prints this help information."
120 echo "Note: If no keys are given script just performs make step."
123 echo " ./build.csh -o -p /home/user/salome -b KERNEL MED GEOM"
125 echo " This will make KERNEL, GEOM and MED modules: build_configure, configure, make"
126 echo " and install procedures will be performed for all specified modules."
127 echo " The modules will be built in the optimized mode"
132 #########################################################
133 # sort modules in proper order according to the dependancies
134 #########################################################
135 if ( "${params}" != "" ) then
137 foreach module (${modules})
138 set ckt=`echo ${params} | grep -E "\<${module}\>"`
139 if ( "$ckt" != "" ) then
140 set xparams="$xparams $module"
143 set modules=($xparams $b_params)
144 else if ( "${b_params}" != "" ) then
145 set modules=($b_params)
148 echo ">>> The following modules will be built:"
151 #########################################################
153 #########################################################
154 set env_script=`dirname $0`/env_build.csh
155 if ( ! -e $env_script ) then
156 set env_script=`dirname $0`/env_products.csh
158 if ( ! -e $env_script ) then
159 set env_script=`dirname $0`/env.sh
161 if ( -e $env_script ) then
162 echo ">>> Setting environment"
165 echo "\!\!\! Warning \!\!\! Environment is not set."
166 echo "No environment file (env_build.sh, env_products.sh, env.sh) is found."
167 echo "Proceed with the current environment."
171 set LOG_DIR=${BUILD_DIR}/LOGS
173 #########################################################
174 # define installation prefix
175 #########################################################
176 if ( "$prefix" == "" ) then
177 echo "\!\!\! Warning \!\!\! Installation directory is not set."
178 echo "All the modules will be installed to the ${BUILD_DIR}${def_install_dir}"
180 set is_absolute=`echo $prefix | grep -e "^/"`
181 if ( "$is_absolute" == "" ) then
182 set prefix=${BUILD_DIR}/$prefix
183 echo "\!\!\! Warning \!\!\! Relative prefix is used."
184 echo "All the modules will be installed to the $prefix"
188 #########################################################
189 # create log directory
190 #########################################################
191 if ( ! -e ${LOG_DIR} ) then
195 echo "==========================================================================="
196 echo "Starting SALOME build at `date`"
197 echo "==========================================================================="
199 #########################################################
200 # loop for all given modules
201 #########################################################
202 foreach module (${modules})
203 echo ">>> Processing ${module} module"
205 set module_src=`printenv ${module}_SRC_DIR`
206 set module_build=${BUILD_DIR}/${module}_BUILD
208 if ( ${module_src} != "" ) then
210 #########################################################
211 # check if sources directory exists
212 #########################################################
213 if ( ! -e ${module_src} ) then
214 echo "\!\!\! Error \!\!\! Can't find sources directory: ${module_src} does not exist."
217 #########################################################
218 # check if configure script exists
219 #########################################################
221 if ( -e ${module_src}/configure ) then
224 #########################################################
225 # perform build_configure if -b flag is given or if
226 # configure script does not exist (first compilation?)
227 #########################################################
228 if ( $is_build_configure == 1 || $cfg_exist == 0 ) then
229 echo "... Performing build_configure"
230 #########################################################
231 # check if build_configure script exists
232 #########################################################
233 if ( ! -e ${module_src}/build_configure && "${module}" != "PARAVIS" ) then
234 echo "\!\!\! Warning \!\!\! Can not find build_configure script in ${module_src}."
236 if ( "${module}" == "PARAVIS" ) then
237 echo "\!\!\! Warning \!\!\! build_configure step is not executed for ${module}."
239 #########################################################
240 # call build_configure
241 #########################################################
242 if (! ($?BUILDCONF_OPTS) ) then
243 set mybuildconf_keys=""
245 set mybuildconf_keys="${BUILDCONF_OPTS}"
247 if ( $inst_with_gui == 0 ) then
248 set mybuildconf_keys="${mybuildconf_keys} --without-gui"
251 ./build_configure ${mybuildconf_keys} >& ${LOG_DIR}/build_configure_${module}.log
252 #########################################################
253 # echo possible errors
254 #########################################################
255 if ( $verbose_level > 0 ) then
256 cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" >/dev/stderr
261 #########################################################
262 # deleting build directory if -d flag is given
263 #########################################################
264 if ( -e ${module_build} && $is_delete == 1 ) then
265 echo "... Removing ${module_build}"
266 chmod -R +w ${module_build} && rm -rf ${module_build} >& /dev/null
267 if ( "$?" != "0" ) then
268 echo "\!\!\! Warning \!\!\! Cannot remove build directory ${module_build}. Permission denied."
271 #########################################################
272 # creating build directory if it does not exist
273 #########################################################
274 if ( ! -e ${module_build} ) then
275 mkdir -p ${module_build} >& /dev/null
276 if ( "$?" != "0" ) then
277 echo "\!\!\! Error \!\!\! Cannot create build directory ${module_build}. Permission denied."
282 #########################################################
283 # check if top Makefile exists in build directory, i.e.
284 # is it necessary to run configure script
285 #########################################################
287 if ( -e ${module_build}/Makefile ) then
290 #########################################################
291 # check if configure options are changed from the
293 #########################################################
295 ## if ( -f ${module_build}/config.log ) then
296 ## set old_prefix=`grep -e '^prefix=' ${module_build}/config.log | sed -e "s%^prefix='\(.*\)'%\1%"`
297 ## if ( "$old_prefix" != "$prefix" ) then
298 ## set opts_changed=1
301 #########################################################
302 # define installation directory (by using module's version
303 # number); default is a build directory
304 #########################################################
306 if ( -e ${module_src}/configure.ac ) then
307 set vx=`grep -e "^AC_INIT" ${module_src}/configure.ac | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
308 else if ( -e ${module_src}/configure.in.base ) then
309 set vx=`grep -e "^VERSION=" ${module_src}/configure.in.base | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
310 if ( "$vx" == "" ) then
311 set vx=`grep -e "^AC_INIT" ${module_src}/configure.in.base | sed -e "s%.*\[\([[:digit:].]*\)\].*%\1%g"`
313 else if ( -e ${module_src}/CMakeLists.txt ) then
314 set ver_maj=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MAJOR | sed -e "s%[A-Z_() ]%%g"`
315 set ver_min=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MINOR | sed -e "s%[A-Z_() ]%%g"`
316 set ver_maintenance=`cat ${module_src}/CMakeLists.txt | grep SET\(VERSION_MAINTENANCE | sed -e "s%[A-Z_() ]%%g"`
317 set vx="${ver_maj}.${ver_min}.${ver_maintenance}"
319 if ( "$vx" != "" ) then
322 if ( "$prefix" == "" ) then
323 #set module_root_dir=`printenv ${module}_ROOT_DIR`
324 #if ( "$module_root_dir" != "" ) then
325 # set px=$module_root_dir
327 set px=${BUILD_DIR}${def_install_dir}/${module}${vx}
330 set px=${prefix}/${module}${vx}
332 #########################################################
333 # perform configure if -c flag is given or if
334 # Makefile does not exist (first compilation?)
335 #########################################################
336 if ( $is_configure == 1 || $mkfile_exist == 0 || $opts_changed == 1 ) then
337 echo "... Performing configure"
338 #########################################################
339 # check if configure script exists
340 #########################################################
341 if ( ! -e ${module_src}/configure && "${module}" != "PARAVIS" ) then
342 echo "\!\!\! Warning \!\!\! Can not find configure script in ${module_src}."
344 if (! ($?BUILDCONF_OPTS) ) then
347 set myconf_keys="${CONF_OPTS}"
349 if ( $inst_with_gui == 0 ) then
350 set myconf_keys="${myconf_keys} --without-gui"
352 if ( "${module}" == "MED" && ($?METISDIR) && ($?SCOTCHDIR) ) then
353 set myconf_keys="${myconf_keys} --enable-splitter=yes --with-metis=${METISDIR} --with-scotch=${SCOTCHDIR}"
355 if ( "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
356 set 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
363 #########################################################
364 # echo possible errors
365 #########################################################
366 if ( $verbose_level > 0 ) then
367 cat ${LOG_DIR}/configure_${module}.log | grep ": error:" >/dev/stderr
369 if ( $verbose_level > 1 ) then
370 cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" >/dev/stderr
374 #########################################################
376 #########################################################
377 echo "... Performing make"
378 #########################################################
379 # first clear dependencies
380 #########################################################
381 find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null
382 make >& ${LOG_DIR}/make_${module}.log
384 #########################################################
385 # if make step is successful set the ${module}_ROOT_DIR
386 # environment variable
387 #########################################################
388 #if ( $sts == 0 ) then
389 # setenv ${module}_ROOT_DIR ${module_build}
391 #########################################################
393 #########################################################
394 cat ${LOG_DIR}/make_${module}.log | grep -Ei '[*][*][*].*error' >/dev/stderr
395 #########################################################
396 # print compiler errors and warnings
397 # Note: here awk is used to concatenate together several lines of single
398 # error or warning message produced by stupid gnu compiler
399 # Actually, instead of that we could use 'fmessage length=n' option of g++...
400 #########################################################
401 if ( $verbose_level > 0 ) then
402 ###cat ${LOG_DIR}/make_${module}.log | grep ": error"
403 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/"@@ >/dev/stderr
405 if ( $verbose_level > 1 ) then
406 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/"@@ >/dev/stderr
408 #########################################################
409 # perform make dev_docs step if -t flag is given
410 #########################################################
411 if ( $is_tui == 1 && $sts == 0 && -d ${module_build}/doc ) then
412 cd ${module_build}/doc
413 set dd=`cat Makefile | grep -E "dev_docs[[:space:]]*:"`
414 if ( "$dd" != "" ) then
415 echo "... Performing make dev_docs"
416 make dev_docs >& ${LOG_DIR}/make_dev_docs_${module}.log
417 cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' >/dev/stderr
421 #########################################################
422 # perform make if -i or -p flags are given
423 #########################################################
424 if ( $is_install == 1 && $sts == 0 || "${module}" == "KERNEL" ) then
425 #########################################################
426 # deleting build directory if -d flag is given
427 #########################################################
428 if ( -e $px && $is_delete == 1 ) then
429 echo "... Removing $px"
430 rm -rf $px >& /dev/null
431 if ( "$?" != "0" ) then
432 echo "\!\!\! Warning \!\!\! Cannot remove install directory ${px}. Permission denied."
435 echo "... Performing make install"
436 make install >& ${LOG_DIR}/make_install_${module}.log
438 #########################################################
439 # if make install step is successful set the
440 # ${module}_ROOT_DIR environment variable
441 #########################################################
442 if ( $sts == 0 ) then
443 setenv ${module}_ROOT_DIR $px
446 echo ">>> Finished ${module} module"
448 echo "\!\!\! Error \!\!\! Can't find module sources. ${module}_SRC_DIR environment variable is not set."
451 #########################################################
453 #########################################################
456 echo "==========================================================================="
457 echo "SALOME build finished at `date`"
458 echo "==========================================================================="