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 GEOM MED SMESH VISU SUPERV NETGENPLUGIN GHS3DPLUGIN COMPONENT PYCALCULATOR CALCULATOR HELLO PYHELLO)
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 # create log directory
154 #########################################################
155 if ( ! -e ${LOG_DIR} ) then
159 echo "==========================================================================="
160 echo "Starting SALOME build at `date`"
162 #########################################################
163 # loop for all given modules
164 #########################################################
165 foreach module (${modules})
166 echo "==========================================================================="
167 echo "Processing ${module} module"
169 set module_src=`printenv ${module}_SRC_DIR`
170 set module_build=${BUILD_DIR}/${module}_BUILD
172 if ( ${module_src} != "" ) then
175 #########################################################
176 # check if sources directory exists
177 #########################################################
178 if ( ! -e ${module_src} ) then
179 echo "Error! Can't find sources directory: ${module_src} does not exist."
182 #########################################################
183 # check if configure script exists
184 #########################################################
186 if ( -e ${module_src}/configure ) then
189 #########################################################
190 # perform build_configure if -b flag is given or if
191 # configure script does not exist (first compilation?)
192 #########################################################
193 if ( $is_build_configure == 1 || $cfg_exist == 0 ) then
194 echo "------- Build configure ---------"
195 #########################################################
196 # if build_configure script is not found, omit the module
197 #########################################################
198 if ( ! -e ${module_src}/build_configure ) then
199 echo "Error! Nothing to build in ${module_src}. Skipping module."
202 #########################################################
203 # call build_configure
204 #########################################################
206 ./build_configure >& ${LOG_DIR}/build_configure_${module}.log
207 #########################################################
208 # echo possible errors
209 #########################################################
210 if ( $verbose_level > 0 ) then
211 cat ${LOG_DIR}/build_configure_${module}.log | grep ": error:"
214 #########################################################
215 # deleting build directory if -d flag is given
216 #########################################################
217 if ( -e ${module_build} && $is_delete == 1 ) then
218 echo "Deleting ${module_build}"
219 rm -rf ${module_build}
221 #########################################################
222 # creating build directory if it does not exist
223 #########################################################
224 if ( ! -e ${module_build} ) then
225 mkdir -p ${module_build}
228 #########################################################
229 # check if top Makefile exists in build directory, i.e.
230 # is it necessary to run configure script
231 #########################################################
233 if ( -e ${module_build}/Makefile ) then
236 #########################################################
237 # define installation directory (by using module's version
238 # number); default is a build directory
239 #########################################################
241 if ( -e ${module_src}/bin/VERSION ) then
242 set vx=`awk -F: '{ if (NF > 1) print $NF; }' ${module_src}/bin/VERSION | tr -d '[:space:]'`
244 set px=${BUILD_DIR}/${module}
245 if ( "$prefix" != "" ) then
246 set px=$prefix/${module}
248 if ( "$vx" != "" ) then
251 #########################################################
252 # perform configure if -c flag is given or if
253 # Makefile does not exist (first compilation?)
254 #########################################################
255 if ( $is_configure == 1 || $mkfile_exist == 0) then
256 echo "------- Configure ---------------"
257 if ( "${module}" == "NETGENPLUGIN" && ($?NETGENHOME) ) then
258 set add_keys="--with-netgen=${NETGENHOME}"
260 ${module_src}/configure --prefix=$px ${optim} ${add_keys} >& ${LOG_DIR}/configure_${module}.log
261 #########################################################
262 # echo possible errors
263 #########################################################
264 if ( $verbose_level > 0 ) then
265 cat ${LOG_DIR}/configure_${module}.log | grep ": error:"
267 if ( $verbose_level > 1 ) then
268 cat ${LOG_DIR}/configure_${module}.log | grep ": WARNING:"
271 #########################################################
273 #########################################################
274 echo "------- Make --------------------"
275 #########################################################
276 # first clear dependencies
277 #########################################################
278 find . -name ".dep*" -exec rm -rf {} \; >& /dev/null
279 make >& ${LOG_DIR}/make_${module}.log
281 #########################################################
282 # if make step is successful set the ${module}_ROOT_DIR
283 # environment variable
284 #########################################################
285 if ( $sts == 0 ) then
286 setenv ${module}_ROOT_DIR ${module_build}
288 #########################################################
290 #########################################################
291 cat ${LOG_DIR}/make_${module}.log | grep '[*][*][*]'
292 #########################################################
293 # print compiler errors and warnings
294 # Note: here awk is used to concatenate together several lines of single
295 # error or warning message produced by stupid gnu compiler
296 # Actually, instead of that we could use 'fmessage length=n' option of g++...
297 #########################################################
298 if ( $verbose_level > 0 ) then
299 ###cat ${LOG_DIR}/make_${module}.log | grep ": error"
300 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/"@@
302 if ( $verbose_level > 1 ) then
303 cat ${LOG_DIR}/make_${module}.log | awk 'substr($0,0,1)!=" " {print ""} {printf $0} END {print ""}' | grep ": warning" | sed s@"^${module_src}/src/"@@
305 #########################################################
306 # perform make if -i or -p flags are given
307 #########################################################
308 if ( $is_install == 1 && $sts == 0 ) then
309 echo "------- Make install ------------"
310 #########################################################
311 # deleting build directory if -d flag is given
312 #########################################################
313 if ( -e $px && $is_delete == 1 ) then
317 make install >& ${LOG_DIR}/make_install_${module}.log
319 #########################################################
320 # if make install step is successful set the
321 # ${module}_ROOT_DIR environment variable
322 #########################################################
323 if ( $sts == 0 ) then
324 setenv ${module}_ROOT_DIR $px
329 echo "Error! Can't find module sources. ${module}_SRC_DIR environment variable is not set."
332 #########################################################
334 #########################################################
337 echo "==========================================================================="
338 echo "SALOME build finished at `date`"
339 echo "==========================================================================="