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.csh -h for more details about usage.
16 ####################################################################################
18 set is_build_configure=0
25 set modules=(KERNEL GUI GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT)
32 #########################################################
34 #########################################################
36 if ( "$1" == "-b" ) then
37 set is_build_configure=1
39 else if ( "$1" == "-c" ) then
41 else if ( "$1" == "-w" ) then
43 else if ( "$1" == "-d" ) then
45 else if ( "$1" == "-o" ) then
46 set optim="--enable-production=yes --disable-debug"
47 else if ( "$1" == "-i" ) then
49 else if ( "$1" == "-v" ) then
52 else if ( "$1" == "-p" ) then
56 else if ( "$1" == "-h" ) then
58 else if ( "$1" == "-t" ) then
61 set ckt=`echo ${modules} | grep $1`
62 if ( "$ckt" != "" ) then
63 set params="$params $1"
65 set b_params="$b_params $1"
66 echo "\!\!\! Warning \!\!\! Unknown module: $1. Skipping."
72 #########################################################
73 # if -h option is given - print help info and exit
74 #########################################################
75 if ( $is_help == 1 ) then
79 echo " Builds given SALOME modules by performing make and (optionally) make install commands"
82 echo " build.csh [ <option> ] ... [ <module> [ <module> ... ] ]"
84 echo "<module> Modules to build, separated by space(s)."
85 echo " If no modules are given - all SALOME modules are assumed."
86 echo " Note, that modules given in command lines are automatically sorted in such order"
87 echo " to support correct modules dependencies."
90 echo "-b Perform build_configure command for all given modules."
91 echo " This option forces configure (-c) key to be set. Default is off."
93 echo "-c Perform configure command for all given modules. Default is off."
95 echo "-w Add --without-ihm key to build_configure and configure"
96 echo " commands for MED module to build its sources without GUI."
97 echo " By default MED sources are built with GUI."
99 echo "-d Delete build directories before calling configure, to enforce full rebuild"
100 echo " (and reinstall if -i or -p option is used) of module."
101 echo " Use this option carefully."
103 echo "-o Build sources in optimized mode. Default is off that means debug mode."
104 echo " Use this option together with -c or -b."
105 echo " This option can require -d option to be set (to ensure that previously"
106 echo " created build directories are removed to enforce rebuild in optimized mode)."
108 echo "-t Performs make dev_docs step to build TUI documentation for those modules"
109 echo " which support this. Default is off."
111 echo "-i Performs make install step. Default is off that means only make step."
113 echo "-p <prefix> Define the directory where to install modules after compilation."
114 echo " By default the directory where compilation is performed is used."
116 echo "-v <level> Verbose level (0-2, default 2): print information on build status:"
117 echo " 0: only 'make' errors"
118 echo " 1: 0 + compiler and other errors (including build_configure, configure)"
119 echo " 2: 1 + compiler and other warnings "
121 echo "-h Prints this help information."
123 echo "Note: If no keys are given script just performs make step."
126 echo " ./build.csh -o -i -b KERNEL MED GEOM"
128 echo " This will make KERNEL, GEOM and MED modules: build_configure, configure, make"
129 echo " and install procedures will be performed for all specified modules."
130 echo " The modules will be built in the optimized mode"
135 #########################################################
136 # sort modules in proper order according to the dependancies
137 #########################################################
138 if ( "${params}" != "" ) then
140 foreach module (${modules})
141 set ckt=`echo ${params} | grep ${module}`
142 if ( "$ckt" != "" ) then
143 set xparams="$xparams $module"
146 set modules=($xparams)
148 if ( "${b_params}" != "" ) then
149 echo "Nothing to be built. Exiting."
154 echo ">>> The following SALOME packages will be built:"
157 #########################################################
159 #########################################################
160 set env_script=`dirname $0`/env_build.csh
161 if ( ! -e $env_script ) then
162 set env_script=`dirname $0`/env_products.csh
164 if ( -e $env_script ) then
165 echo ">>> Setting environment"
168 echo "\!\!\! Warning \!\!\! Environment is not set: file env_products.csh is not found."
172 set LOG_DIR=${BUILD_DIR}/LOGS
174 #########################################################
175 # define installation prefix
176 #########################################################
177 if ( "$prefix" == "" ) then
178 set prefix=${BUILD_DIR}/INSTALL
179 if ( $is_install == 1 ) then
180 echo "\!\!\! Warning \!\!\! Installation directory is not set."
181 echo "All the modules will be installed to the $prefix"
183 set is_kernel=`echo ${modules} | grep KERNEL`
184 if ( "$is_kernel" != "" ) then
185 echo "\!\!\! Warning \!\!\! KERNEL module requires install step to be performed."
186 echo "For this module -i option will be forced."
187 echo "The module(s) will be installed to the $prefix"
191 set is_absolute=`echo $prefix | grep -e "^/"`
192 if ( "$is_absolute" == "" ) then
193 set prefix=${BUILD_DIR}/$prefix
194 echo "\!\!\! Warning \!\!\! Relative prefix is used."
195 echo "All the modules will be installed to the $prefix"
199 #########################################################
200 # create log directory
201 #########################################################
202 if ( ! -e ${LOG_DIR} ) then
206 echo "==========================================================================="
207 echo "Starting SALOME build at `date`"
208 echo "==========================================================================="
210 #########################################################
211 # loop for all given modules
212 #########################################################
213 foreach module (${modules})
214 echo ">>> Processing ${module} module"
216 set module_src=`printenv ${module}_SRC_DIR`
217 set module_build=${BUILD_DIR}/${module}_BUILD
219 if ( ${module_src} != "" ) then
222 #########################################################
223 # check if sources directory exists
224 #########################################################
225 if ( ! -e ${module_src} ) then
226 echo "\!\!\! Error \!\!\! Can't find sources directory: ${module_src} does not exist."
229 #########################################################
230 # check if configure script exists
231 #########################################################
233 if ( -e ${module_src}/configure ) 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 == 1 || $cfg_exist == 0 ) then
241 echo "... Performing build_configure"
242 #########################################################
243 # check if build_configure script exists
244 #########################################################
245 if ( ! -e ${module_src}/build_configure ) then
246 echo "\!\!\! Warning \!\!\! Can not find build_configure script in ${module_src}."
248 #########################################################
249 # call build_configure
250 #########################################################
251 if ( $med_with_gui == 0 && "${module}" == "MED" ) then
252 set add_keys="--without-ihm"
255 ./build_configure ${add_keys} >& ${LOG_DIR}/build_configure_${module}.log
256 #########################################################
257 # echo possible errors
258 #########################################################
259 if ( $verbose_level > 0 ) then
260 cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" >&2
264 #########################################################
265 # deleting build directory if -d flag is given
266 #########################################################
267 if ( -e ${module_build} && $is_delete == 1 ) then
268 echo "... Removing ${module_build}"
269 rm -rf ${module_build}
271 #########################################################
272 # creating build directory if it does not exist
273 #########################################################
274 if ( ! -e ${module_build} ) then
275 mkdir -p ${module_build}
278 #########################################################
279 # check if top Makefile exists in build directory, i.e.
280 # is it necessary to run configure script
281 #########################################################
283 if ( -e ${module_build}/Makefile ) then
286 #########################################################
287 # check if configure options are changed from the
289 #########################################################
291 ## if ( -f ${module_build}/config.log ) then
292 ## set old_prefix=`grep -e '^prefix=' ${module_build}/config.log | sed -e "s%^prefix='\(.*\)'%\1%"`
293 ## if ( "$old_prefix" != "$prefix" ) then
294 ## set opts_changed=1
297 #########################################################
298 # define installation directory (by using module's version
299 # number); default is a build directory
300 #########################################################
302 set cfg_file=configure.ac
303 if ( ! -e ${module_src}/${cfg_file} ) then
304 set cfg_file=configure.in.base
306 if ( -e ${module_src}/${cfg_file} ) then
307 set vx=`grep -e "^VERSION=" ${module_src}/${cfg_file} | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
309 set px=${BUILD_DIR}/${module}
310 if ( "$prefix" != "" ) then
311 set px=$prefix/${module}
313 if ( "$vx" != "" ) then
316 #########################################################
317 # perform configure if -c flag is given or if
318 # Makefile does not exist (first compilation?)
319 #########################################################
320 if ( $is_configure == 1 || $mkfile_exist == 0 || $opts_changed == 1 ) then
321 echo "... Performing configure"
322 #########################################################
323 # check if configure script exists
324 #########################################################
325 if ( ! -e ${module_src}/configure ) then
326 echo "\!\!\! Warning \!\!\! Can not find configure script in ${module_src}."
328 if ( $med_with_gui == 0 && "${module}" == "MED" ) then
329 set add_keys="--without-ihm"
331 if ( "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
332 set add_keys="--with-netgen=${NETGENHOME}"
334 ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
335 #########################################################
336 # echo possible errors
337 #########################################################
338 if ( $verbose_level > 0 ) then
339 cat ${LOG_DIR}/configure_${module}.log | grep ": error:" >&2
341 if ( $verbose_level > 1 ) then
342 cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" >&2
346 #########################################################
348 #########################################################
349 echo "... Performing make"
350 #########################################################
351 # first clear dependencies
352 #########################################################
353 find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null
354 make >& ${LOG_DIR}/make_${module}.log
356 #########################################################
357 # if make step is successful set the ${module}_ROOT_DIR
358 # environment variable
359 #########################################################
360 if ( $sts == 0 ) then
361 setenv ${module}_ROOT_DIR ${module_build}
363 #########################################################
365 #########################################################
366 cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]' >&2
367 #########################################################
368 # print compiler errors and warnings
369 # Note: here awk is used to concatenate together several lines of single
370 # error or warning message produced by stupid gnu compiler
371 # Actually, instead of that we could use 'fmessage length=n' option of g++...
372 #########################################################
373 if ( $verbose_level > 0 ) then
374 ###cat ${LOG_DIR}/make_${module}.log | grep ": error"
375 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
377 if ( $verbose_level > 1 ) then
378 cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {printf $0} END {print ""}' | grep ": warning" | sed s@"^${module_src}/src/"@@ >&2
380 #########################################################
381 # perform make dev_docs step if -t flag is given
382 #########################################################
383 if ( $is_tui == 1 && $sts == 0 && -d ${module_build}/doc ) then
384 cd ${module_build}/doc
385 set dd=`cat Makefile | grep -E "dev_docs[[:space:]]*:"`
386 if ( "$dd" != "" ) then
387 echo "... Performing make dev_docs"
388 make dev_docs >& ${LOG_DIR}/make_dev_docs_${module}.log
389 cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' >&2
393 #########################################################
394 # perform make if -i or -p flags are given
395 #########################################################
396 if ( $is_install == 1 && $sts == 0 || "${module}" == "KERNEL" ) then
397 #########################################################
398 # deleting build directory if -d flag is given
399 #########################################################
400 if ( -e $px && $is_delete == 1 ) then
401 echo "... Removing $px"
404 echo "... Performing make install"
405 make install >& ${LOG_DIR}/make_install_${module}.log
407 #########################################################
408 # if make install step is successful set the
409 # ${module}_ROOT_DIR environment variable
410 #########################################################
411 if ( $sts == 0 ) then
412 setenv ${module}_ROOT_DIR $px
415 echo ">>> Finished ${module} module"
417 echo "\!\!\! Error \!\!\! Can't find module sources. ${module}_SRC_DIR environment variable is not set."
420 #########################################################
422 #########################################################
425 echo "==========================================================================="
426 echo "SALOME build finished at `date`"
427 echo "==========================================================================="