#!/bin/sh
-if [ $# = 0 ]
-then
-
-echo "Run it as 'root':"
-echo "Use it as :"
-echo "sh make-install.sh <nameOfTheGenerationDirectory> <BooleanForDocGeneration> <userNameForCVS> <installPrefix> <buildType> <GDCM Version>"
-echo "with 'installPrefix' : /usr/local or <directory where you want to generate>/creatools_install"
-echo "with 'GDCM Version' : GDCM1 / GDCM2"
-echo " "
-echo "ex : sh make-install.sh /tmp/gendir OFF jpr /tmp/gendir/creatools_install Debug GDCM2"
-exit 0
-fi
-
-echo $#
-echo "----------"
-echo $0
-echo $1
-echo $2
-echo $3
-echo $4
-echo $5
-echo $6
-echo "----------"
-
-if [ $# != 6 ]
-then
-echo "sh make-install.sh <nameOfTheGenerationDirectory> <BooleanForDocGeneration> <userNameForCVS> <installPrefix> <buildType> <GDCM Version>"
-echo "with 'installPrefix' : /usr/local or <directory where you want to generate>/creatools_install"
-echo " "
-echo "ex : sh make-install.sh /tmp/gendir OFF jpr /tmp/gendir/creatools_install Debug GDCM2"
-exit 0
-fi
-
-# @echo off
-
-#allow user to choose the generation dir
-#allow user to choose to generate the doc or not
-
-generationdir=$1
-docGeneration=$2
-cvsUserName=$3
-installPrefix=$4
-buildType=$5
-gdcmVersion=$6
-
-scriptDir=$PWD
-echo scriptDir
-echo $scriptDir
-
-
-# /// \TODO check if directories exist.
-# /// \ exit 0 if they don't (message: run install.sh first!")
-#mkdir $generationdir
-#mkdir $generationdir/creatools_source
-#mkdir $generationdir/creatools_bin
-
- creasource=crea
- bbtksource=bbtk
- creamaracassource=creaMaracasVisu
- creaenvironmentsource=creaEnvironment
- creabrukersource=creaBruker
- creaimagesource=creaImageIO
- creacontourssource=creaContours
- crearigidregistrationssource=creaRigidRegistration
- bbtkgeditorsource=bbtkGEditor
- creatoolssource=creaTools
-
-cd $generationdir
-
-# start_point : used at debug time : start point of the script
-# ex : if everything is OK, but bbtkGEditor,
-# cvs upate bbtkGEditor manually,and use :
-# start_point=10
-# in order not to cvs co everything, nor recompile everything.
-
-start_point=0
-
-# --------------------------------
-# start_point = 1 : remove everything hat was installed before
-#---------------------------------
-if [ $start_point -le 1 ]
-then
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
-
- rm -rf creatools_install/lib/creatools
- rm -rf creatools_install/lib64/creatools
- rm -rf creatools_install/bin/bb*
- rm -rf creatools_install/bin/crea*
- rm -rf creatools_install/include/bb*
- rm -rf creatools_install/include/crea*
- rm -rf creatools_install/share/bb*
- rm -rf creatools_install/share/crea*
-
-#this is for the old versions EED
- rm -rf creatools_install/lib/crea*
- rm -rf creatools_install/lib/libbb*
- rm -rf creatools_install/lib/libcrea*
- rm -rf creatools_install/lib64/crea*
- rm -rf creatools_install/lib64/libbb*
- rm -rf creatools_install/lib64/libcrea*
-fi
-fi
-
-
-cd $scriptDir
-
-
-# -------------------------
-# start_point = 2 : CREA
-#-------------------------
-if [ $start_point -le 2 ]
-then
-# CREA
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
- sh installmod.sh $buildType $creasource $generationdir
-
-fi
-fi
- creadll=$generationdir/creatools_bin/creaBin
- LD_LIBRARY_PATH=$creadll:LD_LIBRARY_$PATH
-
-
-
-# -------------------------
-# start_point = 3 : BBTK
-#-------------------------
-if [ $start_point -le 3 ]
-then
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
-# BBTK
- sh installmod.sh $buildType $bbtksource $generationdir
-fi
-fi
- bbtkdll=$generationdir/creatools_bin/bbtkBin
- LD_LIBRARY_PATH=$bbtkdll:$LD_LIBRARY_PATH
-
-
-# -------------------------
-# start_point = 4 : creaMaracasVisu
-#-------------------------
-if [ $start_point -le 4 ]
-then
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
-# creaMaracasVisu
- sh installmod.sh $buildType $creamaracassource $generationdir
-fi
-fi
- creamaracasdll=$generationdir/creatools_bin/creamaracasBin
- LD_LIBRARY_PATH=$creamaracasdll:$LD_LIBRARY_PATH
-
-
-# -------------------------
-# start_point = 5 : creaEnvironment
-#-------------------------
-if [ $start_point -le 5 ]
-then
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
-# creaEnvironment
- sh installmod.sh $buildType $creaenvironmentsource $generationdir
-fi
-fi
- creaenvironmentdll=$generationdir/creatools_bin/creaenvironmentBin
- LD_LIBRARY_PATH=$creaenvironmentdll:$LD_LIBRARY_PATH
-
-
-# -------------------------
-# start_point = 6 : creaBruker
-#-------------------------
-if [ $start_point -le 6 ]
-then
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
-# creaBruker
- sh installmod.sh $buildType $creabrukersource $generationdir
- echo generationdir
-fi
-fi
- creabrukerdll=$generationdir/creatools_bin/creabrukerBin
- LD_LIBRARY_PATH=$creabrukerdll:$LD_LIBRARY_PATH
-
-
-# -------------------------
-# start_point = 7 : creaImageIO
-#-------------------------
-if [ $start_point -le 7 ]
-then
- # the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
-# creaImageIO
- sh installmod.sh $buildType $creaimagesource $generationdir
-fi
-fi
- creaimagedll=$generationdir/creatools_bin/creaimageBin
- LD_LIBRARY_PATH=$creaimagedll:$LD_LIBRARY_PATH
-
-
-# -------------------------
-# start_point = 8 : creaContour
-#-------------------------
-if [ $start_point -le 8 ]
-then
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
-# creaContours
- sh installmod.sh $buildType $creacontourssource $generationdir
-fi
-fi
-# creacontourdll=$generationdir/creatools_bin/creacontoursBin
-# LD_LIBRARY_PATH=$creacontoursdll:$LD_LIBRARY_PATH
-
-
-# -------------------------
-# start_point = 9 : creaRigidRegistration
-#-------------------------
-if [ $start_point -le 9 ]
-then
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
- sh installmod.sh $buildType $crearigidregistrationssource $generationdir
-fi
-fi
-# crearigidregistrationdll=$generationdir/creatools_bin/crearigidregistrationBin
-# LD_LIBRARY_PATH=$crearigidregistrationdll:$LD_LIBRARY_PATH
-
-
-# -------------------------
-# start_point = 10 : bbtkGEditor
-#-------------------------
-if [ $start_point -le 10 ]
-then
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
-# bbtkGEditor
- sh installmod.sh $buildType $bbtkgeditorsource $generationdir
-fi
-fi
-# bbtkgeditordll=$generationdir/creatools_bin/bbtkgeditorBin
-# LD_LIBRARY_PATH=$bbtkgeditordll:$LD_LIBRARY_PATH
-
-
-# -------------------------
-# start_point = 11 : creaTools
-#-------------------------
-if [ $start_point -le 11 ]
-then
-# the following stupid test is used at debug time; Please don't remove!
-#if [ true = false ]
-if [ true = true ]
-then
-# creaTools
- sh installmod.sh $buildType $creatoolssource $generationdir
-fi
-fi
-
-
-# creatoolsdll=$generationdir/creatools_bin/creatoolsBin
-# LD_LIBRARY_PATH=$creatoolssdll:$LD_LIBRARY_PATH
-
-
-CREATOOLS_INSTALL_DIR=$installPrefix
-rm $CREATOOLS_INSTALL_DIR/share/creatools_base_library_config.sh
-touch $CREATOOLS_INSTALL_DIR/share/creatools_base_library_config.sh
-chmod 666 $CREATOOLS_INSTALL_DIR/share/creatools_base_library_config.sh
-
-#######################################
-
-touch $installPrefix/share/creatools_base_library_config.sh
-chmod 666 $installPrefix/share/creatools_base_library_config.sh
-
-
-echo export PATH='$'PATH:$installPrefix/bin >> $installPrefix/share/creatools_base_library_config.sh
-echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$installPrefix/lib/creatools >> $installPrefix/share/creatools_base_library_config.sh
-echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$installPrefix/lib64/creatools >> $installPrefix/share/creatools_base_library_config.sh
-
-# modify .bashrc
-# - remove line 'sh $installPrefix/creatools_install/share/creatools_base_party_libraries_config.sh' if any (with accurate value for ???)
-sed -i -e '/.*creatools_base_library_config.*/ d' ~/.bashrc
-
-# - add line 'sh $installPrefix/creatools_install/share/creatools_base_libraries_config.sh' (with accurate value for ???)
-echo source $installPrefix/share/creatools_base_library_config.sh >> ~/.bashrc
+if [ $UID = 0 ]
+then
+ # Set all local variables
+ source $PWD/configure.sh
+ cd $scriptDir
+ sh installmod.sh $buildType $creasource $generationdir
+ sh installmod.sh $buildType $bbtksource $generationdir
+ sh installmod.sh $buildType $creamaracassource $generationdir
+ sh installmod.sh $buildType $creaenvironmentsource $generationdir
+ sh installmod.sh $buildType $creabrukersource $generationdir
+ sh installmod.sh $buildType $creaimagesource $generationdir
+ sh installmod.sh $buildType $creacontourssource $generationdir
+ sh installmod.sh $buildType $crearigidregistrationssource $generationdir
+ sh installmod.sh $buildType $bbtkgeditorsource $generationdir
+ sh installmod.sh $buildType $creatoolssource $generationdir
+
+ touch $installPrefix/share/creatools_base_library_config.sh
+ rm $installPrefix/share/creatools_base_library_config.sh
+ touch $installPrefix/share/creatools_base_library_config.sh
+ chmod 755 $installPrefix/share/creatools_base_library_config.sh
+
+ echo export PATH='$'PATH:$installPrefix/bin >> $installPrefix/share/creatools_base_library_config.sh
+ echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$installPrefix/lib/creatools >> $installPrefix/share/creatools_base_library_config.sh
+ echo export LD_LIBRARY_PATH='$'LD_LIBRARY_PATH:$installPrefix/lib64/creatools >> $installPrefix/share/creatools_base_library_config.sh
+
+
+ # - remove line 'sh $installPrefix/creatools_install/share/creatools_base_libraries_config.sh' if any
+ sed -i -e '/.*creatools_base_library_config.*/ d' /etc/bashrc
+ # modify /etc/bashrc (we cannot modify .bashrc, since we witched as root)
+ # - add line 'sh $installPrefix/creatools_install/share/creatools_base_libraries_config.sh'
+ echo source $installPrefix/share/creatools_base_library_config.sh >> /etc/bashrc
+else
+ echo
+ echo "..ERROR.."
+ echo "==================================================="
+ echo "REMEMBER !"
+ echo ""
+ echo "YOU NEED TO RUN THIS ONE AS root"
+ echo "==================================================="
+ echo
+ echo
+fi
-# shutdown /s
-# exit /b