1 # ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # This software is governed by the CeCILL-B license under French law and
8 # abiding by the rules of distribution of free software. You can use,
9 # modify and/ or redistribute the software under the terms of the CeCILL-B
10 # license as circulated by CEA, CNRS and INRIA at the following URL
11 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
12 # or in the file LICENSE.txt.
14 # As a counterpart to the access to the source code and rights to copy,
15 # modify and redistribute granted by the license, users are provided only
16 # with a limited warranty and the software's author, the holder of the
17 # economic rights, and the successive licensors have only limited
20 # The fact that you are presently reading this means that you have had
21 # knowledge of the CeCILL-B license and that you accept its terms.
22 # ------------------------------------------------------------------------
26 #########################################################################
27 ############ Local Functions #######################################
28 #########################################################################
30 ##########################################
31 # check that $1 is one of $2, $3, ...
36 if [ "$val" == "$x" ] ; then
44 ###########################################
46 echo " ================================================================================================"
47 echo " ================================================================================================"
49 echo " ================================================================================================"
50 echo " ================================================================================================"
53 ###########################################
54 function checkDistrib {
57 if [ "`checkVal $OS MacOS Fedora Ubuntu Mandriva`" == "false" ] ; then
58 echo "Operating System not supported: $OS"
59 echo "Currently supported system: Fedora Ubuntu MacOS"
64 ###########################################
68 if [ "$OS" == Darwin ] ; then OS=MacOS;
69 elif [ "$OS" == Linux ] ; then OS=`awk 'NR==1{print $1}' /etc/issue`
78 ###########################################
80 if [ `uname` == Darwin ] ; then # MacOS
81 system_profiler | grep Processor | awk '$1=="Number" {print $4}'
83 cat /proc/cpuinfo | grep processor | wc -l
87 ###########################################
89 if [ ! -f $HOME/.bashrc ] ; then
95 # # Do it, while we are under user, not under root! # JPR
96 # if [ -f $HOME/.bashrc ] ; then
99 # if [ -f $HOME/.profile ] ; then
100 # echo $HOME/.profile
102 # echo "=============== BIG TROUBLE : neither $HOME/.bashrc nor $HOME/.profile file found" > /dev/stderr
103 # echo "=============== You'd better abort the program and (try to) fix the issue" > /dec/stderr
104 # read a # just to let the user time enough to read the message...
110 ###########################################
111 function printconfig {
114 echo "Current Configuration:"
115 echo " Operating System : $OperatingSystem"
116 echo " Number of Cores : $corenumber"
117 echo " Name of the Generation Directory : $generationdir"
118 echo " Install Prefix for Third Party Libraries : $installPrefixThird"
119 echo " Install Prefix for CreaTools : $installPrefix"
120 echo " Boolean for Doc Generation : $docgeneration"
121 echo " Where do you want to get source files from : $sourcesFrom"
122 echo " Login User Name : $loginUserName"
123 echo " Login Group Name : $loginGroupName"
124 echo " Build type : $buildType"
125 echo " Gdcm version : $gdcmVersion"
126 echo " ITK version : $ITKVersion"
133 ##################################################################################################
134 ##################################################################################################
135 ##################################################################################################
136 ##################################################################################################
137 ##################################################################################################
138 ##################################################################################################
140 configureFile="scripts/CreaTools-configure.sh"
143 # default configuration parameters
144 OperatingSystem=`getDistrib`
145 corenumber=`getncore`
146 generationdir=$HOME/CreatoolsGenerationDir
153 loginGroupName=`groups | awk '{print $1}'`
154 buildType=RelWithDebug
157 export ETC_BASHRC=`getbashrc`
164 echo "installscript [options] command"
165 echo "creatools configure/compile/install script"
168 echo "OPTIONS ARE USE FOR CONFIGURATION ONLY: THEY WILL BE IGNORED IF <COMMAND> IS NOT \"CONFIG\" OR \"ALL\""
173 echo " as a normal user:"
174 echo " config : set the configuration parameters only"
177 echo " 3rd : Get, Compile, Install all 3rd party library "
178 echo " 3rd-base : Install basic tools (cmake, doxygen...)"
179 echo " 3rd-vtk : Get, Compile, Install vtk"
180 echo " 3rd-itk : Get, Compile, Install itk"
181 echo " 3rd-gdcm : Get, Compile, Install gdcm"
182 echo " 3rd-wx : Get, Compile, Install wx widget (for Mac Users)"
184 echo " as a normal user:"
185 echo " creatools : Get Compile and Install the CreaTools"
186 echo " creatools-get : Get the CreaTools"
187 echo " creatools-cmp : Compile the CreaTools"
188 echo " creatools-install : Install the CreaTools"
190 echo " uninstall : uninstall the creatools"
192 echo " printconfig : print the configuration"
193 echo " help : print help"
194 echo " env : print some environnement variables"
196 echo " all : configure / compile / install"
202 echo " configure options: !!!!! IGNORED IF COMMAND IS NOT CONFIG OR ALL !!!!!!"
203 echo " -os <os> : operating system distribution (default $OperatingSystem)"
204 echo " -ncore <n> : number of core to use (default $corenumber)"
205 echo " -gdir <dir> : generation directory (default $generationdir)"
206 echo " -instprefix <dir> : creatools install prefix"
207 echo " -instprefix3 <dir> : 3rd party library install prefix"
208 echo " -git : get creatools from git (CREATIS user only)"
209 echo " -build : build type Release, RelWithDebug or Debug (default RelWithDebug)"
211 echo " experimental configure options (use at your own risk!!):"
212 echo " -gdcm2 : use GDCM2 "
213 echo " -doc : generate documentation"
214 echo " -itk4 : use ITK4"
219 ##################################################
221 while [ $# -ge 1 ] ; do
223 -os) OperatingSystem=$2; shift 2;;
224 -ncore) corenumber=$2; shift 2;;
225 -gdir) generationdir=$2; shift 2;;
226 -instprefix) installPrefix=$2; shift 2;;
227 -instprefix3) installPrefixThird=$2; shift 2;;
228 -doc) docgeneration=ON; shift 1;;
229 -git) sourcesFrom=GIT; shift 1;;
230 -gdcm2) gdcmVersion=GDCM2; shift 1;;
231 -itk4) ITKVersion=ITK4; shift 1;;
232 -build) buildType=$2; shift 2;;
237 if [ $# -le 0 ] ; then usage; fi
241 # check that command is valid
242 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
243 echo "Unrecognized command: $command"
249 ############################## use existing configuration if command is not config or all
250 if [ `checkVal $command config all` == false ] ; then
251 if [ ! -f $configureFile ] ; then
252 echo "scripts/CreaTools-configure.sh does not exists"
253 echo "please run the scripts with command \"config\" or \"all\""
256 source $configureFile
257 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
259 echo "the curently used Third Party libraries are NOT in $installPrefixThird but ... in :"
260 grep "installPrefixThird=" $ETC_BASHRC
261 echo "VTK_DIR : " $VTK_DIR
262 echo "ITK_DIR : " $ITK_DIR
263 echo "GDCM_DIR : " $GDCM_DIR
264 echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
271 ##################################################################################
272 ############################ check configuration parameters
274 checkDistrib $OperatingSystem
276 # complete default install prefix
277 if [ -z "$installPrefix" ] ; then installPrefix=$generationdir/creatools_install; fi
278 if [ -z "$installPrefixThird" ] ; then installPrefixThird=$generationdir/thirdparty_install; fi
281 if [ `checkVal $buildType Release Debug RelWithDebug` == "false" ] ; then
282 echo "Unsupported build type: $buildType"
283 echo "Please use one of: Release Debug RelWithDebug"
288 ##################################################################################
289 ############################ write configuration file
290 if [ `checkVal $command config all` == true ] ; then
291 echo "#!/bin/bash" > $configureFile
292 echo >> $configureFile
293 echo "#File generated by 'installscript'" >> $configureFile
294 echo "#DO NOT edit !" >> $configureFile
295 echo "#(except if you *do* know what you do)" >> $configureFile
296 echo >> $configureFile
297 echo "OperatingSystem=$OperatingSystem" >> $configureFile
298 echo "corenumber=$corenumber" >> $configureFile
299 echo "generationdir=$generationdir" >> $configureFile
300 echo "installPrefix=$installPrefix" >> $configureFile
301 echo "installPrefixThird=$installPrefixThird" >> $configureFile
302 echo "docgeneration=$docgeneration" >> $configureFile
303 echo "sourcesFrom=$sourcesFrom" >> $configureFile
304 echo "loginUserName=$loginUserName" >> $configureFile
305 echo "loginGroupName=$loginGroupName" >> $configureFile
306 echo "buildType=$buildType" >> $configureFile
307 echo "gdcmVersion=$gdcmVersion" >> $configureFile
308 echo "ITKVersion=$ITKVersion" >> $configureFile
309 echo "ETC_BASHRC=$ETC_BASHRC" >> $configureFile
314 ################################### print current configuration
318 ##################################################################################
319 ##################################################################################
320 ############ Process commands
321 ##################################################################################
322 ##################################################################################
325 ################################################################################## config printconfig
326 # config or printconfig : already done
327 if [ `checkVal $command config printconfig` == true ] ; then
332 ################################################################################## 3rd library
333 # install packaged dependencies as root
334 if [ `checkVal $command all 3rd 3rd-base` == true ] ; then
335 bigDisplay "INSTALL PACKAGES DEPENDENCIES"
336 if [ "`whoami`" == root ] ; then
337 bash scripts/ThirdParty-install-Base-Stuff.sh
340 echo "Please enter the root passwd to add necessary packages:";
341 sudo su -c "bash scripts/ThirdParty-install-Base-Stuff.sh"
343 bash scripts/ThirdParty-install.sh
348 if [ `checkVal $command all 3rd 3rd-vtk` == true ] ; then
349 bigDisplay "INSTALL VTK"
350 bash scripts/ThirdParty-install-VTK.sh
354 if [ `checkVal $command all 3rd 3rd-gdcm` == true ] ; then
355 bigDisplay "INSTALL $gdcmVersion"
356 bash scripts/ThirdParty-install-gdcm.sh
360 if [ `checkVal $command all 3rd 3rd-itk` == true ] ; then
361 bigDisplay "INSTALL $ITKVersion"
362 bash scripts/ThirdParty-install-ITK.sh
366 #if [ `checkVal $command all 3rd` == true ] ; then
367 # bash scripts/ThirdParty-install.sh
370 # Setup the user .bashrc correctly
371 if [ `checkVal $command all 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
372 bigDisplay "FINALIZE 3RD PARTY LIBRARY INSTALLATION"
373 bash scripts/ThirdParty-install-Finalize.sh
375 if [ `checkVal $command 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
376 bigDisplay "Third Party Install Done"
377 bigDisplay "Please copy paste the following command or open a new terminal: source ~/.bashrc"
381 ################################################################################## creatools
384 if [ `checkVal $command all creatools creatools-get` == true ] ; then
385 bigDisplay "DOWNLOAD CREATOOLS"
386 bash scripts/CreaTools-load.sh
390 if [ `checkVal $command all creatools creatools-cmp` == true ] ; then
391 bigDisplay "COMPILE CREATOOLS"
393 bash -x scripts/CreaTools-compile.sh
395 # To allow (*very* aware) user to patch code, later
396 if [ ! -e $generationdir/creatools_source ] ; then
397 echo "You probabely made a mistake : "
398 echo "Directory $loginUserName $generationdir/creatools_source not found"
399 echo "Make sure you know the mistake"
400 echo "Hit any key to continue"
401 echo "Fix the mistake!"
404 chown -R $loginUserName $generationdir/creatools_source
405 chgrp -R $loginGroupName $generationdir/creatools_source
410 if [ `checkVal $command all creatools creatools-install` == true ] ; then
411 bigDisplay "INSTALL CREATOOLS"
413 bash scripts/CreaTools-install.sh
417 ################################################################################## uninstall
419 if [ `checkVal $command uninstall` == true ] ; then
420 bigDisplay "UNINSTALL CREATOOLS"
421 bash scripts/CreaTools-uninstall.sh
424 ################################################################################## help
425 if [ `checkVal $command help` == true ] ; then
429 ################################################################################## print env variables
430 if [ `checkVal $command env` == true ] ; then
431 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
434 echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
435 grep "installPrefixThird=" $ETC_BASHRC
436 echo "VTK_DIR : " $VTK_DIR
437 echo "ITK_DIR : " $ITK_DIR
438 echo "GDCM_DIR : " $GDCM_DIR
440 echo "installPrefixThird ... " $installPrefixThird
443 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
444 echo "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
446 cat $installPrefixThird/share/creatools_third_party_library_config.sh
452 if [ -f $installPrefix/share/creatools_base_library_config.sh ] ; then
453 echo "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
455 cat $installPrefix/share/creatools_base_library_config.sh
458 echo "installPrefix ... " $installPrefix
462 echo "VTK_DIR : " $VTK_DIR
463 echo "ITK_DIR : " $ITK_DIR
464 echo "GDCM_DIR : " $GDCM_DIR
466 echo "crea_DIR : " $crea_DIR
467 echo "BBTK_DIR : " $BBTK_DIR
468 echo "creaMaracasVisu_DIR : " $creaMaracasVisu_DIR
469 echo "creaEnvironment_DIR : " $creaEnvironment_DIR
470 echo "creaBruker_DIR : " $creaBruker_DIR
471 echo "creaImageIO_DIR : " $creaImageIO_DIR
472 echo "creaContours_DIR : " $creaContours_DIR
473 echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
474 echo "bbtkGEditor_DIR : " $bbtkGEditor_DIR
475 echo "creaTools_DIR : " $creaTools_DIR
476 echo "creaMiniTools_DIR : " $creaMiniTools_DIR
477 echo "Ido_DIR : " $Ido_DIR
478 echo "==================================="