2 ##################################################################################################
4 # Description: Build and install SALOME modules from sources
5 # Author : Vadim SANDLER (VSR), Open CASCADE S.A.
7 ##################################################################################################
9 set is_build_configure=0
15 set modules=(KERNEL GUI GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO LIGHT)
22 #########################################################
24 #########################################################
26 if ( "$1" == "-b" ) then
27 set is_build_configure=1
29 else if ( "$1" == "-c" ) then
31 else if ( "$1" == "-d" ) then
33 else if ( "$1" == "-o" ) then
34 set optim="--enable-production=yes --disable-debug"
35 else if ( "$1" == "-i" ) then
37 else if ( "$1" == "-v" ) then
40 else if ( "$1" == "-p" ) then
44 else if ( "$1" == "-h" ) then
46 else if ( "$1" == "-t" ) then
49 set ckt=`echo ${modules} | grep $1`
50 if ( "$ckt" != "" ) then
51 set params="$params $1"
53 set b_params="$b_params $1"
54 echo "\!\!\! Warning \!\!\! Unknown module: $1. Skipping."
60 #########################################################
61 # if -h option is given - print help info and exit
62 #########################################################
63 if ( $is_help == 1 ) then
67 echo " Builds given SALOME2 modules by performing make and (optionally) make install commands"
70 echo " build.csh [ <option> ] ... [ <module> [ <module> ... ] ]"
72 echo "<module> Modules to build, separated by space(s)."
73 echo " If no modules are given - all SALOME2 modules are assumed."
74 echo " Note, that modules given in command lines are automatically sorted in such order"
75 echo " to support correct modules dependencies."
78 echo "-b Perform build_configure command for all given modules."
79 echo " This option forces configure (-c) key to be set. Default is off."
81 echo "-c Perform configure command for all given modules. Default is off."
83 echo "-d Delete build directories before calling configure, to enforce full rebuild"
84 echo " (and reinstall if -i or -p option is used) of module."
85 echo " Use this option carefully."
87 echo "-o Build sources in optimized mode. Default is off that means debug mode."
88 echo " Use this option together with -c or -b."
89 echo " This option can require -d option to be set (to ensure that previously"
90 echo " created build directories are removed to enforce rebuild in optimized mode)."
92 echo "-t Performs make dev_docs step to build TUI documentation for those modules"
93 echo " which support this. Default is off."
95 echo "-i Performs make install step. Default is off that means only make step."
97 echo "-p <prefix> Define the directory where to install modules after compilation."
98 echo " By default the directory where compilation is performed is used."
100 echo "-v <level> Verbose level (0-2, default 2): print information on build status:"
101 echo " 0: only 'make' errors"
102 echo " 1: 0 + compiler and other errors (including build_configure, configure)"
103 echo " 2: 1 + compiler and other warnings "
105 echo "-h Prints this help information."
107 echo "Note: If no keys are given script just performs make step."
110 echo " ./build.csh -o -i -b KERNEL MED GEOM"
112 echo " This will make KERNEL, GEOM and MED modules: build_configure, configure, make"
113 echo " and install procedures will be performed for all specified modules."
114 echo " The modules will be built in the optimized mode"
119 #########################################################
120 # sort modules in proper order according to the dependancies
121 #########################################################
122 if ( "${params}" != "" ) then
124 foreach module (${modules})
125 set ckt=`echo ${params} | grep ${module}`
126 if ( "$ckt" != "" ) then
127 set xparams="$xparams $module"
130 set modules=($xparams)
132 if ( "${b_params}" != "" ) then
133 echo "Nothing to be built. Exiting."
138 echo ">>> The following SALOME packages will be built:"
141 #########################################################
143 #########################################################
144 set env_script=`dirname $0`/env_build.csh
145 if ( ! -e $env_script ) then
146 set env_script=`dirname $0`/env_products.csh
148 if ( -e $env_script ) then
149 echo ">>> Setting environment"
152 echo "\!\!\! Warning \!\!\! Environment is not set: file env_products.csh is not found."
156 set LOG_DIR=${BUILD_DIR}/LOGS
158 #########################################################
159 # define installation prefix
160 #########################################################
161 if ( "$prefix" == "" ) then
162 set prefix=${BUILD_DIR}/INSTALL
163 if ( $is_install == 1 ) then
164 echo "\!\!\! Warning \!\!\! Installation directory is not set."
165 echo "All the modules will be installed to the $prefix"
167 set is_kernel=`echo ${modules} | grep KERNEL`
168 if ( "$is_kernel" != "" ) then
169 echo "\!\!\! Warning \!\!\! KERNEL module requires install step to be performed."
170 echo "For this module -i option will be forced."
171 echo "The module(s) will be installed to the $prefix"
175 set is_absolute=`echo $prefix | grep -e "^/"`
176 if ( "$is_absolute" == "" ) then
177 set prefix=${BUILD_DIR}/$prefix
178 echo "\!\!\! Warning \!\!\! Relative prefix is used."
179 echo "All the modules will be installed to the $prefix"
183 #########################################################
184 # create log directory
185 #########################################################
186 if ( ! -e ${LOG_DIR} ) then
190 echo "==========================================================================="
191 echo "Starting SALOME build at `date`"
192 echo "==========================================================================="
194 #########################################################
195 # loop for all given modules
196 #########################################################
197 foreach module (${modules})
198 echo ">>> Processing ${module} module"
200 set module_src=`printenv ${module}_SRC_DIR`
201 set module_build=${BUILD_DIR}/${module}_BUILD
203 if ( ${module_src} != "" ) then
206 #########################################################
207 # check if sources directory exists
208 #########################################################
209 if ( ! -e ${module_src} ) then
210 echo "\!\!\! Error \!\!\! Can't find sources directory: ${module_src} does not exist."
213 #########################################################
214 # check if configure script exists
215 #########################################################
217 if ( -e ${module_src}/configure ) then
220 #########################################################
221 # perform build_configure if -b flag is given or if
222 # configure script does not exist (first compilation?)
223 #########################################################
224 if ( $is_build_configure == 1 || $cfg_exist == 0 ) then
225 echo "... Performing build_configure"
226 #########################################################
227 # check if build_configure script exists
228 #########################################################
229 if ( ! -e ${module_src}/build_configure ) then
230 echo "\!\!\! Warning \!\!\! Can not find build_configure script in ${module_src}."
232 #########################################################
233 # call build_configure
234 #########################################################
236 ./build_configure >& ${LOG_DIR}/build_configure_${module}.log
237 #########################################################
238 # echo possible errors
239 #########################################################
240 if ( $verbose_level > 0 ) then
241 cat ${LOG_DIR}/build_configure_${module}.log | grep ": error:"
245 #########################################################
246 # deleting build directory if -d flag is given
247 #########################################################
248 if ( -e ${module_build} && $is_delete == 1 ) then
249 echo "... Removing ${module_build}"
250 rm -rf ${module_build}
252 #########################################################
253 # creating build directory if it does not exist
254 #########################################################
255 if ( ! -e ${module_build} ) then
256 mkdir -p ${module_build}
259 #########################################################
260 # check if top Makefile exists in build directory, i.e.
261 # is it necessary to run configure script
262 #########################################################
264 if ( -e ${module_build}/Makefile ) then
267 #########################################################
268 # check if configure options are changed from the
270 #########################################################
272 ## if ( -f ${module_build}/config.log ) then
273 ## set old_prefix=`grep -e '^prefix=' ${module_build}/config.log | sed -e "s%^prefix='\(.*\)'%\1%"`
274 ## if ( "$old_prefix" != "$prefix" ) then
275 ## set opts_changed=1
278 #########################################################
279 # define installation directory (by using module's version
280 # number); default is a build directory
281 #########################################################
283 set cfg_file=configure.ac
284 if ( ! -e ${module_src}/${cfg_file} ) then
285 set cfg_file=configure.in.base
287 if ( -e ${module_src}/${cfg_file} ) then
288 set vx=`grep -e "^VERSION=" ${module_src}/${cfg_file} | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
290 set px=${BUILD_DIR}/${module}
291 if ( "$prefix" != "" ) then
292 set px=$prefix/${module}
294 if ( "$vx" != "" ) then
297 #########################################################
298 # perform configure if -c flag is given or if
299 # Makefile does not exist (first compilation?)
300 #########################################################
301 if ( $is_configure == 1 || $mkfile_exist == 0 || $opts_changed == 1 ) then
302 echo "... Performing configure"
303 #########################################################
304 # check if configure script exists
305 #########################################################
306 if ( ! -e ${module_src}/configure ) then
307 echo "\!\!\! Warning \!\!\! Can not find configure script in ${module_src}."
309 if ( "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
310 set add_keys="--with-netgen=${NETGENHOME}"
312 ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
313 #########################################################
314 # echo possible errors
315 #########################################################
316 if ( $verbose_level > 0 ) then
317 cat ${LOG_DIR}/configure_${module}.log | grep ": error:"
319 if ( $verbose_level > 1 ) then
320 cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:"
324 #########################################################
326 #########################################################
327 echo "... Performing make"
328 #########################################################
329 # first clear dependencies
330 #########################################################
331 find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null
332 make >& ${LOG_DIR}/make_${module}.log
334 #########################################################
335 # if make step is successful set the ${module}_ROOT_DIR
336 # environment variable
337 #########################################################
338 if ( $sts == 0 ) then
339 setenv ${module}_ROOT_DIR ${module_build}
341 #########################################################
343 #########################################################
344 cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]'
345 #########################################################
346 # print compiler errors and warnings
347 # Note: here awk is used to concatenate together several lines of single
348 # error or warning message produced by stupid gnu compiler
349 # Actually, instead of that we could use 'fmessage length=n' option of g++...
350 #########################################################
351 if ( $verbose_level > 0 ) then
352 ###cat ${LOG_DIR}/make_${module}.log | grep ": error"
353 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/"@@
355 if ( $verbose_level > 1 ) then
356 cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {printf $0} END {print ""}' | grep ": warning" | sed s@"^${module_src}/src/"@@
358 #########################################################
359 # perform make dev_docs step if -t flag is given
360 #########################################################
361 if ( $is_tui == 1 && $sts == 0 && -d ${module_build}/doc ) then
362 cd ${module_build}/doc
363 set dd=`cat Makefile | grep -E "dev_docs[[:space:]]*:"`
364 if ( "$dd" != "" ) then
365 echo "... Performing make dev_docs"
366 make dev_docs >& ${LOG_DIR}/make_dev_docs_${module}.log
370 #########################################################
371 # perform make if -i or -p flags are given
372 #########################################################
373 if ( $is_install == 1 && $sts == 0 || "${module}" == "KERNEL" ) then
374 echo "... Performing make install"
375 #########################################################
376 # deleting build directory if -d flag is given
377 #########################################################
378 if ( -e $px && $is_delete == 1 ) then
379 echo "... Removing $px"
382 make install >& ${LOG_DIR}/make_install_${module}.log
384 #########################################################
385 # if make install step is successful set the
386 # ${module}_ROOT_DIR environment variable
387 #########################################################
388 if ( $sts == 0 ) then
389 setenv ${module}_ROOT_DIR $px
392 echo ">>> Finished ${module} module"
394 echo "\!\!\! Error \!\!\! Can't find module sources. ${module}_SRC_DIR environment variable is not set."
397 #########################################################
399 #########################################################
402 echo "==========================================================================="
403 echo "SALOME build finished at `date`"
404 echo "==========================================================================="