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
24 set modules=(KERNEL GUI GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT)
31 #########################################################
33 #########################################################
35 if ( "$1" == "-b" ) then
36 set is_build_configure=1
38 else if ( "$1" == "-c" ) then
40 else if ( "$1" == "-d" ) then
42 else if ( "$1" == "-o" ) then
43 set optim="--enable-production=yes --disable-debug"
44 else if ( "$1" == "-i" ) then
46 else if ( "$1" == "-v" ) then
49 else if ( "$1" == "-p" ) then
53 else if ( "$1" == "-h" ) then
55 else if ( "$1" == "-t" ) then
58 set ckt=`echo ${modules} | grep $1`
59 if ( "$ckt" != "" ) then
60 set params="$params $1"
62 set b_params="$b_params $1"
63 echo "\!\!\! Warning \!\!\! Unknown module: $1. Skipping."
69 #########################################################
70 # if -h option is given - print help info and exit
71 #########################################################
72 if ( $is_help == 1 ) then
76 echo " Builds given SALOME modules by performing make and (optionally) make install commands"
79 echo " build.csh [ <option> ] ... [ <module> [ <module> ... ] ]"
81 echo "<module> Modules to build, separated by space(s)."
82 echo " If no modules are given - all SALOME modules are assumed."
83 echo " Note, that modules given in command lines are automatically sorted in such order"
84 echo " to support correct modules dependencies."
87 echo "-b Perform build_configure command for all given modules."
88 echo " This option forces configure (-c) key to be set. Default is off."
90 echo "-c Perform configure command for all given modules. Default is off."
92 echo "-d Delete build directories before calling configure, to enforce full rebuild"
93 echo " (and reinstall if -i or -p option is used) of module."
94 echo " Use this option carefully."
96 echo "-o Build sources in optimized mode. Default is off that means debug mode."
97 echo " Use this option together with -c or -b."
98 echo " This option can require -d option to be set (to ensure that previously"
99 echo " created build directories are removed to enforce rebuild in optimized mode)."
101 echo "-t Performs make dev_docs step to build TUI documentation for those modules"
102 echo " which support this. Default is off."
104 echo "-i Performs make install step. Default is off that means only make step."
106 echo "-p <prefix> Define the directory where to install modules after compilation."
107 echo " By default the directory where compilation is performed is used."
109 echo "-v <level> Verbose level (0-2, default 2): print information on build status:"
110 echo " 0: only 'make' errors"
111 echo " 1: 0 + compiler and other errors (including build_configure, configure)"
112 echo " 2: 1 + compiler and other warnings "
114 echo "-h Prints this help information."
116 echo "Note: If no keys are given script just performs make step."
119 echo " ./build.csh -o -i -b KERNEL MED GEOM"
121 echo " This will make KERNEL, GEOM and MED modules: build_configure, configure, make"
122 echo " and install procedures will be performed for all specified modules."
123 echo " The modules will be built in the optimized mode"
128 #########################################################
129 # sort modules in proper order according to the dependancies
130 #########################################################
131 if ( "${params}" != "" ) then
133 foreach module (${modules})
134 set ckt=`echo ${params} | grep ${module}`
135 if ( "$ckt" != "" ) then
136 set xparams="$xparams $module"
139 set modules=($xparams)
141 if ( "${b_params}" != "" ) then
142 echo "Nothing to be built. Exiting."
147 echo ">>> The following SALOME packages will be built:"
150 #########################################################
152 #########################################################
153 set env_script=`dirname $0`/env_build.csh
154 if ( ! -e $env_script ) then
155 set env_script=`dirname $0`/env_products.csh
157 if ( -e $env_script ) then
158 echo ">>> Setting environment"
161 echo "\!\!\! Warning \!\!\! Environment is not set: file env_products.csh is not found."
165 set LOG_DIR=${BUILD_DIR}/LOGS
167 #########################################################
168 # define installation prefix
169 #########################################################
170 if ( "$prefix" == "" ) then
171 set prefix=${BUILD_DIR}/INSTALL
172 if ( $is_install == 1 ) then
173 echo "\!\!\! Warning \!\!\! Installation directory is not set."
174 echo "All the modules will be installed to the $prefix"
176 set is_kernel=`echo ${modules} | grep KERNEL`
177 if ( "$is_kernel" != "" ) then
178 echo "\!\!\! Warning \!\!\! KERNEL module requires install step to be performed."
179 echo "For this module -i option will be forced."
180 echo "The module(s) will be installed to the $prefix"
184 set is_absolute=`echo $prefix | grep -e "^/"`
185 if ( "$is_absolute" == "" ) then
186 set prefix=${BUILD_DIR}/$prefix
187 echo "\!\!\! Warning \!\!\! Relative prefix is used."
188 echo "All the modules will be installed to the $prefix"
192 #########################################################
193 # create log directory
194 #########################################################
195 if ( ! -e ${LOG_DIR} ) then
199 echo "==========================================================================="
200 echo "Starting SALOME build at `date`"
201 echo "==========================================================================="
203 #########################################################
204 # loop for all given modules
205 #########################################################
206 foreach module (${modules})
207 echo ">>> Processing ${module} module"
209 set module_src=`printenv ${module}_SRC_DIR`
210 set module_build=${BUILD_DIR}/${module}_BUILD
212 if ( ${module_src} != "" ) then
215 #########################################################
216 # check if sources directory exists
217 #########################################################
218 if ( ! -e ${module_src} ) then
219 echo "\!\!\! Error \!\!\! Can't find sources directory: ${module_src} does not exist."
222 #########################################################
223 # check if configure script exists
224 #########################################################
226 if ( -e ${module_src}/configure ) then
229 #########################################################
230 # perform build_configure if -b flag is given or if
231 # configure script does not exist (first compilation?)
232 #########################################################
233 if ( $is_build_configure == 1 || $cfg_exist == 0 ) then
234 echo "... Performing build_configure"
235 #########################################################
236 # check if build_configure script exists
237 #########################################################
238 if ( ! -e ${module_src}/build_configure ) then
239 echo "\!\!\! Warning \!\!\! Can not find build_configure script in ${module_src}."
241 #########################################################
242 # call build_configure
243 #########################################################
245 ./build_configure >& ${LOG_DIR}/build_configure_${module}.log
246 #########################################################
247 # echo possible errors
248 #########################################################
249 if ( $verbose_level > 0 ) then
250 cat ${LOG_DIR}/build_configure_${module}.log | grep -E "(failed|: error:)" > /dev/stderr
254 #########################################################
255 # deleting build directory if -d flag is given
256 #########################################################
257 if ( -e ${module_build} && $is_delete == 1 ) then
258 echo "... Removing ${module_build}"
259 rm -rf ${module_build}
261 #########################################################
262 # creating build directory if it does not exist
263 #########################################################
264 if ( ! -e ${module_build} ) then
265 mkdir -p ${module_build}
268 #########################################################
269 # check if top Makefile exists in build directory, i.e.
270 # is it necessary to run configure script
271 #########################################################
273 if ( -e ${module_build}/Makefile ) then
276 #########################################################
277 # check if configure options are changed from the
279 #########################################################
281 ## if ( -f ${module_build}/config.log ) then
282 ## set old_prefix=`grep -e '^prefix=' ${module_build}/config.log | sed -e "s%^prefix='\(.*\)'%\1%"`
283 ## if ( "$old_prefix" != "$prefix" ) then
284 ## set opts_changed=1
287 #########################################################
288 # define installation directory (by using module's version
289 # number); default is a build directory
290 #########################################################
292 set cfg_file=configure.ac
293 if ( ! -e ${module_src}/${cfg_file} ) then
294 set cfg_file=configure.in.base
296 if ( -e ${module_src}/${cfg_file} ) then
297 set vx=`grep -e "^VERSION=" ${module_src}/${cfg_file} | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
299 set px=${BUILD_DIR}/${module}
300 if ( "$prefix" != "" ) then
301 set px=$prefix/${module}
303 if ( "$vx" != "" ) then
306 #########################################################
307 # perform configure if -c flag is given or if
308 # Makefile does not exist (first compilation?)
309 #########################################################
310 if ( $is_configure == 1 || $mkfile_exist == 0 || $opts_changed == 1 ) then
311 echo "... Performing configure"
312 #########################################################
313 # check if configure script exists
314 #########################################################
315 if ( ! -e ${module_src}/configure ) then
316 echo "\!\!\! Warning \!\!\! Can not find configure script in ${module_src}."
318 if ( "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
319 set add_keys="--with-netgen=${NETGENHOME}"
321 ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
322 #########################################################
323 # echo possible errors
324 #########################################################
325 if ( $verbose_level > 0 ) then
326 cat ${LOG_DIR}/configure_${module}.log | grep ": error:" > /dev/stderr
328 if ( $verbose_level > 1 ) then
329 cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:" > /dev/stderr
333 #########################################################
335 #########################################################
336 echo "... Performing make"
337 #########################################################
338 # first clear dependencies
339 #########################################################
340 find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null
341 make >& ${LOG_DIR}/make_${module}.log
343 #########################################################
344 # if make step is successful set the ${module}_ROOT_DIR
345 # environment variable
346 #########################################################
347 if ( $sts == 0 ) then
348 setenv ${module}_ROOT_DIR ${module_build}
350 #########################################################
352 #########################################################
353 cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]' > /dev/stderr
354 #########################################################
355 # print compiler errors and warnings
356 # Note: here awk is used to concatenate together several lines of single
357 # error or warning message produced by stupid gnu compiler
358 # Actually, instead of that we could use 'fmessage length=n' option of g++...
359 #########################################################
360 if ( $verbose_level > 0 ) then
361 ###cat ${LOG_DIR}/make_${module}.log | grep ": error"
362 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
364 if ( $verbose_level > 1 ) then
365 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
367 #########################################################
368 # perform make dev_docs step if -t flag is given
369 #########################################################
370 if ( $is_tui == 1 && $sts == 0 && -d ${module_build}/doc ) then
371 cd ${module_build}/doc
372 set dd=`cat Makefile | grep -E "dev_docs[[:space:]]*:"`
373 if ( "$dd" != "" ) then
374 echo "... Performing make dev_docs"
375 make dev_docs >& ${LOG_DIR}/make_dev_docs_${module}.log
376 cat ${LOG_DIR}/make_dev_docs_${module}.log | grep '[*][*][*]' > /dev/stderr
380 #########################################################
381 # perform make if -i or -p flags are given
382 #########################################################
383 if ( $is_install == 1 && $sts == 0 || "${module}" == "KERNEL" ) then
384 #########################################################
385 # deleting build directory if -d flag is given
386 #########################################################
387 if ( -e $px && $is_delete == 1 ) then
388 echo "... Removing $px"
391 echo "... Performing make install"
392 make install >& ${LOG_DIR}/make_install_${module}.log
394 #########################################################
395 # if make install step is successful set the
396 # ${module}_ROOT_DIR environment variable
397 #########################################################
398 if ( $sts == 0 ) then
399 setenv ${module}_ROOT_DIR $px
402 echo ">>> Finished ${module} module"
404 echo "\!\!\! Error \!\!\! Can't find module sources. ${module}_SRC_DIR environment variable is not set."
407 #########################################################
409 #########################################################
412 echo "==========================================================================="
413 echo "SALOME build finished at `date`"
414 echo "==========================================================================="