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 if [ $sourcesFrom = CVS ] ; then
123 echo " CVS User Name : $cvsUserName"
125 echo " Login User Name : $loginUserName"
126 echo " Login Group Name : $loginGroupName"
127 echo " Build type : $buildType"
128 echo " Gdcm version : $gdcmVersion"
129 echo " ITK version : $ITKVersion"
136 ##################################################################################################
137 ##################################################################################################
138 ##################################################################################################
139 ##################################################################################################
140 ##################################################################################################
141 ##################################################################################################
143 configureFile="scripts/CreaTools-configure.sh"
146 # default configuration parameters
147 OperatingSystem=`getDistrib`
148 corenumber=`getncore`
149 generationdir=$HOME/CreatoolsGenerationDir
157 loginGroupName=`groups | awk '{print $1}'`
158 buildType=RelWithDebug
161 export ETC_BASHRC=`getbashrc`
168 echo "menu.sh [options] command"
169 echo "creatools configure/compile/install script"
172 echo "OPTIONS ARE USE FOR CONFIGURATION ONLY: THEY WILL BE IGNORED IF <COMMAND> IS NOT \"CONFIG\" OR \"ALL\""
176 echo " all : configure / compile / install"
178 echo " config : set the configuration parameters only"
180 echo " 3rd : Get, Compile, Install all 3rd party library "
181 echo " 3rd-base : Install basic tools (cmake, doxygen...)"
182 echo " 3rd-vtk : Get, Compile, Install vtk"
183 echo " 3rd-itk : Get, Compile, Install itk"
184 echo " 3rd-gdcm : Get, Compile, Install gdcm"
185 echo " 3rd-wx : Get, Compile, Install wx widget (for Mac Users)"
187 echo " creatools : Get Compile and Install the CreaTools"
188 echo " creatools-get : Get the CreaTools"
189 echo " creatools-cmp : Compile the CreaTools"
190 echo " creatools-install : Install the CreaTools"
192 echo " uninstall : uninstall the creatools"
194 echo " printconfig : print the configuration"
195 echo " help : print help"
196 echo " env : print some environnement variables"
201 echo " configure options: !!!!! IGNORED IF COMMAND IS NOT CONFIG OR ALL !!!!!!"
202 echo " -os <os> : operating system distribution (default $OperatingSystem)"
203 echo " -ncore <n> : number of core to use (default $corenumber)"
204 echo " -gdir <dir> : generation directory (default $generationdir)"
205 echo " -instprefix <dir> : creatools install prefix"
206 echo " -instprefix3 <dir> : 3rd party library install prefix"
207 echo " -cvs <cvsusername> : get creatools from cvs (CREATIS user only)"
208 echo " -build : build type Release, RelWithDebug or Debug (default RelWithDebug)"
210 echo " experimental configure options (use at your own risk!!):"
211 echo " -gdcm2 : use GDCM2 "
212 echo " -doc : generate documentation"
213 echo " -itk4 : use ITK4"
218 ##################################################
220 while [ $# -ge 1 ] ; do
222 -os) OperatingSystem=$2; shift 2;;
223 -ncore) corenumber=$2; shift 2;;
224 -gdir) generationdir=$2; shift 2;;
225 -instprefix) installPrefix=$2; shift 2;;
226 -instprefix3) installPrefixThird=$2; shift 2;;
227 -doc) docgeneration=ON; shift 1;;
228 -cvs) sourcesFrom=CVS; cvsUserName=$2; shift 2;;
229 -gdcm2) gdcmVersion=GDCM2; shift 1;;
230 -itk4) ITKVersion=ITK4; shift 1;;
231 -build) buildType=$2; shift 2;;
236 if [ $# -le 0 ] ; then usage; fi
240 # check that command is valid
241 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
242 echo "Unrecognized command: $command"
248 ############################## use existing configuration if command is not config or all
249 if [ `checkVal $command config all` == false ] ; then
250 if [ ! -f $configureFile ] ; then
251 echo "scripts/CreaTools-configure.sh does not exists"
252 echo "please run the scripts with command \"config\" or \"all\""
255 source $configureFile
256 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
258 echo "the curently used Third Party libraries are NOT in $installPrefixThird but ... in :"
259 grep "installPrefixThird=" $ETC_BASHRC
260 echo "VTK_DIR : " $VTK_DIR
261 echo "ITK_DIR : " $ITK_DIR
262 echo "GDCM_DIR : " $GDCM_DIR
263 echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
270 ##################################################################################
271 ############################ check configuration parameters
273 checkDistrib $OperatingSystem
275 # complete default install prefix
276 if [ -z "$installPrefix" ] ; then installPrefix=$generationdir/creatools_install; fi
277 if [ -z "$installPrefixThird" ] ; then installPrefixThird=$generationdir/thirdparty_install; fi
280 if [ `checkVal $buildType Release Debug RelWithDebug` == "false" ] ; then
281 echo "Unsupported build type: $buildType"
282 echo "Please use one of: Release Debug RelWithDebug"
287 ##################################################################################
288 ############################ write configuration file
289 if [ `checkVal $command config all` == true ] ; then
290 echo "#!/bin/bash" > $configureFile
291 echo >> $configureFile
292 echo "#File generated by 'menu.sh'" >> $configureFile
293 echo "#DO NOT edit !" >> $configureFile
294 echo "#(except if you *do* know what you do)" >> $configureFile
295 echo >> $configureFile
296 echo "OperatingSystem=$OperatingSystem" >> $configureFile
297 echo "corenumber=$corenumber" >> $configureFile
298 echo "generationdir=$generationdir" >> $configureFile
299 echo "installPrefix=$installPrefix" >> $configureFile
300 echo "installPrefixThird=$installPrefixThird" >> $configureFile
301 echo "docgeneration=$docgeneration" >> $configureFile
302 echo "sourcesFrom=$sourcesFrom" >> $configureFile
303 echo "cvsUserName=$cvsUserName" >> $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 su -c "bash scripts/ThirdParty-install-Base-Stuff.sh"
343 bash scripts/ThirdParty-install.sh
347 if [ `checkVal $command all 3rd 3rd-vtk` == true ] ; then
348 bigDisplay "INSTALL VTK"
349 bash scripts/ThirdParty-install-VTK.sh
353 if [ `checkVal $command all 3rd 3rd-gdcm` == true ] ; then
354 bigDisplay "INSTALL $gdcmVersion"
355 bash scripts/ThirdParty-install-gdcm.sh
359 if [ `checkVal $command all 3rd 3rd-itk` == true ] ; then
360 bigDisplay "INSTALL $ITKVersion"
361 bash scripts/ThirdParty-install-ITK.sh
365 #if [ `checkVal $command all 3rd` == true ] ; then
366 # bash scripts/ThirdParty-install.sh
369 # Setup the user .bashrc correctly
370 if [ `checkVal $command all 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
371 bigDisplay "FINALIZE 3RD PARTY LIBRARY INSTALLATION"
372 bash scripts/ThirdParty-install-Finalize.sh
374 if [ `checkVal $command 3rd 3rd-vtk 3rd-itk 3rd-gdcm 3rd-wx ` == true ] ; then
375 bigDisplay "Third Party Install Done"
376 bigDisplay "Please copy paste the following command or open a new terminal: source ~/.bashrc"
380 ################################################################################## creatools
383 if [ `checkVal $command all creatools creatools-get` == true ] ; then
384 bigDisplay "DOWNLOAD CREATOOLS"
385 bash scripts/CreaTools-load.sh
389 if [ `checkVal $command all creatools creatools-cmp` == true ] ; then
390 bigDisplay "COMPILE CREATOOLS"
392 bash -x scripts/CreaTools-compile.sh
394 # To allow (*very* aware) user to patch code, later
395 if [ ! -e $generationdir/creatools_source ] ; then
396 echo "You probabely made a mistake : "
397 echo "Directory $loginUserName $generationdir/creatools_source not found"
398 echo "Make sure you know the mistake"
399 echo "Hit any key to continue"
400 echo "Fix the mistake!"
403 chown -R $loginUserName $generationdir/creatools_source
404 chgrp -R $loginGroupName $generationdir/creatools_source
409 if [ `checkVal $command all creatools creatools-install` == true ] ; then
410 bigDisplay "INSTALL CREATOOLS"
412 bash scripts/CreaTools-install.sh
416 ################################################################################## uninstall
418 if [ `checkVal $command uninstall` == true ] ; then
419 bigDisplay "UNINSTALL CREATOOLS"
420 bash scripts/CreaTools-uninstall.sh
423 ################################################################################## help
424 if [ `checkVal $command help` == true ] ; then
428 ################################################################################## print env variables
429 if [ `checkVal $command env` == true ] ; then
430 if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
433 echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
434 grep "installPrefixThird=" $ETC_BASHRC
435 echo "VTK_DIR : " $VTK_DIR
436 echo "ITK_DIR : " $ITK_DIR
437 echo "GDCM_DIR : " $GDCM_DIR
439 echo "installPrefixThird ... " $installPrefixThird
442 if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ] ; then
443 echo "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
445 cat $installPrefixThird/share/creatools_third_party_library_config.sh
451 if [ -f $installPrefix/share/creatools_base_library_config.sh ] ; then
452 echo "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
454 cat $installPrefix/share/creatools_base_library_config.sh
457 echo "installPrefix ... " $installPrefix
461 echo "VTK_DIR : " $VTK_DIR
462 echo "ITK_DIR : " $ITK_DIR
463 echo "GDCM_DIR : " $GDCM_DIR
465 echo "crea_DIR : " $crea_DIR
466 echo "BBTK_DIR : " $BBTK_DIR
467 echo "creaMaracasVisu_DIR : " $creaMaracasVisu_DIR
468 echo "creaEnvironment_DIR : " $creaEnvironment_DIR
469 echo "creaBruker_DIR : " $creaBruker_DIR
470 echo "creaImageIO_DIR : " $creaImageIO_DIR
471 echo "creaContours_DIR : " $creaContours_DIR
472 echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
473 echo "bbtkGEditor_DIR : " $bbtkGEditor_DIR
474 echo "creaTools_DIR : " $creaTools_DIR
475 echo "creaMiniTools_DIR : " $creaMiniTools_DIR
476 echo "Ido_DIR : " $Ido_DIR
477 echo "==================================="