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 #########################################################################
33 source scripts/LocalFunctions.sh
35 configureFile="scripts/CreaTools-configure.sh"
38 # default configuration parameters
39 OperatingSystem=`getDistrib`
41 generationdir=$HOME/Creatis/creaTools
48 loginGroupName=`groups | awk '{print $1}'`
52 export ETC_BASHRC=`getbashrc`
56 echo "installscript [options] command"
57 echo "creatools configure/compile/install script"
60 echo "OPTIONS ARE USE FOR CONFIGURATION ONLY: THEY WILL BE IGNORED IF <COMMAND> IS NOT \"CONFIG\" OR \"ALL\""
65 echo " as a normal user:"
66 echo " config : set the configuration parameters only"
68 echo " need root password:"
69 echo " 3rd : Get, Compile, Install all 3rd party library "
70 echo " 3rd-base : Install basic tools (cmake, doxygen...)"
71 echo " 3rd-vtk : Get, Compile, Install vtk"
72 echo " 3rd-itk : Get, Compile, Install itk"
73 echo " 3rd-gdcm : Get, Compile, Install gdcm"
74 echo " 3rd-wx : Get, Compile, Install wx widget (for Mac Users)"
76 echo " as a normal user:"
77 echo " creatools : Get Compile and Install the CreaTools"
78 echo " creatools-get : Get the CreaTools"
79 echo " creatools-cmp : Compile the CreaTools"
80 echo " creatools-install : Install the CreaTools"
82 echo " creatools-generateBinTGZ : generation of CreaTools.tgz (binary version)"
84 echo " uninstall : uninstall the creatools"
86 echo " printconfig : print the configuration"
87 echo " help : print help"
88 echo " env : print some environnement variables"
90 echo " all : configure / compile / install"
96 echo " configure options: !!!!! IGNORED IF COMMAND IS NOT CONFIG OR ALL !!!!!!"
97 echo " -os <os> : operating system distribution (default $OperatingSystem)"
98 echo " -ncore <n> : number of core to use (default $corenumber)"
99 echo " -gdir <dir> : generation directory (default $generationdir)"
100 echo " -instprefix <dir> : creatools install prefix"
101 echo " -instprefix3 <dir> : 3rd party library install prefix"
102 echo " -html : get creatools from HTML"
103 echo " -git : get creatools from git (CREATIS user only)"
104 echo " -git-read-only : get creatools from git (anonymously, no write access)"
105 echo " -build : build type Release, RelWithDebug or Debug (default RelWithDebug)"
107 echo " experimental configure options (use at your own risk!!):"
108 echo " -gdcm2 : use GDCM2 "
109 echo " -doc : generate documentation"
110 echo " -itk4 : use ITK4"
115 ##################################################
117 while [ $# -ge 1 ] ; do
119 -os) OperatingSystem=$2; shift 2;;
120 -ncore) corenumber=$2; shift 2;;
121 -gdir) generationdir=$2; shift 2;;
122 -instprefix) installPrefix=$2; shift 2;;
123 -instprefix3) installPrefixThird=$2; shift 2;;
124 -doc) docgeneration=ON; shift 1;;
125 -html) sourcesFrom=HTML; shift 1;;
126 -git) sourcesFrom=GIT; shift 1;;
127 -git-read-only) sourcesFrom=GIT-READ-ONLY;
129 -gdcm2) gdcmVersion=GDCM2; shift 1;;
130 -itk4) ITKVersion=ITK4; shift 1;;
131 -build) buildType=$2; shift 2;;
136 if [ $# -le 0 ] ; then usage; fi
140 # check that command is valid
141 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
142 echo "Unrecognized command: $command"
148 ############################## use existing configuration if command is not config or all
149 if [ `checkVal $command config all` == false ] ; then
150 if [ ! -f $configureFile ] ; then
151 echo "scripts/CreaTools-configure.sh does not exists"
152 echo "please run the scripts with command \"config\" or \"all\""
155 source $configureFile
156 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
158 echo "the curently used Third Party libraries are NOT in $installPrefixThird but ... in :"
159 grep "installPrefixThird=" $ETC_BASHRC
160 echo "VTK_DIR : " $VTK_DIR
161 echo "ITK_DIR : " $ITK_DIR
162 echo "GDCM_DIR : " $GDCM_DIR
163 echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
170 ##################################################################################
171 ############################ check configuration parameters
173 checkDistrib $OperatingSystem
175 # complete default install prefix
176 if [ -z "$installPrefix" ] ; then installPrefix=$generationdir/creatools_install; fi
177 if [ -z "$installPrefixThird" ] ; then installPrefixThird=$generationdir/thirdparty_install; fi
180 if [ `checkVal $buildType Release Debug RelWithDebug` == "false" ] ; then
181 echo "Unsupported build type: $buildType"
182 echo "Please use one of: Release Debug RelWithDebug"
187 ##################################################################################
188 ############################ write configuration file
189 if [ `checkVal $command config all` == true ] ; then
190 echo "#!/bin/bash" > $configureFile
191 echo >> $configureFile
192 echo "#File generated by 'installscript'" >> $configureFile
193 echo "#DO NOT edit !" >> $configureFile
194 echo "#(except if you *do* know what you do)" >> $configureFile
195 echo >> $configureFile
196 echo "OperatingSystem=$OperatingSystem" >> $configureFile
197 echo "corenumber=$corenumber" >> $configureFile
198 echo "generationdir=$generationdir" >> $configureFile
199 echo "installPrefix=$installPrefix" >> $configureFile
200 echo "installPrefixThird=$installPrefixThird" >> $configureFile
201 echo "docgeneration=$docgeneration" >> $configureFile
202 echo "sourcesFrom=$sourcesFrom" >> $configureFile
203 echo "loginUserName=$loginUserName" >> $configureFile
204 echo "loginGroupName=$loginGroupName" >> $configureFile
205 echo "buildType=$buildType" >> $configureFile
206 echo "gdcmVersion=$gdcmVersion" >> $configureFile
207 echo "ITKVersion=$ITKVersion" >> $configureFile
208 echo "ETC_BASHRC=$ETC_BASHRC" >> $configureFile
213 ################################### print current configuration
217 ##################################################################################
218 ##################################################################################
219 ############ Process commands
220 ##################################################################################
221 ##################################################################################
224 ################################################################################## config printconfig
225 # config or printconfig : already done
226 if [ `checkVal $command config printconfig` == true ] ; then
230 ################################################################################## creatools
232 if [ `checkVal $command all creatools creatools-get` == true ] ; then
233 bigDisplay "DOWNLOAD CREATOOLS"
234 bash scripts/CreaTools-load.sh
237 ################################################################################## 3rd library
238 # install packaged dependencies as root
239 if [ `checkVal $command all 3rd 3rd-base` == true ] ; then
240 bigDisplay "INSTALL PACKAGES DEPENDENCIES"
241 source scripts/CreaTools-configure.sh
243 source ThirdParty-install-Base-Stuff.sh $OperatingSystem
245 bash scripts/ThirdParty-install.sh
249 if [ `checkVal $command all 3rd 3rd-vtk` == true ] ; then
250 bigDisplay "INSTALL VTK"
251 source scripts/ThirdParty-install-VTK.sh
256 if [ `checkVal $command all 3rd 3rd-gdcm` == true ] ; then
257 bigDisplay "INSTALL $gdcmVersion"
258 source scripts/ThirdParty-install-gdcm.sh
263 if [ `checkVal $command all 3rd 3rd-itk` == true ] ; then
264 bigDisplay "INSTALL $ITKVersion"
265 bash scripts/ThirdParty-install-ITK.sh
270 # Setup the user .bashrc correctly
271 if [ `checkVal $command all 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
272 bigDisplay "FINALIZE 3RD PARTY LIBRARY INSTALLATION"
273 bash scripts/ThirdParty-install-Finalize.sh
274 if [ `checkVal $command 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
275 bigDisplay "Third Party Install Done"
276 bigDisplay "Please copy paste the following command or open a new terminal: source ~/.bashrc"
280 ################################################################################## creatools
282 if [ `checkVal $command all creatools creatools-cmp` == true ] ; then
283 bigDisplay "COMPILE CREATOOLS"
284 echo "EED installscript compile creatools"
287 bash -x scripts/CreaTools-compile.sh
289 # To allow (*very* aware) user to patch code, later
290 if [ ! -e $generationdir/creatools_source ] ; then
291 echo "You probabely made a mistake : "
292 echo "Directory $loginUserName $generationdir/creatools_source not found"
293 echo "Make sure you know the mistake"
294 echo "Hit any key to continue"
295 echo "Fix the mistake!"
298 chown -R $loginUserName $generationdir/creatools_source
299 chgrp -R $loginGroupName $generationdir/creatools_source
304 if [ `checkVal $command all creatools creatools-install` == true ] ; then
305 bigDisplay "INSTALL CREATOOLS"
307 bash scripts/CreaTools-install.sh
313 echo "Open a new terminal to run creatools."
314 echo "(Close this window and continue....) "
317 read -p "Press [Enter] key to continue..."
320 #generate TGZ version of the bin (Creatools and ThirdParty)
321 if [ `checkVal $command creatools-generateBinTGZ` == true ] ; then
322 bash scripts/CreaTools-GenerateBinTGZ.sh
325 ################################################################################## uninstall
326 if [ `checkVal $command uninstall` == true ] ; then
327 bigDisplay "UNINSTALL CREATOOLS"
328 bash scripts/CreaTools-uninstall.sh
331 ################################################################################## help
332 if [ `checkVal $command help` == true ] ; then
336 ################################################################################## print env variables
337 if [ `checkVal $command env` == true ] ; then
338 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
341 echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
342 grep "installPrefixThird=" $ETC_BASHRC
343 echo "VTK_DIR : " $VTK_DIR
344 echo "ITK_DIR : " $ITK_DIR
345 echo "GDCM_DIR : " $GDCM_DIR
347 echo "installPrefixThird ... " $installPrefixThird
350 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
351 echo "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
353 cat $installPrefixThird/share/creatools_third_party_library_config.sh
359 if [ -f $installPrefix/share/creatools_base_library_config.sh ] ; then
360 echo "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
362 cat $installPrefix/share/creatools_base_library_config.sh
365 echo "installPrefix ... " $installPrefix
369 echo "VTK_DIR : " $VTK_DIR
370 echo "ITK_DIR : " $ITK_DIR
371 echo "GDCM_DIR : " $GDCM_DIR
373 echo "crea_DIR : " $crea_DIR
374 echo "BBTK_DIR : " $BBTK_DIR
375 echo "creaMaracasVisu_DIR : " $creaMaracasVisu_DIR
376 echo "creaEnvironment_DIR : " $creaEnvironment_DIR
377 echo "creaBruker_DIR : " $creaBruker_DIR
378 echo "creaImageIO_DIR : " $creaImageIO_DIR
379 echo "creaContours_DIR : " $creaContours_DIR
380 echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
381 echo "bbtkGEditor_DIR : " $bbtkGEditor_DIR
382 echo "creaTools_DIR : " $creaTools_DIR
383 echo "creaMiniTools_DIR : " $creaMiniTools_DIR
384 echo "Ido_DIR : " $Ido_DIR
385 echo "==================================="