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)
21 #########################################################
23 #########################################################
25 if ( "$1" == "-b" ) then
26 set is_build_configure=1
28 else if ( "$1" == "-c" ) then
30 else if ( "$1" == "-d" ) then
32 else if ( "$1" == "-o" ) then
33 set optim="--enable-production=yes --disable-debug"
34 else if ( "$1" == "-i" ) then
36 else if ( "$1" == "-v" ) then
39 else if ( "$1" == "-p" ) then
43 else if ( "$1" == "-h" ) then
46 set ckt=`echo ${modules} | grep $1`
47 if ( "$ckt" != "" ) then
48 set params="$params $1"
50 set b_params="$b_params $1"
51 echo "\!\!\! Warning \!\!\! Unknown module: $1. Skipping."
57 #########################################################
58 # if -h option is given - print help info and exit
59 #########################################################
60 if ( $is_help == 1 ) then
64 echo " Builds given SALOME2 modules by performing make and (optionally) make install commands"
67 echo " build.csh [ <option> ] ... [ <module> [ <module> ... ] ]"
69 echo "<module> Modules to build, separated by space(s)."
70 echo " If no modules are given - all SALOME2 modules are assumed."
71 echo " Note, that modules given in command lines are automatically sorted in such order"
72 echo " to support correct modules dependencies."
75 echo "-b Perform build_configure command for all given modules."
76 echo " This option forces configure (-c) key to be set. Default is off."
78 echo "-c Perform configure command for all given modules. Default is off."
80 echo "-d Delete build directories before calling configure, to enforce full rebuild"
81 echo " (and reinstall if -i or -p option is used) of module."
82 echo " Use this option carefully."
84 echo "-o Build sources in optimized mode. Default is off that means debug mode."
85 echo " Use this option together with -c or -b."
86 echo " This option can require -d option to be set (to ensure that previously"
87 echo " created build directories are removed to enforce rebuild in optimized mode)."
89 echo "-i Performs make install step. Default is off that means only make step."
91 echo "-p <prefix> Define the directory where to install modules after compilation."
92 echo " By default the directory where compilation is performed is used."
94 echo "-v <level> Verbose level (0-2, default 2): print information on build status:"
95 echo " 0: only 'make' errors"
96 echo " 1: 0 + compiler and other errors (including build_configure, configure)"
97 echo " 2: 1 + compiler and other warnings "
99 echo "-h Prints this help information."
101 echo "Note: If no keys are given script just performs make step."
104 echo " ./build.csh -o -i -b KERNEL MED GEOM"
106 echo " This will make KERNEL, GEOM and MED modules: build_configure, configure, make"
107 echo " and install procedures will be performed for all specified modules."
108 echo " The modules will be built in the optimized mode"
113 #########################################################
114 # sort modules in proper order according to the dependancies
115 #########################################################
116 if ( "${params}" != "" ) then
118 foreach module (${modules})
119 set ckt=`echo ${params} | grep ${module}`
120 if ( "$ckt" != "" ) then
121 set xparams="$xparams $module"
124 set modules=($xparams)
126 if ( "${b_params}" != "" ) then
127 echo "Nothing to be built. Exiting."
132 echo ">>> The following SALOME packages will be built:"
135 #########################################################
137 #########################################################
138 set env_script=`dirname $0`/env_build.csh
139 if ( ! -e $env_script ) then
140 set env_script=`dirname $0`/env_products.csh
142 if ( -e $env_script ) then
143 echo ">>> Setting environment"
146 echo "\!\!\! Warning \!\!\! Environment is not set: file env_products.csh is not found."
150 set LOG_DIR=${BUILD_DIR}/LOGS
152 #########################################################
153 # define installation prefix
154 #########################################################
155 if ( "$prefix" == "" ) then
156 set prefix=${BUILD_DIR}/INSTALL
157 if ( $is_install == 1 ) then
158 echo "\!\!\! Warning \!\!\! Installation directory is not set."
159 echo "All the modules will be installed to the $prefix"
161 set is_kernel=`echo ${modules} | grep KERNEL`
162 if ( "$is_kernel" != "" ) then
163 echo "\!\!\! Warning \!\!\! KERNEL module requires install step to be performed."
164 echo "For this module -i option will be forced."
165 echo "The module(s) will be installed to the $prefix"
169 set is_absolute=`echo $prefix | grep -e "^/"`
170 if ( "$is_absolute" == "" ) then
171 set prefix=${BUILD_DIR}/$prefix
172 echo "\!\!\! Warning \!\!\! Relative prefix is used."
173 echo "All the modules will be installed to the $prefix"
177 #########################################################
178 # create log directory
179 #########################################################
180 if ( ! -e ${LOG_DIR} ) then
184 echo "==========================================================================="
185 echo "Starting SALOME build at `date`"
186 echo "==========================================================================="
188 #########################################################
189 # loop for all given modules
190 #########################################################
191 foreach module (${modules})
192 echo ">>> Processing ${module} module"
194 set module_src=`printenv ${module}_SRC_DIR`
195 set module_build=${BUILD_DIR}/${module}_BUILD
197 if ( ${module_src} != "" ) then
200 #########################################################
201 # check if sources directory exists
202 #########################################################
203 if ( ! -e ${module_src} ) then
204 echo "\!\!\! Error \!\!\! Can't find sources directory: ${module_src} does not exist."
207 #########################################################
208 # check if configure script exists
209 #########################################################
211 if ( -e ${module_src}/configure ) then
214 #########################################################
215 # perform build_configure if -b flag is given or if
216 # configure script does not exist (first compilation?)
217 #########################################################
218 if ( $is_build_configure == 1 || $cfg_exist == 0 ) then
219 echo "... Performing build_configure"
220 #########################################################
221 # check if build_configure script exists
222 #########################################################
223 if ( ! -e ${module_src}/build_configure ) then
224 echo "\!\!\! Warning \!\!\! Can not find build_configure script in ${module_src}."
226 #########################################################
227 # call build_configure
228 #########################################################
230 ./build_configure >& ${LOG_DIR}/build_configure_${module}.log
231 #########################################################
232 # echo possible errors
233 #########################################################
234 if ( $verbose_level > 0 ) then
235 cat ${LOG_DIR}/build_configure_${module}.log | grep ": error:"
239 #########################################################
240 # deleting build directory if -d flag is given
241 #########################################################
242 if ( -e ${module_build} && $is_delete == 1 ) then
243 echo "... Removing ${module_build}"
244 rm -rf ${module_build}
246 #########################################################
247 # creating build directory if it does not exist
248 #########################################################
249 if ( ! -e ${module_build} ) then
250 mkdir -p ${module_build}
253 #########################################################
254 # check if top Makefile exists in build directory, i.e.
255 # is it necessary to run configure script
256 #########################################################
258 if ( -e ${module_build}/Makefile ) then
261 #########################################################
262 # check if configure options are changed from the
264 #########################################################
266 ## if ( -f ${module_build}/config.log ) then
267 ## set old_prefix=`grep -e '^prefix=' ${module_build}/config.log | sed -e "s%^prefix='\(.*\)'%\1%"`
268 ## if ( "$old_prefix" != "$prefix" ) then
269 ## set opts_changed=1
272 #########################################################
273 # define installation directory (by using module's version
274 # number); default is a build directory
275 #########################################################
277 set cfg_file=configure.ac
278 if ( ! -e ${module_src}/${cfg_file} ) then
279 set cfg_file=configure.in.base
281 if ( -e ${module_src}/${cfg_file} ) then
282 set vx=`grep -e "^VERSION=" ${module_src}/${cfg_file} | awk -F= '{ if (NF>1) print $NF; }' | tr -d '[:space:]'`
284 set px=${BUILD_DIR}/${module}
285 if ( "$prefix" != "" ) then
286 set px=$prefix/${module}
288 if ( "$vx" != "" ) then
291 #########################################################
292 # perform configure if -c flag is given or if
293 # Makefile does not exist (first compilation?)
294 #########################################################
295 if ( $is_configure == 1 || $mkfile_exist == 0 || $opts_changed == 1 ) then
296 echo "... Performing configure"
297 #########################################################
298 # check if configure script exists
299 #########################################################
300 if ( ! -e ${module_src}/configure ) then
301 echo "\!\!\! Warning \!\!\! Can not find configure script in ${module_src}."
303 if ( "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
304 set add_keys="--with-netgen=${NETGENHOME}"
306 ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
307 #########################################################
308 # echo possible errors
309 #########################################################
310 if ( $verbose_level > 0 ) then
311 cat ${LOG_DIR}/configure_${module}.log | grep ": error:"
313 if ( $verbose_level > 1 ) then
314 cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:"
318 #########################################################
320 #########################################################
321 echo "... Performing make"
322 #########################################################
323 # first clear dependencies
324 #########################################################
325 find . -name ".dep*" -type f -exec rm -f {} \; >& /dev/null
326 make >& ${LOG_DIR}/make_${module}.log
328 #########################################################
329 # if make step is successful set the ${module}_ROOT_DIR
330 # environment variable
331 #########################################################
332 if ( $sts == 0 ) then
333 setenv ${module}_ROOT_DIR ${module_build}
335 #########################################################
337 #########################################################
338 cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]'
339 #########################################################
340 # print compiler errors and warnings
341 # Note: here awk is used to concatenate together several lines of single
342 # error or warning message produced by stupid gnu compiler
343 # Actually, instead of that we could use 'fmessage length=n' option of g++...
344 #########################################################
345 if ( $verbose_level > 0 ) then
346 ###cat ${LOG_DIR}/make_${module}.log | grep ": error"
347 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/"@@
349 if ( $verbose_level > 1 ) then
350 cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {printf $0} END {print ""}' | grep ": warning" | sed s@"^${module_src}/src/"@@
352 #########################################################
353 # perform make if -i or -p flags are given
354 #########################################################
355 if ( $is_install == 1 && $sts == 0 || "${module}" == "KERNEL" ) then
356 echo "... Performing make install"
357 #########################################################
358 # deleting build directory if -d flag is given
359 #########################################################
360 if ( -e $px && $is_delete == 1 ) then
361 echo "... Removing $px"
364 make install >& ${LOG_DIR}/make_install_${module}.log
366 #########################################################
367 # if make install step is successful set the
368 # ${module}_ROOT_DIR environment variable
369 #########################################################
370 if ( $sts == 0 ) then
371 setenv ${module}_ROOT_DIR $px
374 echo ">>> Finished ${module} module"
376 echo "\!\!\! Error \!\!\! Can't find module sources. ${module}_SRC_DIR environment variable is not set."
379 #########################################################
381 #########################################################
384 echo "==========================================================================="
385 echo "SALOME build finished at `date`"
386 echo "==========================================================================="