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 scriptDirName=$(dirname $(readlink -f $0) )
28 #########################################################################
29 ############ Local Functions #######################################
30 #########################################################################
32 ##########################################
33 # check that $1 is one of $2, $3, ...
38 if [ "$val" == "$x" ] ; then
46 ###########################################
48 echo " ================================================================================================"
49 echo " ================================================================================================"
51 echo " ================================================================================================"
52 echo " ================================================================================================"
55 ###########################################
56 function checkDistrib {
59 if [ "`checkVal $OS MacOS Fedora Ubuntu Mandriva`" == "false" ] ; then
60 echo "Operating System not supported: $OS"
61 echo "Currently supported system: Fedora Ubuntu MacOS"
66 ###########################################
70 if [ "$OS" == Darwin ] ; then OS=MacOS;
71 elif [ "$OS" == Linux ] ; then OS=`awk 'NR==1{print $1}' /etc/issue`
80 ###########################################
82 if [ `uname` == Darwin ] ; then # MacOS
83 system_profiler | grep Processor | awk '$1=="Number" {print $4}'
85 cat /proc/cpuinfo | grep processor | wc -l
89 ###########################################
91 if [ ! -f $HOME/.bashrc ] ; then
97 # # Do it, while we are under user, not under root! # JPR
98 # if [ -f $HOME/.bashrc ] ; then
101 # if [ -f $HOME/.profile ] ; then
102 # echo $HOME/.profile
104 # echo "=============== BIG TROUBLE : neither $HOME/.bashrc nor $HOME/.profile file found" > /dev/stderr
105 # echo "=============== You'd better abort the program and (try to) fix the issue" > /dec/stderr
106 # read a # just to let the user time enough to read the message...
112 ###########################################
113 function printconfig {
116 echo "Current Configuration:"
117 echo " Operating System : $OperatingSystem"
118 echo " Number of Cores : $corenumber"
119 echo " Name of the Generation Directory : $generationdir"
120 echo " Install Prefix for Third Party Libraries : $installPrefixThird"
121 echo " Install Prefix for CreaTools : $installPrefix"
122 echo " Boolean for Doc Generation : $docgeneration"
123 echo " Where do you want to get source files from : $sourcesFrom"
124 echo " Login User Name : $loginUserName"
125 echo " Login Group Name : $loginGroupName"
126 echo " Build type : $buildType"
127 echo " Gdcm version : $gdcmVersion"
128 echo " ITK version : $ITKVersion"
135 ##################################################################################################
136 ##################################################################################################
137 ##################################################################################################
138 ##################################################################################################
139 ##################################################################################################
140 ##################################################################################################
142 configureFile="scripts/CreaTools-configure.sh"
145 # default configuration parameters
146 OperatingSystem=`getDistrib`
147 corenumber=`getncore`
148 generationdir=$HOME/Creatis/creaTools
155 loginGroupName=`groups | awk '{print $1}'`
159 export ETC_BASHRC=~/.bashrc
163 echo "installscript [options] command"
164 echo "creatools configure/compile/install script"
167 echo "OPTIONS ARE USE FOR CONFIGURATION ONLY: THEY WILL BE IGNORED IF <COMMAND> IS NOT \"CONFIG\" OR \"ALL\""
172 echo " as a normal user:"
173 echo " config : set the configuration parameters only"
175 echo " need root password:"
176 echo " 3rd : Get, Compile, Install all 3rd party library "
177 echo " 3rd-base : Install basic tools (cmake, doxygen...)"
178 echo " 3rd-vtk : Get, Compile, Install vtk"
179 echo " 3rd-itk : Get, Compile, Install itk"
180 echo " 3rd-gdcm : Get, Compile, Install gdcm"
181 echo " 3rd-wx : Get, Compile, Install wx widget (for Mac Users)"
183 echo " as a normal user:"
184 echo " creatools : Get Compile and Install the CreaTools"
185 echo " creatools-get : Get the CreaTools"
186 echo " creatools-cmp : Compile the CreaTools"
187 echo " creatools-install : Install the CreaTools"
189 echo " creatools-generateBinTGZ : generation of CreaTools.tgz (binary version)"
191 echo " uninstall : uninstall the creatools"
193 echo " printconfig : print the configuration"
194 echo " help : print help"
195 echo " env : print some environnement variables"
197 echo " all : configure / compile / install"
203 echo " configure options: !!!!! IGNORED IF COMMAND IS NOT CONFIG OR ALL !!!!!!"
204 echo " -os <os> : operating system distribution (default $OperatingSystem)"
205 echo " -ncore <n> : number of core to use (default $corenumber)"
206 echo " -gdir <dir> : generation directory (default $generationdir)"
207 echo " -instprefix <dir> : creatools install prefix"
208 echo " -instprefix3 <dir> : 3rd party library install prefix"
209 echo " -html : get creatools from HTML"
210 echo " -git : get creatools from git (CREATIS user only)"
211 echo " -git-read-only : get creatools from git (anonymously, no write access)"
212 echo " -build : build type Release, RelWithDebug or Debug (default RelWithDebug)"
214 echo " experimental configure options (use at your own risk!!):"
215 echo " -gdcm2 : use GDCM2 "
216 echo " -doc : generate documentation"
217 echo " -itk4 : use ITK4"
222 ##################################################
224 while [ $# -ge 1 ] ; do
226 -os) OperatingSystem=$2; shift 2;;
227 -ncore) corenumber=$2; shift 2;;
228 -gdir) generationdir=$2; shift 2;;
229 -instprefix) installPrefix=$2; shift 2;;
230 -instprefix3) installPrefixThird=$2; shift 2;;
231 -doc) docgeneration=ON; shift 1;;
232 -html) sourcesFrom=HTML; shift 1;;
233 -git) sourcesFrom=GIT; shift 1;;
234 -git-read-only) sourcesFrom=GIT-READ-ONLY;
236 -gdcm2) gdcmVersion=GDCM2; shift 1;;
237 -itk4) ITKVersion=ITK4; shift 1;;
238 -build) buildType=$2; shift 2;;
243 if [ $# -le 0 ] ; then usage; fi
247 # check that command is valid
248 if [ `checkVal $command all config 3rd 3rd-base 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx creatools creatools-get creatools-cmp creatools-install creatools-generateBinTGZ uninstall printconfig help env` == "false" ] ; then
249 echo "Unrecognized command: $command"
255 ############################## use existing configuration if command is not config or all
256 if [ `checkVal $command config all` == false ] ; then
257 if [ ! -f $configureFile ] ; then
258 echo "scripts/CreaTools-configure.sh does not exists"
259 echo "please run the scripts with command \"config\" or \"all\""
262 source $configureFile
263 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
265 echo "the curently used Third Party libraries are NOT in $installPrefixThird but ... in :"
266 grep "installPrefixThird=" $ETC_BASHRC
267 echo "VTK_DIR : " $VTK_DIR
268 echo "ITK_DIR : " $ITK_DIR
269 echo "GDCM_DIR : " $GDCM_DIR
270 echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
277 ##################################################################################
278 ############################ check configuration parameters
280 checkDistrib $OperatingSystem
282 # complete default install prefix
283 if [ -z "$installPrefix" ] ; then installPrefix=$generationdir/creatools_install; fi
284 if [ -z "$installPrefixThird" ] ; then installPrefixThird=$generationdir/thirdparty_install; fi
287 if [ `checkVal $buildType Release Debug RelWithDebug` == "false" ] ; then
288 echo "Unsupported build type: $buildType"
289 echo "Please use one of: Release Debug RelWithDebug"
294 ##################################################################################
295 ############################ write configuration file
296 if [ `checkVal $command config all` == true ] ; then
297 echo "#!/bin/bash" > $configureFile
298 echo >> $configureFile
299 echo "#File generated by 'installscript'" >> $configureFile
300 echo "#DO NOT edit !" >> $configureFile
301 echo "#(except if you *do* know what you do)" >> $configureFile
302 echo >> $configureFile
303 echo "OperatingSystem=$OperatingSystem" >> $configureFile
304 echo "corenumber=$corenumber" >> $configureFile
305 echo "generationdir=$generationdir" >> $configureFile
306 echo "installPrefix=$installPrefix" >> $configureFile
307 echo "installPrefixThird=$installPrefixThird" >> $configureFile
308 echo "docgeneration=$docgeneration" >> $configureFile
309 echo "sourcesFrom=$sourcesFrom" >> $configureFile
310 echo "loginUserName=$loginUserName" >> $configureFile
311 echo "loginGroupName=$loginGroupName" >> $configureFile
312 echo "buildType=$buildType" >> $configureFile
313 echo "gdcmVersion=$gdcmVersion" >> $configureFile
314 echo "ITKVersion=$ITKVersion" >> $configureFile
315 echo "ETC_BASHRC=$ETC_BASHRC" >> $configureFile
320 ################################### print current configuration
324 ##################################################################################
325 ##################################################################################
326 ############ Process commands
327 ##################################################################################
328 ##################################################################################
331 ################################################################################## config printconfig
332 # config or printconfig : already done
333 if [ `checkVal $command config printconfig` == true ] ; then
337 ################################################################################## creatools
339 if [ `checkVal $command all creatools creatools-get` == true ] ; then
340 bigDisplay "DOWNLOAD CREATOOLS"
341 bash scripts/CreaTools-load.sh
344 ################################################################################## 3rd library
345 # install packaged dependencies as root
346 if [ `checkVal $command all 3rd 3rd-base` == true ] ; then
347 bigDisplay "INSTALL PACKAGES DEPENDENCIES"
348 if [ "`whoami`" == root ] ; then
349 echo ThirdParty-install-Base-Stuff
350 bash scripts/ThirdParty-install-Base-Stuff.sh
353 echo "Please enter the root passwd to add necessary packages:";
354 su -c "bash scripts/ThirdParty-install-Base-Stuff.sh"
356 bash scripts/ThirdParty-install.sh
360 if [ `checkVal $command all 3rd 3rd-vtk` == true ] ; then
361 bigDisplay "INSTALL VTK"
362 source scripts/ThirdParty-install-VTK.sh
367 if [ `checkVal $command all 3rd 3rd-gdcm` == true ] ; then
368 bigDisplay "INSTALL $gdcmVersion"
369 source scripts/ThirdParty-install-gdcm.sh
374 if [ `checkVal $command all 3rd 3rd-itk` == true ] ; then
375 bigDisplay "INSTALL $ITKVersion"
376 bash scripts/ThirdParty-install-ITK.sh
380 #if [ `checkVal $command all 3rd` == true ] ; then
381 # bash scripts/ThirdParty-install.sh
384 # Setup the user .bashrc correctly
385 if [ `checkVal $command all 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
386 bigDisplay "FINALIZE 3RD PARTY LIBRARY INSTALLATION"
387 bash scripts/ThirdParty-install-Finalize.sh
388 if [ `checkVal $command 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
389 bigDisplay "Third Party Install Done"
390 bigDisplay "Please copy paste the following command or open a new terminal: source ~/.bashrc"
394 ################################################################################## creatools
396 if [ `checkVal $command all creatools creatools-cmp` == true ] ; then
397 bigDisplay "COMPILE CREATOOLS"
399 bash -x scripts/CreaTools-compile.sh
401 # To allow (*very* aware) user to patch code, later
402 if [ ! -e $generationdir/creatools_source ] ; then
403 echo "You probabely made a mistake : "
404 echo "Directory $loginUserName $generationdir/creatools_source not found"
405 echo "Make sure you know the mistake"
406 echo "Hit any key to continue"
407 echo "Fix the mistake!"
410 chown -R $loginUserName $generationdir/creatools_source
411 chgrp -R $loginGroupName $generationdir/creatools_source
416 if [ `checkVal $command all creatools creatools-install` == true ] ; then
417 bigDisplay "INSTALL CREATOOLS"
419 bash scripts/CreaTools-install.sh
425 echo "Open a new terminal to run creatools."
426 echo "(Close this window and continue....) "
429 read -p "Press [Enter] key to continue..."
432 #generate TGZ version of the bin (Creatools and ThirdParty)
433 if [ `checkVal $command creatools-generateBinTGZ` == true ] ; then
434 bash scripts/CreaTools-GenerateBinTGZ.sh
437 ################################################################################## uninstall
438 if [ `checkVal $command uninstall` == true ] ; then
439 bigDisplay "UNINSTALL CREATOOLS"
440 bash scripts/CreaTools-uninstall.sh
443 ################################################################################## help
444 if [ `checkVal $command help` == true ] ; then
448 ################################################################################## print env variables
449 if [ `checkVal $command env` == true ] ; then
450 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
453 echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
454 grep "installPrefixThird=" $ETC_BASHRC
455 echo "VTK_DIR : " $VTK_DIR
456 echo "ITK_DIR : " $ITK_DIR
457 echo "GDCM_DIR : " $GDCM_DIR
459 echo "installPrefixThird ... " $installPrefixThird
462 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
463 echo "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
465 cat $installPrefixThird/share/creatools_third_party_library_config.sh
471 if [ -f $installPrefix/share/creatools_base_library_config.sh ] ; then
472 echo "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
474 cat $installPrefix/share/creatools_base_library_config.sh
477 echo "installPrefix ... " $installPrefix
481 echo "VTK_DIR : " $VTK_DIR
482 echo "ITK_DIR : " $ITK_DIR
483 echo "GDCM_DIR : " $GDCM_DIR
485 echo "crea_DIR : " $crea_DIR
486 echo "BBTK_DIR : " $BBTK_DIR
487 echo "creaMaracasVisu_DIR : " $creaMaracasVisu_DIR
488 echo "creaEnvironment_DIR : " $creaEnvironment_DIR
489 echo "creaBruker_DIR : " $creaBruker_DIR
490 echo "creaImageIO_DIR : " $creaImageIO_DIR
491 echo "creaContours_DIR : " $creaContours_DIR
492 echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
493 echo "bbtkGEditor_DIR : " $bbtkGEditor_DIR
494 echo "creaTools_DIR : " $creaTools_DIR
495 echo "creaMiniTools_DIR : " $creaMiniTools_DIR
496 echo "Ido_DIR : " $Ido_DIR
497 echo "==================================="