]> Creatis software - creaToolsTools.git/blob - Linux/menu.sh
Feature #1773 Add licence terms for all files.
[creaToolsTools.git] / Linux / menu.sh
1 # ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
4 #                        pour la Santé)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 #
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.
13 #
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
18 #  liability. 
19 #
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 # ------------------------------------------------------------------------  
23
24
25 #!/bin/bash -e
26
27   if [ -f scripts/CreaTools-configure.sh ]
28   then
29      source scripts/CreaTools-configure.sh
30   fi
31
32 expanded="NO"
33 i=999
34 while [ "$i" != 9 ]
35 do
36    clear
37    echo
38    echo
39    echo
40    echo "                MENU"
41    echo
42    echo " Choose what you want to do :"
43    echo  
44    echo " Configure :........................0"
45
46    if [ $expanded = "YES" ]
47    then 
48       echo " Install all base stuff  :..........1.0"
49       echo "        (cmake, doxygen, graphviz, ...)"
50       echo " Get, Compile, Install vtk   .......1.1"                
51       echo " Get, Compile, Install gdcm :.. .  .1.2" 
52       echo " Get, Compile, Install itk  :.......1.3"
53       echo " Get, Compile, Install Wx (for Mac Users)  :…....1.4"
54
55    else
56       echo " Install Third Party Libraries :....1 (as root)"   
57    fi
58      
59    if [ $expanded = "YES" ]
60    then
61       echo " Get the 'CreaTools' source files :.2.1 (CVS : as user!)" 
62       echo " Compile   the CreaTools :..........2.2"
63       # Install creatools as user (no longer as root) // JPR 2/5/2011   
64       echo " Install   the CreaTools :..........2.3"
65    else
66       echo " Get and Install the 'CreaTools':...2"
67    fi
68    echo
69    if [ $expanded = "NO" ]
70    then
71       echo " Use Expanded menu :................5 "
72    else
73       echo " Use compact menu :.................5 "
74    fi
75    echo " Uninstall the CreaTools :..........6 "
76    echo " Help ..............................7 Help about this menu"   
77    echo " Show some Environment Variables ...8"
78    echo " Exit :.............................9"
79    echo
80    echo
81    echo 
82
83   echo "Type in your choice :"
84   read i
85
86   case $i in
87   0)
88
89   # Do it, while we are under user, not under root! # JPR
90               if [ -f $HOME/.bashrc ]
91               then
92                  export ETC_BASHRC=$HOME/.bashrc
93               else
94                  if [ -f $HOME/.profile ]
95                      then
96                     export ETC_BASHRC=$HOME/.profile
97                      else
98                         echo "======================== BIG TROUBLE : neither $HOME/.bashrc nor $HOME/.profile file found"
99                         echo "======================== You'd better to abort the program and (try to) fix the issue"
100                         read a # just to let the user time enough to read the message...
101                      fi
102           fi
103
104   clear
105   suitable=XXX
106   #ls -l  scripts/CreaTools-configure.sh
107   if [ -f scripts/CreaTools-configure.sh ]
108   then
109      while [[ "$suitable" != "YES" && \
110               "$suitable" != "yes" && \
111               "$suitable" != "Y"   && \
112               "$suitable" != "y"   && \
113               "$suitable" != "NO"  && \
114               "$suitable" != "no"  ]]
115      do   
116         echo "'Configure' already done; Content of scripts/CreaTools-configure.sh :"
117         echo "------------------------"
118         more scripts/CreaTools-configure.sh
119         echo "------------------------"
120         
121             # WARNING : $installPrefixThird is taken from CreaTools-configure.sh
122         # If user configured without installing third party library,
123         # last third party library is still in use!  JPR
124
125         if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
126         then
127            echo WARNING
128            echo "the curently used Third Party libraries are NOT in $installPrefixThird but ... in :"
129            grep "installPrefixThird=" $ETC_BASHRC
130            echo "VTK_DIR  : " $VTK_DIR
131            echo "ITK_DIR  : " $ITK_DIR
132            echo "GDCM_DIR : " $GDCM_DIR
133            echo "(Have a look at $ETC_BASHRC=, edit it or run again Install Third Party Libraries if you disagree)"
134         fi
135         echo    
136         echo "Are these values suitable for you : YES/NO? (default is YES)"
137         read suitable
138         if [ "$suitable" = "" ]
139         then
140            suitable="YES"
141         fi
142      done
143   else
144      suitable="NO"
145   fi
146
147   if [[ "$suitable" = "YES" || "$suitable" = "Y" || "$suitable" = "yes" || "$suitable" = "y" ]]
148   then
149      source scripts/CreaTools-configure.sh
150   fi
151   
152  if [[ "$suitable" = "NO" || "$suitable" = "N"  || "$suitable" = "no" || "$suitable" = "n" ]]
153  #if [ "$suitable" = "NO" ]
154   then
155      echo
156      echo
157      confirm="NO"
158      while [ "$confirm" != "YES" ]
159      do
160         # ///\TODO what about SuSE? Debian? Mandriva? Gentoo?    
161         OperatingSystem="XXX"
162         while [[ "$OperatingSystem" != "Fedora" && \
163                  "$OperatingSystem" != "Ubuntu" && \
164                  "$OperatingSystem" != "MacOS" ]]
165         do
166            echo "Operating System : Fedora/Ubuntu/MacOS (default : Fedora)"
167            read OperatingSystem
168            if [ "$OperatingSystem" = "" ]
169            then
170              OperatingSystem="Fedora"
171            fi  
172         done
173         echo "you said : [" $OperatingSystem "]"
174         echo
175         echo
176         
177         # ------------------
178         echo "How many cores on your computer 2 (default is 2)"
179         read corenumber
180         if [ "$corenumber" = "" ]
181         then
182            corenumber="2"
183         fi
184         echo "you said : [" $corenumber "]"
185
186         echo
187         echo
188                 
189         racine=$HOME/myDefaultCreatoolsGenerationDir
190         # ------------------
191         echo "Name of the Generation Directory (default is $racine)"
192         read generationdir
193         if [ "$generationdir" = "" ]
194         then
195            generationdir=$racine
196         fi
197         echo "you said : [" $generationdir "]"
198
199         echo
200         echo
201         # ------------------
202         installPrefixThird="___"
203         echo "Install Prefix For Third Party Library : '$generationdir/thirdparty_install' / '/usr/local' (default is '$generationdir/thirdparty_install')"
204         read installPrefixThird
205         if [ "$installPrefixThird" = "" ]
206         then
207            installPrefixThird="$generationdir/thirdparty_install"
208         fi
209         echo "you said : [" $installPrefixThird "]"
210         echo
211         echo 
212         # ------------------
213
214         installPrefix="___"
215         echo "Install Prefix for CreaTools : '$generationdir/creatools_install' / '/usr/local' (default is '$generationdir/creatools_install')"
216         read installPrefix
217         if [ "$installPrefix" = "" ]
218         then
219            installPrefix="$generationdir/creatools_install"
220         fi
221         echo "you said : [" $installPrefix "]"
222         echo
223         echo 
224         # ------------------
225
226 if [ false ]
227 then
228         docgeneration="___"
229         while [[ "$docgeneration" != "ON"  && "$docgeneration" != "OFF" ]]
230         do
231            echo "Boolean For Doc Generation : ON/OFF (default is OFF)"
232            read docgeneration
233            if [ "$docgeneration" = "" ]
234            then
235               docgeneration="OFF"
236            fi
237            echo "you said : [" $docgeneration "]"
238         done
239         echo
240         echo
241 fi
242
243 docgeneration="OFF"
244
245         # ------------------
246
247         sourcesFrom="___"
248         while [[ "$sourcesFrom" != "CVS"  && "$sourcesFrom" != "HTML" ]]
249         do
250            echo "Where do you want to get source files from : CVS/HTML ( CVS : for registered CREATIS users only! )"
251            read sourcesFrom
252            if [ "$sourcesFrom" = "" ]
253            then
254               sourcesFrom="CVS"
255            fi
256            echo "you said : [" $sourcesFrom "]"
257         done
258         echo
259         echo
260         # ------------------
261
262         cvsUserName=""
263         if [ "$sourcesFrom" = "CVS" ]
264         then
265            while [ "$cvsUserName" == "" ]
266            do
267               echo "CVS User Name ( registered CREATIS user : mandatory!)"
268               read cvsUserName
269            done
270            echo "you said : [" $cvsUserName "]"
271         else
272            cvsUserName="ForgetThisOne" 
273         fi
274         echo
275         echo
276         # ------------------
277
278
279         #loginUserName=""
280             loginUserName=$USER
281         #while [ "$loginUserName" == "" ]
282         #do 
283            echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
284            ls -l menu.sh
285          #  echo "Login User Name (mandatory!)"
286          #  read loginUserName  
287          #  echo "you said : [" $loginUserName "]"  
288         #done
289         echo
290         echo
291
292         loginGroupName=""
293         while [ "$loginGroupName" == "" ]
294         do
295            echo "Have a look at the following line to know 'Login User Name'/'Login Group Name'"
296                echo "Login Group Name (mandatory!)"
297            read loginGroupName  
298            echo "you said : [" $loginGroupName "]"  
299         done
300         echo
301         echo
302         # ------------------
303
304         buildType="___"
305         while [[ "$buildType" != "Release"  && "$buildType" != "Debug" ]]
306         do
307            echo "Build type : Release/Debug (default is Release)"
308            read buildType
309            if [ "$buildType" = "" ]
310            then
311               buildType="Release"
312            fi
313            echo "you said : [" $buildType "]"
314         done
315         echo
316         echo
317         # ------------------
318
319         gdcmVersion="___"
320         while [[ "$gdcmVersion" != "GDCM1"  && "$gdcmVersion" != "GDCM2" ]]
321         do
322            echo "Gdcm version : GDCM1/GDCM2 (default is GDCM1)"
323            read gdcmVersion
324            if [ "$gdcmVersion" = "" ]
325            then
326               gdcmVersion="GDCM1"
327            fi
328            echo "you said : [" $gdcmVersion "]"
329         done
330
331 # NOT YET CHECKED ! JPR
332         ITKVersion="___"
333         while [[ "$ITKVersion" != "ITK3"  && "$ITKVersion" != "ITK4" ]]
334         do
335            echo "ITK version : ITK3/ITK4 (default is ITK3)"
336            read ITKVersion
337            if [ "$ITKVersion" = "" ]
338            then
339               ITKVersion="ITK3"
340            fi
341            echo "you said : [" $ITKVersion "]"
342         done
343
344         echo
345         echo
346         echo
347         echo
348         echo "You said :"
349         echo "  Operating System                           : $OperatingSystem"
350         echo "  Number of Cores                            : $corenumber"       
351         echo "  Name of the Generation Directory           : $generationdir"
352         echo "  Install Prefix for Third Party Libraries   : $installPrefixThird"       
353         echo "  Install Prefix for CreaTools               : $installPrefix"
354         echo "  Boolean for Doc Generation                 : $docgeneration"
355         echo "  Where do you want to get source files from : $sourcesFrom"
356         if [ $sourcesFrom = CVS ]
357         then
358            echo "  CVS User Name                              : $cvsUserName"
359         fi
360         echo "  Login User Name                            : $loginUserName"
361         echo "  Login Group Name                           : $loginGroupName"
362         echo "  Build type                                 : $buildType"          
363         echo "  Gdcm version                               : $gdcmVersion"
364         echo "  ITK version                                : $ITKVersion"
365         echo
366         echo
367      
368         echo "Do you confirm your choices : YES/NO ? (default is YES)"
369         read confirm
370         if [ "$confirm" = "" ]
371         then
372            confirm=YES
373         fi
374    done
375
376  # ==> On genere le fichier CreaTools-configure.sh genere chez l'utilisateur (no choice!)...
377  # 
378
379    configureFile="scripts/CreaTools-configure.sh"
380    touch  $configureFile
381    echo "#!/bin/bash"                            >  $configureFile
382    echo                                          >> $configureFile
383    echo "#File generated by 'menu.sh'"           >> $configureFile
384    echo "#DO NOT edit !"                         >> $configureFile
385    echo "#(except if you *do* know what you do)" >> $configureFile
386    echo                                          >> $configureFile
387    echo "OperatingSystem=$OperatingSystem"       >> $configureFile
388    echo "corenumber=$corenumber"                 >> $configureFile   
389    echo "generationdir=$generationdir"           >> $configureFile
390    echo "installPrefix=$installPrefix"           >> $configureFile
391    echo "installPrefixThird=$installPrefixThird" >> $configureFile
392    echo "docgeneration=$docgeneration"           >> $configureFile
393    echo "sourcesFrom=$sourcesFrom"               >> $configureFile
394    echo "cvsUserName=$cvsUserName"               >> $configureFile 
395    echo "loginUserName=$loginUserName"           >> $configureFile
396    echo "loginGroupName=$loginGroupName"         >> $configureFile
397    echo "buildType=$buildType"                   >> $configureFile
398    echo "gdcmVersion=$gdcmVersion"               >> $configureFile
399    echo "ITKVersion=$ITKVersion"                 >> $configureFile
400    echo "ETC_BASHRC=$ETC_BASHRC"                 >> $configureFile
401
402   # ------------------      
403   # endif 'suitable'
404   fi 
405   ;;
406   
407   1)
408      echo "========================== 1 "
409      source scripts/Check-if-root.sh
410      bash scripts/ThirdParty-install-Base-Stuff.sh     
411      bash scripts/ThirdParty-install-VTK.sh
412      bash scripts/ThirdParty-install-gdcm.sh
413      bash scripts/ThirdParty-install-ITK.sh
414      bash scripts/ThirdParty-install.sh
415      bash scripts/ThirdParty-install-Finalize.sh
416
417      if [ "$sourcesFrom" = "CVS" ]
418      then
419         echo "----------------------------------------------------------------------"
420         echo OK
421         echo "To go on, run again 'bash menu.sh' as '$loginUserName', in a new window"
422         echo "----------------------------------------------------------------------"
423      else
424         echo "----------------------------------------------------------------------"
425         echo OK
426         echo "To go on, run again 'bash menu.sh'  in a new window"
427         echo "----------------------------------------------------------------------"
428      fi
429      echo
430      echo "==>"
431      echo "==> You HAVE to leave current window to continue!" 
432      echo "==>"
433      source $ETC_BASHRC
434      read a
435   ;;
436
437   1.0)
438      echo "========================== 1.0 "
439      source scripts/Check-if-root.sh
440      bash scripts/ThirdParty-install-Base-Stuff.sh     
441      bash scripts/ThirdParty-install-Finalize.sh
442   ;;
443
444   1.1)
445      echo "========================== 1.1 "
446      #source scripts/Check-if-root.sh 
447      bash scripts/ThirdParty-install-VTK.sh  
448      bash scripts/ThirdParty-install-Finalize.sh
449   ;;
450
451   1.2)
452      echo "========================== 1.2 "
453      #source scripts/Check-if-root.sh
454      bash scripts/ThirdParty-install-gdcm.sh
455      bash scripts/ThirdParty-install-Finalize.sh
456   ;;
457
458   1.3)
459      echo "========================== 1.3 "
460      #source scripts/Check-if-root.sh
461      bash scripts/ThirdParty-install-ITK.sh
462      bash scripts/ThirdParty-install-Finalize.sh         
463   ;;
464   1.4)
465     echo "========================== 1.4 "
466      #source scripts/Check-if-root.sh
467      bash scripts/ThirdParty-install-WX.sh     
468      bash scripts/ThirdParty-install-Finalize.sh         
469      read a
470   ;;
471
472   2)
473      #2.1
474      bash scripts/CreaTools-load.sh
475      #2.2
476      source scripts/CreaTools-configure.sh
477      bash scripts/CreaTools-compile.sh
478      #2.3
479      bash scripts/CreaTools-install.sh
480      echo "==>"
481      echo "==> You HAVE to leave current window to continue!"
482      echo "==>"
483      source $ETC_BASHRC
484      read a
485      kill -9 $PPID
486   ;;
487
488   2.1)
489      echo "========================== 2.1"
490      bash scripts/CreaTools-load.sh
491   ;;
492
493   2.2)
494      echo "========================== 2.2"
495      source scripts/CreaTools-configure.sh
496      
497      bash scripts/CreaTools-compile.sh
498
499      # To allow (*very* aware) user to patch code, later
500      if [ ! -e $generationdir/creatools_source ]
501      then
502         echo "You probabely made a mistake : "
503             echo "Directory $loginUserName $generationdir/creatools_source not found"
504             echo "Make sure you know the mistake"
505             echo "Hit any key to continue"
506             echo "Fix the mistake!"
507             read a
508      else
509         chown -R $loginUserName  $generationdir/creatools_source
510         chgrp -R $loginGroupName $generationdir/creatools_source
511     fi    
512   ;;
513
514   2.3)
515
516       echo "========================= 4"
517       
518       bash scripts/CreaTools-install.sh
519    
520 #      if [ $UID != 0 ]
521 #      then
522 #        echo "You HAVE to leave current window to continue!"
523 #      else
524 #        echo "==> Hit any key to close current window"
525 #      fi
526      source $ETC_BASHRC
527   ;;
528
529   5)
530    if [ $expanded = "NO" ]
531    then
532      expanded="YES"
533    else
534      expanded="NO"
535    fi
536   ;;
537
538   6)
539      echo "========================= 5"
540      bash scripts/CreaTools-uninstall.sh 
541      echo
542      echo "==> Hit any key to go on"
543      read a
544   ;;
545
546   7)
547      clear
548      echo "==================================="
549      more README.txt
550      echo
551      echo "==> Hit any key to go on" 
552      read a
553   ;;
554          
555   8)
556      clear
557      echo "==================================="
558      
559      # WARNING : $installPrefixThird is taken from CreaTools-configure.sh
560      # If user configured without installing third party library,
561      # last third party library is still in use!  JPR
562
563
564      if [ ! -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
565      then
566         echo WARNING
567         echo
568         echo "the curently used Third Party libraries are NOT in $installPrefixThird but in :"
569         grep "installPrefixThird=" $ETC_BASHRC
570         echo "VTK_DIR  : " $VTK_DIR
571         echo "ITK_DIR  : " $ITK_DIR
572         echo "GDCM_DIR : " $GDCM_DIR
573         echo
574         echo "installPrefixThird ... " $installPrefixThird
575      fi
576              
577      if [ -f $installPrefixThird/share/creatools_third_party_library_config.sh ]
578      then
579         echo  "Third party config file : " $installPrefixThird/share/creatools_third_party_library_config.sh
580             echo  ------
581             more $installPrefixThird/share/creatools_third_party_library_config.sh
582             echo  ------
583      fi
584      
585      echo
586      
587      if [ -f $installPrefix/share/creatools_base_library_config.sh ]
588      then
589         echo  "Creatools base library config file : " $installPrefix/share/creatools_base_library_config.sh
590             echo  ------ 
591             more $installPrefix/share/creatools_base_library_config.sh
592             echo  ------ 
593             echo
594         echo "installPrefix ... " $installPrefix
595      fi
596      echo  ------
597         echo "VTK_DIR  :                 " $VTK_DIR
598         echo "ITK_DIR  :                 " $ITK_DIR
599         echo "GDCM_DIR :                 " $GDCM_DIR
600         echo
601         echo "crea_DIR :                 " $crea_DIR
602         echo "BBTK_DIR :                 " $BBTK_DIR
603         echo "creaMaracasVisu_DIR :      " $creaMaracasVisu_DIR
604         echo "creaEnvironment_DIR :      " $creaEnvironment_DIR
605         echo "creaBruker_DIR :           " $creaBruker_DIR
606         echo "creaImageIO_DIR :          " $creaImageIO_DIR
607         echo "creaContours_DIR :         " $creaContours_DIR
608         echo "creaRigidRegistration_DIR :" $creaRigidRegistration_DIR
609         echo "bbtkGEditor_DIR :          " $bbtkGEditor_DIR
610         echo "creaTools_DIR :            " $creaTools_DIR
611         echo "creaMiniTools_DIR :        " $creaMiniTools_DIR
612         echo "Ido_DIR :                  " $Ido_DIR
613         echo "==================================="
614         echo
615         echo "Press any key to continue"
616         read a
617    ;;
618
619   9) 
620     echo
621     exit 0
622     ;;
623
624   10)
625   # Hiden option, usefull at debug time
626     bash scripts/ThirdParty-install_no_compile.sh  
627     ;;
628       
629   *)
630
631   if [ expanded="NO" ]
632   then
633      echo "Your answer must be in {0, 1, 2, 5, 6, 7, 8, 9} (was [ $i ])"
634   else
635      echo "Your answer must be in {0, 1, 2.1, 2.2, 2.3, 5, 6, 7, 8, 9} (was [ $i ])"
636   fi
637   ;;
638   esac
639
640 done
641
642