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 # ------------------------------------------------------------------------
28 # #This code is for Mac
29 # function EEDreadlink() {
31 # (cd "$DIR" && echo "$(pwd -P)")
35 # #EED 2120-08-25 This code is not working in MacOS so we use EEDreadlink()
36 # #EED scriptDirName=$(dirname $(Ereadlink -f $0) )
37 # scriptDirName=$(dirname $(Ereadlink $0) )/Linux
41 # #scriptDirName=$(dirname $(readlink -f $0) )
42 # scriptDirName=$(pwd)
43 # >>>>>>> origin/vtk8itk5wx3-mingw64
47 #########################################################################
48 ############ Local Functions #######################################
49 #########################################################################
52 echo scriptDirName $scriptDirName
57 source scripts/LocalFunctions.sh
59 configureFile="scripts/CreaTools-configure.sh"
62 # default configuration parameters
63 OperatingSystem=`getDistrib`
65 generationdir=$HOME/Creatis/C11
73 loginGroupName=`groups | awk '{print $1}'`
77 export ETC_BASHRC=`getbashrc`
82 echo "installscript [options] command"
83 echo "creatools configure/compile/install script"
86 echo "OPTIONS ARE USE FOR CONFIGURATION ONLY: THEY WILL BE IGNORED IF <COMMAND> IS NOT \"CONFIG\" OR \"ALL\""
91 echo " as a normal user:"
92 echo " config : set the configuration parameters only"
94 echo " need root password:"
95 echo " 3rd : Get, Compile, Install all 3rd party library "
96 echo " 3rd-base : Install basic tools (cmake, doxygen...)"
97 echo " 3rd-vtk : Get, Compile, Install vtk"
98 echo " 3rd-itk : Get, Compile, Install itk"
99 echo " 3rd-gdcm : Get, Compile, Install gdcm"
100 echo " 3rd-wx : Get, Compile, Install wx widget (for Mac Users)"
101 echo " 3rd-wt : Get, Compile, Install wt"
103 echo " as a normal user:"
104 echo " creatools : Get Compile and Install the CreaTools"
105 echo " creatools-get : Get the CreaTools"
106 echo " creatools-cmp : Compile the CreaTools"
107 echo " creatools-install : Install the CreaTools"
109 echo " creatools-generateBinTGZ : generation of CreaTools.tgz (binary version)"
111 echo " uninstall : uninstall the creatools"
113 echo " printconfig : print the configuration"
114 echo " help : print help"
115 echo " env : print some environnement variables"
117 echo " all : configure / compile / install"
123 echo " configure options: !!!!! IGNORED IF COMMAND IS NOT CONFIG OR ALL !!!!!!"
124 echo " -os <os> : operating system distribution (default $OperatingSystem)"
125 echo " -ncore <n> : number of core to use (default $corenumber)"
126 echo " -gdir <dir> : generation directory (default $generationdir)"
127 echo " -instprefix <dir> : creatools install prefix"
128 echo " -instprefix3 <dir> : 3rd party library install prefix"
129 echo " -html : get creatools from HTML"
130 echo " -git : get creatools from git (CREATIS user only)"
131 echo " -git-read-only : get creatools from git (anonymously, no write access)"
132 echo " -build : build type Release, RelWithDebug or Debug (default RelWithDebug)"
134 echo " experimental configure options (use at your own risk!!):"
135 echo " -gdcm2 : use GDCM2 "
136 echo " -doc : generate documentation"
137 echo " -itk4 : use ITK4"
142 ##################################################
144 while [ $# -ge 1 ] ; do
146 -os) OperatingSystem=$2; shift 2;;
147 -ncore) corenumber=$2; shift 2;;
148 -gdir) generationdir=$2; shift 2;;
149 -instprefix) installPrefix=$2; shift 2;;
150 -instprefix3) installPrefixThird=$2; shift 2;;
151 -doc) docgeneration=ON; shift 1;;
152 -html) sourcesFrom=HTML; shift 1;;
153 -git) sourcesFrom=GIT; shift 1;;
154 -git-read-only) sourcesFrom=GIT-READ-ONLY;
156 -gdcm2) gdcmVersion=GDCM2; shift 1;;
157 -itk4) ITKVersion=ITK4; shift 1;;
158 -build) buildType=$2; shift 2;;
163 if [ $# -le 0 ] ; then usage; fi
167 # check that command is valid
168 if [ `checkVal $command all config 3rd 3rd-base 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx 3rd-wt creatools creatools-get creatools-cmp creatools-install creatools-generateBinTGZ uninstall printconfig help env` == "false" ] ; then
169 echo "Unrecognized command: $command"
175 ############################## use existing configuration if command is not config or all
176 if [ `checkVal $command config all` == false ] ; then
177 if [ ! -f $configureFile ] ; then
178 echo "scripts/CreaTools-configure.sh does not exists"
179 echo "please run the scripts with command \"config\" or \"all\""
182 source $configureFile
183 if [ ! -f $installPrefixThird/share/creatools/creatools_third_party_library_config.sh ] ; then
185 echo "the curently used Third Party libraries are NOT in $installPrefixThird but ... in :"
186 grep "installPrefixThird=" $ETC_BASHRC
187 echo "VTK_DIR : " $VTK_DIR
188 echo "ITK_DIR : " $ITK_DIR
189 echo "GDCM_DIR : " $GDCM_DIR
190 echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
197 ##################################################################################
198 ############################ check configuration parameters
200 checkDistrib $OperatingSystem
202 # complete default install prefix
203 if [ -z "$installPrefix" ] ; then installPrefix=$generationdir/ci; fi
204 if [ -z "$installPrefixThird" ] ; then installPrefixThird=$generationdir/tpli; fi
207 if [ `checkVal $buildType Release Debug RelWithDebug` == "false" ] ; then
208 echo "Unsupported build type: $buildType"
209 echo "Please use one of: Release Debug RelWithDebug"
214 ##################################################################################
215 ############################ write configuration file
216 if [ `checkVal $command config all` == true ] ; then
217 echo "#!/bin/bash" > $configureFile
218 echo >> $configureFile
219 echo "#File generated by 'installscript'" >> $configureFile
220 echo "#DO NOT edit !" >> $configureFile
221 echo "#(except if you *do* know what you do)" >> $configureFile
222 echo >> $configureFile
223 echo "OperatingSystem=$OperatingSystem" >> $configureFile
224 echo "corenumber=$corenumber" >> $configureFile
225 echo "generationdir=$generationdir" >> $configureFile
226 echo "installPrefix=$installPrefix" >> $configureFile
227 echo "installPrefixThird=$installPrefixThird" >> $configureFile
228 echo "docgeneration=$docgeneration" >> $configureFile
229 echo "sourcesFrom=$sourcesFrom" >> $configureFile
230 echo "loginUserName=$loginUserName" >> $configureFile
231 echo "loginGroupName=$loginGroupName" >> $configureFile
232 echo "buildType=$buildType" >> $configureFile
233 echo "gdcmVersion=$gdcmVersion" >> $configureFile
234 echo "ITKVersion=$ITKVersion" >> $configureFile
235 echo "ETC_BASHRC=$ETC_BASHRC" >> $configureFile
236 echo "TDx=$TDx" >> $configureFile
241 ################################### print current configuration
245 ##################################################################################
246 ##################################################################################
247 ############ Process commands
248 ##################################################################################
249 ##################################################################################
252 ################################################################################## config printconfig
253 # config or printconfig : already done
254 if [ `checkVal $command config printconfig` == true ] ; then
258 ################################################################################## creatools
260 if [ `checkVal $command all creatools creatools-get` == true ] ; then
261 bigDisplay "DOWNLOAD CREATOOLS"
262 bash scripts/CreaTools-load.sh
265 ################################################################################## 3rd library
266 # install packaged dependencies as root
267 if [ `checkVal $command all 3rd 3rd-base` == true ] ; then
268 bigDisplay "INSTALL PACKAGES DEPENDENCIES"
269 bash scripts/CreaTools-configure.sh
271 source ThirdParty-install-Base-Stuff.sh $OperatingSystem
273 bash scripts/ThirdParty-install.sh
277 if [ `checkVal $command all 3rd 3rd-vtk` == true ] ; then
278 bigDisplay "INSTALL VTK"
279 bash scripts/ThirdParty-install-VTK.sh
284 if [ `checkVal $command all 3rd 3rd-gdcm` == true ] ; then
285 bigDisplay "INSTALL $gdcmVersion"
286 bash scripts/ThirdParty-install-gdcm.sh
293 if [ `checkVal $command all 3rd 3rd-itk` == true ] ; then
294 bigDisplay "INSTALL $ITKVersion"
295 bash scripts/ThirdParty-install-ITK.sh
300 if [ `checkVal $command all 3rd 3rd-wt` == true ] ; then
301 bigDisplay "INSTALL WT"
302 bash scripts/ThirdParty-install-WT.sh
306 # Setup the user .bashrc correctly
307 if [ `checkVal $command all 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx 3rd-wt ` == true ] ; then
308 bigDisplay "FINALIZE 3RD PARTY LIBRARY INSTALLATION"
309 bash scripts/ThirdParty-install-Finalize.sh
310 if [ `checkVal $command 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
311 bigDisplay "Third Party Install Done"
312 bigDisplay "Please copy paste the following command or open a new terminal: source ~/.bashrc"
316 ################################################################################## creatools
318 if [ `checkVal $command all creatools creatools-cmp` == true ] ; then
319 bigDisplay "COMPILE CREATOOLS"
320 echo "EED installscript compile creatools"
323 bash -x scripts/CreaTools-compile.sh
325 # To allow (*very* aware) user to patch code, later
326 if [ ! -e $generationdir/creatools_source ] ; then
327 echo "You probabely made a mistake : "
328 echo "Directory $loginUserName $generationdir/creatools_source not found"
329 echo "Make sure you know the mistake"
330 echo "Hit any key to continue"
331 echo "Fix the mistake!"
334 chown -R $loginUserName $generationdir/creatools_source
335 chgrp -R $loginGroupName $generationdir/creatools_source
340 if [ `checkVal $command all creatools creatools-install` == true ] ; then
341 bigDisplay "INSTALL CREATOOLS"
343 bash scripts/CreaTools-install.sh
349 echo "Open a new terminal to run creatools."
350 echo "(Close this window and continue....) "
353 ##EED read -p "Press [Enter] key to continue..."
356 #generate TGZ version of the bin (Creatools and ThirdParty)
357 if [ `checkVal $command creatools-generateBinTGZ` == true ] ; then
358 bash scripts/CreaTools-GenerateBinTGZ.sh
361 ################################################################################## uninstall
362 if [ `checkVal $command uninstall` == true ] ; then
363 bigDisplay "UNINSTALL CREATOOLS"
364 bash scripts/CreaTools-uninstall.sh
367 ################################################################################## help
368 if [ `checkVal $command help` == true ] ; then
372 ################################################################################## print env variables
373 if [ `checkVal $command env` == true ] ; then
374 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
377 echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
378 grep "installPrefixThird=" $ETC_BASHRC
379 echo "VTK_DIR : " $VTK_DIR
380 echo "ITK_DIR : " $ITK_DIR
381 echo "GDCM_DIR : " $GDCM_DIR
383 echo "installPrefixThird ... " $installPrefixThird
386 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
387 echo "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
389 cat $installPrefixThird/share/creatools_third_party_library_config.sh
395 if [ -f $installPrefix/share/creatools_base_library_config.sh ] ; then
396 echo "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
398 cat $installPrefix/share/creatools_base_library_config.sh
401 echo "installPrefix ... " $installPrefix
405 echo "VTK_DIR : " $VTK_DIR
406 echo "ITK_DIR : " $ITK_DIR
407 echo "GDCM_DIR : " $GDCM_DIR
409 echo "crea_DIR : " $crea_DIR
410 echo "BBTK_DIR : " $BBTK_DIR
411 echo "creaMaracasVisu_DIR : " $creaMaracasVisu_DIR
412 echo "creaEnvironment_DIR : " $creaEnvironment_DIR
413 echo "creaBruker_DIR : " $creaBruker_DIR
414 echo "creaImageIO_DIR : " $creaImageIO_DIR
415 echo "creaContours_DIR : " $creaContours_DIR
416 echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
417 echo "bbtkGEditor_DIR : " $bbtkGEditor_DIR
418 echo "creaTools_DIR : " $creaTools_DIR
419 echo "creaMiniTools_DIR : " $creaMiniTools_DIR
420 echo "Ido_DIR : " $Ido_DIR
421 echo "==================================="