3 #########################################################################
4 ############ Local Functions #######################################
5 #########################################################################
7 ##########################################
8 # check that $1 is one of $2, $3, ...
13 if [ "$val" == "$x" ] ; then
21 ###########################################
23 echo " ================================================================================================"
24 echo " ================================================================================================"
26 echo " ================================================================================================"
27 echo " ================================================================================================"
30 ###########################################
31 function checkDistrib {
34 if [ "`checkVal $OS MacOS Fedora Ubuntu Mandriva`" == "false" ] ; then
35 echo "Operating System not supported: $OS"
36 echo "Currently supported system: Fedora Ubuntu MacOS"
41 ###########################################
45 if [ "$OS" == Darwin ] ; then OS=MacOS;
46 elif [ "$OS" == Linux ] ; then OS=`awk 'NR==1{print $1}' /etc/issue`
55 ###########################################
57 if [ `uname` == Darwin ] ; then # MacOS
58 system_profiler | grep Processor | awk '$1=="Number" {print $4}'
60 cat /proc/cpuinfo | grep processor | wc -l
64 ###########################################
66 if [ ! -f $HOME/.bashrc ] ; then
72 # # Do it, while we are under user, not under root! # JPR
73 # if [ -f $HOME/.bashrc ] ; then
76 # if [ -f $HOME/.profile ] ; then
79 # echo "=============== BIG TROUBLE : neither $HOME/.bashrc nor $HOME/.profile file found" > /dev/stderr
80 # echo "=============== You'd better abort the program and (try to) fix the issue" > /dec/stderr
81 # read a # just to let the user time enough to read the message...
87 ###########################################
88 function printconfig {
91 echo "Current Configuration:"
92 echo " Operating System : $OperatingSystem"
93 echo " Number of Cores : $corenumber"
94 echo " Name of the Generation Directory : $generationdir"
95 echo " Install Prefix for Third Party Libraries : $installPrefixThird"
96 echo " Install Prefix for CreaTools : $installPrefix"
97 echo " Boolean for Doc Generation : $docgeneration"
98 echo " Where do you want to get source files from : $sourcesFrom"
99 if [ $sourcesFrom = CVS ] ; then
100 echo " CVS User Name : $cvsUserName"
102 echo " Login User Name : $loginUserName"
103 echo " Login Group Name : $loginGroupName"
104 echo " Build type : $buildType"
105 echo " Gdcm version : $gdcmVersion"
106 echo " ITK version : $ITKVersion"
113 ##################################################################################################
114 ##################################################################################################
115 ##################################################################################################
116 ##################################################################################################
117 ##################################################################################################
118 ##################################################################################################
120 configureFile="scripts/CreaTools-configure.sh"
123 # default configuration parameters
124 OperatingSystem=`getDistrib`
125 corenumber=`getncore`
126 generationdir=$HOME/CreatoolsGenerationDir
134 loginGroupName=$GROUP
135 buildType=RelWithDebug
138 export ETC_BASHRC=`getbashrc`
145 echo "menu.sh [options] command"
146 echo "creatools configure/compile/install script"
149 echo "OPTIONS ARE USE FOR CONFIGURATION ONLY: THEY WILL BE IGNORED IF <COMMAND> IS NOT \"CONFIG\" OR \"ALL\""
153 echo " all : configure / compile / install"
155 echo " config : set the configuration parameters only"
157 echo " 3rd : Get, Compile, Install all 3rd party library "
158 echo " 3rd-base : Install basic tools (cmake, doxygen...)"
159 echo " 3rd-vtk : Get, Compile, Install vtk"
160 echo " 3rd-itk : Get, Compile, Install itk"
161 echo " 3rd-gdcm : Get, Compile, Install gdcm"
162 echo " 3rd-wx : Get, Compile, Install wx widget (for Mac Users)"
164 echo " creatools : Get Compile and Install the CreaTools"
165 echo " creatools-get : Get the CreaTools"
166 echo " creatools-cmp : Compile the CreaTools"
167 echo " creatools-install : Install the CreaTools"
169 echo " uninstall : uninstall the creatools"
171 echo " printconfig : print the configuration"
172 echo " help : print help"
173 echo " env : print some environnement variables"
178 echo " configure options: !!!!! IGNORED IF COMMAND IS NOT CONFIG OR ALL !!!!!!"
179 echo " -os <os> : operating system distribution (default $OperatingSystem)"
180 echo " -ncore <n> : number of core to use (default $corenumber)"
181 echo " -gdir <dir> : generation directory (default $generationdir)"
182 echo " -instprefix <dir> : creatools install prefix"
183 echo " -instprefix3 <dir> : 3rd party library install prefix"
184 echo " -cvs <cvsusername> : get creatools from cvs (CREATIS user only)"
185 echo " -build : build type Release, RelWithDebug or Debug (default RelWithDebug)"
187 echo " experimental configure options (use at your own risk!!):"
188 echo " -gdcm2 : use GDCM2 "
189 echo " -doc : generate documentation"
190 echo " -itk4 : use ITK4"
195 ##################################################
197 while [ $# -ge 1 ] ; do
199 -os) OperatingSystem=$2; shift 2;;
200 -ncore) corenumber=$2; shift 2;;
201 -gdir) generationdir=$2; shift 2;;
202 -instprefix) installPrefix=$2; shift 2;;
203 -instprefix3) installPrefixThird=$2; shift 2;;
204 -doc) docgeneration=ON; shift 1;;
205 -cvs) sourcesFrom=CVS; cvsUserName=$2; shift 2;;
206 -gdcm2) gdcmVersion=GDCM2; shift 1;;
207 -itk4) ITKVersion=ITK4; shift 1;;
208 -build) buildType=$2; shift 2;;
213 if [ $# -le 0 ] ; then usage; fi
217 # check that command is valid
218 if [ `checkVal $command all config 3rd 3rd-base 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx creatools creatools-get creatools-cmp creatools-install uninstall printconfig help env` == "false" ] ; then
219 echo "Unrecognized command: $command"
225 ############################## use existing configuration if command is not config or all
226 if [ `checkVal $command config all` == false ] ; then
227 if [ ! -f $configureFile ] ; then
228 echo "scripts/CreaTools-configure.sh does not exists"
229 echo "please run the scripts with command \"config\" or \"all\""
232 source $configureFile
233 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
235 echo "the curently used Third Party libraries are NOT in $installPrefixThird but ... in :"
236 grep "installPrefixThird=" $ETC_BASHRC
237 echo "VTK_DIR : " $VTK_DIR
238 echo "ITK_DIR : " $ITK_DIR
239 echo "GDCM_DIR : " $GDCM_DIR
240 echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
247 ##################################################################################
248 ############################ check configuration parameters
250 checkDistrib $OperatingSystem
252 # complete default install prefix
253 if [ -z "$installPrefix" ] ; then installPrefix=$generationdir/creatools_install; fi
254 if [ -z "$installPrefixThird" ] ; then installPrefixThird=$generationdir/thirdparty_install; fi
257 if [ `checkVal $buildType Release Debug RelWithDebug` == "false" ] ; then
258 echo "Unsupported build type: $buildType"
259 echo "Please use one of: Release Debug RelWithDebug"
264 ##################################################################################
265 ############################ write configuration file
266 if [ `checkVal $command config all` == true ] ; then
267 echo "#!/bin/bash" > $configureFile
268 echo >> $configureFile
269 echo "#File generated by 'menu.sh'" >> $configureFile
270 echo "#DO NOT edit !" >> $configureFile
271 echo "#(except if you *do* know what you do)" >> $configureFile
272 echo >> $configureFile
273 echo "OperatingSystem=$OperatingSystem" >> $configureFile
274 echo "corenumber=$corenumber" >> $configureFile
275 echo "generationdir=$generationdir" >> $configureFile
276 echo "installPrefix=$installPrefix" >> $configureFile
277 echo "installPrefixThird=$installPrefixThird" >> $configureFile
278 echo "docgeneration=$docgeneration" >> $configureFile
279 echo "sourcesFrom=$sourcesFrom" >> $configureFile
280 echo "cvsUserName=$cvsUserName" >> $configureFile
281 echo "loginUserName=$loginUserName" >> $configureFile
282 echo "loginGroupName=$loginGroupName" >> $configureFile
283 echo "buildType=$buildType" >> $configureFile
284 echo "gdcmVersion=$gdcmVersion" >> $configureFile
285 echo "ITKVersion=$ITKVersion" >> $configureFile
286 echo "ETC_BASHRC=$ETC_BASHRC" >> $configureFile
291 ################################### print current configuration
295 ##################################################################################
296 ##################################################################################
297 ############ Process commands
298 ##################################################################################
299 ##################################################################################
302 ################################################################################## config printconfig
303 # config or printconfig : already done
304 if [ `checkVal $command config printconfig` == true ] ; then
309 ################################################################################## 3rd library
310 # install packaged dependencies as root
311 if [ `checkVal $command all 3rd 3rd-base` == true ] ; then
312 bigDisplay "INSTALL PACKAGES DEPENDENCIES"
313 if [ "`whoami`" == root ] ; then
314 bash scripts/ThirdParty-install-Base-Stuff.sh
317 echo "Please enter the root passwd to add necessary packages:";
318 su -c "bash scripts/ThirdParty-install-Base-Stuff.sh"
320 bash scripts/ThirdParty-install.sh
324 if [ `checkVal $command all 3rd 3rd-vtk` == true ] ; then
325 bigDisplay "INSTALL VTK"
326 bash scripts/ThirdParty-install-VTK.sh
330 if [ `checkVal $command all 3rd 3rd-gdcm` == true ] ; then
331 bigDisplay "INSTALL $gdcmVersion"
332 bash scripts/ThirdParty-install-gdcm.sh
336 if [ `checkVal $command all 3rd 3rd-itk` == true ] ; then
337 bigDisplay "INSTALL $ITKVersion"
338 bash scripts/ThirdParty-install-ITK.sh
342 #if [ `checkVal $command all 3rd` == true ] ; then
343 # bash scripts/ThirdParty-install.sh
346 # Setup the user .bashrc correctly
347 if [ `checkVal $command all 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
348 bigDisplay "FINALIZE 3RD PARTY LIBRARY INSTALLATION"
349 bash scripts/ThirdParty-install-Finalize.sh
351 if [ `checkVal $command 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
352 bigDisplay "Third Party Install Done"
353 bigDisplay "Please copy paste the following command or open a new terminal: source ~/.bashrc"
357 ################################################################################## creatools
360 if [ `checkVal $command all creatools creatools-get` == true ] ; then
361 bigDisplay "DOWNLOAD CREATOOLS"
362 bash scripts/CreaTools-load.sh
366 if [ `checkVal $command all creatools creatools-cmp` == true ] ; then
367 bigDisplay "COMPILE CREATOOLS"
369 bash -x scripts/CreaTools-compile.sh
371 # To allow (*very* aware) user to patch code, later
372 if [ ! -e $generationdir/creatools_source ] ; then
373 echo "You probabely made a mistake : "
374 echo "Directory $loginUserName $generationdir/creatools_source not found"
375 echo "Make sure you know the mistake"
376 echo "Hit any key to continue"
377 echo "Fix the mistake!"
380 chown -R $loginUserName $generationdir/creatools_source
381 chgrp -R $loginGroupName $generationdir/creatools_source
386 if [ `checkVal $command all creatools creatools-install` == true ] ; then
387 bigDisplay "INSTALL CREATOOLS"
389 bash scripts/CreaTools-install.sh
393 ################################################################################## uninstall
395 if [ `checkVal $command uninstall` == true ] ; then
396 bigDisplay "UNINSTALL CREATOOLS"
397 bash scripts/CreaTools-uninstall.sh
400 ################################################################################## help
401 if [ `checkVal $command help` == true ] ; then
405 ################################################################################## print env variables
406 if [ `checkVal $command env` == true ] ; then
407 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
410 echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
411 grep "installPrefixThird=" $ETC_BASHRC
412 echo "VTK_DIR : " $VTK_DIR
413 echo "ITK_DIR : " $ITK_DIR
414 echo "GDCM_DIR : " $GDCM_DIR
416 echo "installPrefixThird ... " $installPrefixThird
419 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
420 echo "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
422 cat $installPrefixThird/share/creatools_third_party_library_config.sh
428 if [ -f $installPrefix/share/creatools_base_library_config.sh ] ; then
429 echo "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
431 cat $installPrefix/share/creatools_base_library_config.sh
434 echo "installPrefix ... " $installPrefix
438 echo "VTK_DIR : " $VTK_DIR
439 echo "ITK_DIR : " $ITK_DIR
440 echo "GDCM_DIR : " $GDCM_DIR
442 echo "crea_DIR : " $crea_DIR
443 echo "BBTK_DIR : " $BBTK_DIR
444 echo "creaMaracasVisu_DIR : " $creaMaracasVisu_DIR
445 echo "creaEnvironment_DIR : " $creaEnvironment_DIR
446 echo "creaBruker_DIR : " $creaBruker_DIR
447 echo "creaImageIO_DIR : " $creaImageIO_DIR
448 echo "creaContours_DIR : " $creaContours_DIR
449 echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
450 echo "bbtkGEditor_DIR : " $bbtkGEditor_DIR
451 echo "creaTools_DIR : " $creaTools_DIR
452 echo "creaMiniTools_DIR : " $creaMiniTools_DIR
453 echo "Ido_DIR : " $Ido_DIR
454 echo "==================================="