#!/bin/bash ####################################################### # # $Id: INSTALL_QTROOT.sh,v 1.62 2008/10/20 22:21:48 fine Exp $ # # This macro tries to install a complete ROOT + QT + QTROOT(cvs) + COIN3D # build environment. # # Original instructions here: http://root.bnl.gov/QtRoot/How2Install4Unix.html # # the **COMPLETE** stuff is installed in the current working directory. # so you can also test different versions if you feel adventurous... # # you will need: # - curl and/or wget to download the Qt and ROOT files. # - svn to check out the Coin3D package # - cvs to check out the QtRoot package # you should read also ALL the various licenses. # # about 100' on a AMD 3800+, ~3 Gb disk space. # ####################################################### # Author: L.Bardelli [ bardelli@fi.infn.it ] ####################################################### # the versions we will use: QT_VERSION=4.4.3 ROOT_VERSION_MAJOR=5.18 ROOT_VERSION_MINOR=00 ROOT_VERSION=$ROOT_VERSION_MAJOR.$ROOT_VERSION_MINOR TAR_EXTENSION=tar.gz MAKE_TOOL=make NCPUS=0 copycommand="ln -s " qtRootDir=qtRoot COIN3DINSTALLDIR=coin3d build_type=debug ####################################################### # stop at the first error. trap "echo ; echo SOME FATAL ERROR DURING EXECUTION, SORRY... ; echo ; exit;" ERR ## http://en.wikipedia.org/wiki/Uname PLATFORM=$(uname -s ) IV_PLATFORM=$(echo $PLATFORM) uname -s | grep CYGWIN && PLATFORM=Win if [ "$PLATFORM" != "Linux" ]; then if [ "$PLATFORM" != "Darwin" ]; then echo "This macro is not tested outside Linux, Windows or MacOSX! Good luck..." sleep 5; fi fi ##================================================================= QT_CONF_OPTS=-fast ##================================================================= if [ "$PLATFORM" == "Linux" ]; then QT_PLATFORM=x11 NCPUS=$(grep -e 'cpu[0-9]' /proc/stat | grep -c .) fi ##================================================================= if [ "$PLATFORM" == "Darwin" ]; then QT_PLATFORM=mac QT_CONF_OPTS=" -no-framework $QT_CONF_OPTS " ROOT_PLATFORM=macosx NCPUS=$(/usr/sbin/system_profiler SPHardwareDataType | grep Cores: | sed s/.*Cores://g ) QMAKESPEC=macx-g++ fi ##================================================================= if [ "$PLATFORM" == "Win" ]; then QT_PLATFORM=win TAR_EXTENSION=zip MAKE_TOOL=nmake copycommand="cp -rf " #-- #-- Make sure the link from cygwin does not hide the link.exe from Visual C++ linkexebase=$(dirname "$(which link)") mtexebase=$(dirname "$(which mt)") cygwinbase=$(dirname $(which cp)) if [ "$linkexebase" == "$cygwinbase" ]; then echo echo FATAL EROOR: echo The cygwin command \"link\" from "$linkexebase" echo HIDES the link.exe from Microsoft. We need the later to proceed. echo echo Please, DELETE !!! \"`which link`\" and restart the script exit 1 fi if [ "$mtexebase" == "$cygwinbase" ]; then echo echo FATAL EROOR: echo The cygwin command \"mt\" from "$mtexebase" echo HIDES the mt.exe from Microsoft. We need the later to proceed. echo echo Please, DELETE !!! \"`which mt`\" and restart the script exit 1 fi fi ##================================================================= if [ "$STAR" != "" ]; then IV_PLATFORM=$(echo $STAR_HOST_SYS) fi if [ "$NCPUS" -le "0" ]; then NCPUS=1; fi if [ "$NCPUS" -ge "4" ]; then NCPUS=4; fi ##================================================================= ## this is the working directory where EVERYTHING will go. MYWD=$(pwd) ##================================================================= ## If QTDIR was pre-installed ask the user whether he /she wants to re-use that installation QTPREINSTALLED=$QTDIR if [ "$QT_PLATFORM" == "win" ]; then QTPREINSTALLED=`cygpath "$QTDIR"` fi if [ -f "$QTPREINSTALLED/include/Qt/qglobal.h" ]; then echo "--------------------$QTDIR ------------------- ls $QTPREINSTALLED echo "------------------------------------------------------ echo "" echo "The existing version of Qt package has been found under QTDIR=$QTDIR directory" echo "" read -p "Do you want to use it? (yes/no) " ANS if [ "$ANS" == "yes" ]; then touch done.qt touch download.qt export QTDIR=$QTPREINSTALLED else unset QTDIR export QTDIR=$MYWD/Qt-$(echo $QT_VERSION) echo "The Qt package will be re-built from the scratch and installed under $QTDIR" fi else export QTDIR=$MYWD/Qt-$(echo $QT_VERSION) fi export ROOTSYS=$MYWD/root export QTROOTSYSDIR=$ROOTSYS ##================================================================= if [ -f done.root ]; then ANS=yes if [ -f done.coin3d ]; then USE_coin=yes echo "It seems to me the QT+ROOT(+COIN3D) had been installed" fi if [ -f done.coin3d ]; then echo "It seems to me the QT+ROOT with no COIN3D had been installed" fi echo "If you want to star over then invoke this script from the empty directory" else echo "=========================================" echo "(L.B.)" echo "This will compile and install QT+ROOT(+COIN3D) in the current directory!!" echo "" echo "Current config: Qt v.$QT_VERSION opensource, ROOT v.$ROOT_VERSION" echo " dir=$MYWD" echo " PLATFORM=$PLATFORM, make will use $NCPUS cpu(s)" echo "" echo "It will require ~1-2 hours and ~3 Gb on disk. Current dir disk space is:" df -h $MYWD echo "=========================================" echo "" read -p "Do you want to proceed? (yes/no) " ANS if [ "$ANS" != "yes" ]; then exit 0; fi read -p "Do you want to install COIN3D also? (yes/no) " USE_coin fi if [ "$USE_coin" == "yes" ]; then ## no ending "/" here!!! export IVROOT=$MYWD/Coin3D/$COIN3DINSTALLDIR/$IV_PLATFORM/coin3d if [ "$QT_PLATFORM" == "win" ]; then export IVROOT=`cygpath -m $MYWD/Coin3D/$COIN3DINSTALLDIR/$IV_PLATFORM/coin3d` fi if [ "$STAR" == "" ]; then export LD_LIBRARY_PATH=$IVROOT/lib:$LD_LIBRARY_PATH fi if [ "$STAR" != "" ]; then export LD_LIBRARY_PATH=$IVROOT/lib:`dropit coin -p $LD_LIBRARY_PATH` fi fi if [ "$STAR" == "" ]; then # remove the possible version of qt and root on PATH and LD_LIBRARY_PATH if [ "$USE_coin" == "yes" ]; then export LD_LIBRARY_PATH=$IVROOT/lib:$LD_LIBRARY_PATH fi export LD_LIBRARY_PATH=$ROOTSYS/lib:$QTDIR/lib:$LD_LIBRARY_PATH export PATH=$ROOTSYS/bin:$QTDIR/bin:$PATH else if [ "$USE_coin" == "yes" ]; then export LD_LIBRARY_PATH=`dropit coin -p $LD_LIBRARY_PATH` export LD_LIBRARY_PATH=$IVROOT/lib:`dropit Coin -p $LD_LIBRARY_PATH` fi export LD_LIBRARY_PATH=`dropit qt -p $LD_LIBRARY_PATH` export LD_LIBRARY_PATH=$ROOTSYS/lib:$QTDIR/lib:`dropit root -p $LD_LIBRARY_PATH` export PATH=`dropit qt $PATH` export PATH=$ROOTSYS/bin:$QTDIR/bin:`dropit root $PATH` fi echo "" echo ">>>>> COMPILATION STARTS. Be patient..." sleep 2 ## last chance for CTRL+C ## wget or curl? I prefer wget GET="wget -c" which wget || GET="curl -C - -O " ## ============= DOWNLOADS ========================================== ## with ls I check than the "true" file exists, and not a useless ## redirect from the server (like maintenance of similar...) QTPKG=qt-$(echo $QT_PLATFORM)-opensource-src-$(echo $QT_VERSION) QTPKGFILE=$(echo $QTPKG).$(echo $TAR_EXTENSION) if [ ! -f download.qt ]; then echo ">>>>> DOWNLOADING ........ Qt $QTPKGFILE. Be patient..." $GET http://wftp.tu-chemnitz.de/pub/Qt/qt/source/$QTPKGFILE # ftp://ftp.trolltech.com/qt/source/$QTPKGFILE ls -lh $QTPKGFILE touch download.qt fi if [ ! -f download.root ]; then echo ">>>>> DOWNLOADING ........ ROOT $ROOT_VERSION. Be patient..." if [ "x$ROOT_VERSION" == "xtrunk" ]; then svn co https://root.cern.ch/svn/root/trunk root touch $MYWD/done.unpackroot else $GET ftp://root.cern.ch/root/root_v$(echo $ROOT_VERSION).source.tar.gz ls -lh root_v$(echo $ROOT_VERSION).source.tar.gz fi touch $MYWD/download.root fi ##OLDTAR $GET http://root.bnl.gov/QtRoot/downloads/qtFullRoot.tar.gz ##OLDTAR ls -lh qtFullRoot.tar.gz if [ ! -f download.qtroot ]; then echo ">>>>> CHECKING OUT ........ QtRoot. Be patient..." cvs -d :pserver:cvsuser:cvsuser@cvs.bnl.gov:/data01/CVS login cvs -d :pserver:cvsuser@cvs.bnl.gov:/data01/CVS co -Pd $qtRootDir root touch $MYWD/download.qtroot fi ## ============= ENVIRONMENT.sh ===================================== rm -rf set_environment.* echo "#!/bin/bash" > set_environment.sh echo export QTDIR=$QTDIR >> set_environment.sh echo export QMAKESPEC=$QMAKESPEC >> set_environment.sh echo export QT_CONF_OPTS=$QT_CONF_OPTS >> set_environment.sh echo export ROOTSYS=$ROOTSYS >> set_environment.sh echo export QTROOTSYSDIR=$QTROOTSYSDIR >> set_environment.sh if [ "$USE_coin" == "yes" ]; then echo export IVROOT=$IVROOT >> set_environment.sh echo export LD_LIBRARY_PATH=\$ROOTSYS/lib:\$IVROOT/lib:\$QTDIR/lib:\$LD_LIBRARY_PATH>> set_environment.sh echo export PATH=\$ROOTSYS/bin:\$QTDIR/bin:\$IVROOT/bin:\$PATH>> set_environment.sh else echo export LD_LIBRARY_PATH=\$ROOTSYS/lib:\$QTDIR/lib:\$LD_LIBRARY_PATH>> set_environment.sh echo export PATH=\$ROOTSYS/bin:\$QTDIR/bin:\$PATH>> set_environment.sh fi chmod -x set_environment.sh ## user must "source" and not exec! ## ============= ENVIRONMENT.csh ===================================== cat set_environment.sh | sed s/=/" "/g | sed s/^export/set/g | sed s_"/bin/bash"_"/bin/csh"_g > set_environment.csh chmod -x set_environment.csh ## ============= ENVIRONMENT.tcsh ===================================== cat set_environment.sh | sed s/=/" "/g | sed s/^export/setenv/g | sed s_"/bin/bash"_"/bin/tcsh"_g > set_environment.tcsh chmod -x set_environment.tcsh if [ "$PLATFORM" == "Win" ]; then ## ============= ENVIRONMENT.cmd ===================================== #cat set_environment.sh | sed s/^export/SET/g | sed s_"#!/bin/bash"_"rem Windows command file"_g | sed s_\$_\%_g > set_environment.cmd vcbinpath="`which vcvars32.bat`" vcbinpath=`cygpath -w $vcbinpath` echo echo Set the VC environment > set_environment.cmd echo CALL \"$vcbinpath\" >> set_environment.cmd echo SET QTDIR=`cygpath -w $QTDIR` >> set_environment.cmd echo SET QMAKESPEC=$QMAKESPEC >> set_environment.cmd echo SET QT_CONF_OPTS=$QT_CONF_OPTS >> set_environment.cmd echo SET ROOTSYS=`cygpath -w $ROOTSYS` >> set_environment.cmd echo SET QTROOTSYSDIR=`cygpath -w $QTROOTSYSDIR`>> set_environment.cmd if [ "$USE_coin" == "yes" ]; then echo SET IVROOT=`cygpath -w $IVROOT` >> set_environment.cmd echo "SET LIB=%ROOTSYS%\\lib;%IVROOT%\\lib;%QTDIR%\\lib;%LIB%" >> set_environment.cmd echo "SET PATH=%QTDIR%\\bin;%ROOTSYS%\\bin;%IVROOT%\\bin;%PATH%" >> set_environment.cmd fi if [ "$USE_coin" != "yes" ]; then echo "SET LIB=%ROOTSYS%\\lib;%QTDIR%\\lib;%LIB%" >> set_environment.cmd echo "SET PATH=%ROOTSYS%\\bin;%IVROOT%\\bin;%PATH%" >> set_environment.cmd fi chmod -x set_environment.cmd fi ## ============= for MAC-OSX: environment.plist ====================== echo " DYLD_LIBRARY_PATH $ROOTSYS/lib QTROOTSYSDIR $ROOTSYS ROOTSYS $ROOTSYS " > environment.plist ##===================== QT ========================== cd $MYWD if [ ! -f done.qt ]; then rm -rf $QTDIR if [ "$QT_PLATFORM" == "win" ]; then unzip -q $QTPKGFILE ls -lh $QTPKG mv $QTPKG $(echo $QTDIR) fi if [ "$QT_PLATFORM" != "win" ]; then tar xzf $QTPKGFILE ln -s $QTPKG $(echo $QTDIR) fi cd $(echo $QTDIR) if [ "$QT_PLATFORM" == "win" ]; then echo yes | ./configure $QT_CONF_OPTS $MAKE_TOOL fi if [ "$QT_PLATFORM" != "win" ]; then echo yes | ./configure --prefix=$QTDIR $QT_CONF_OPTS $MAKE_TOOL -j $NCPUS fi echo We need no INSTALL to $QTDIR pwd $MAKE_TOOL install cd $MYWD touch done.qt fi ##=====================coin3d============================= if [ "$USE_coin" == "yes" ]; then cd $MYWD if [ ! -f done.coin3d ]; then rm -f done.qtroot if [ ! -d Coin3D/srcdir ]; then mkdir -p Coin3D/srcdir fi cd Coin3D/srcdir if [ ! -f $MYWD/download.coin ]; then ## server may have outdated certificate. (t)emporarily accept it. echo "t t t t t t t t t t t t t " | ../../qtRoot/qtgl/qtcoin/InstallCoin3D/download.sh touch $MYWD/download.coin fi rm -rf $IVROOT ../../qtRoot/qtgl/qtcoin/InstallCoin3D/installCoin3D.sh $COIN3DINSTALLDIR $build_type cd $MYWD touch done.coin3d fi fi ##===================== ROOT ========================== cd $MYWD if [ ! -f done.unpackroot ]; then if [ -f done.root ]; then rm done.root fi rm -rf root tar xzf root_v$(echo $ROOT_VERSION).source.tar.gz cd root ## note1: DON'T use --prefix! ## note2: mac seems to need "./configure macosx" to work properly... if [ "$QT_PLATFORM" == "win" ]; then # --------- On Win32 we have to patch the core ROOT first -------- # # -- root # $copycommand ../$qtRootDir/MyModules.mk . $copycommand ../$qtRootDir/MyMakefile.depend . $copycommand ../$qtRootDir/root.diff . $copycommand ../$qtRootDir/plugins etc/ # # -- fix configure # if [ -f root.diff/configure.$ROOT_VERSION_MAJOR ]; then echo "-- fix configure" mv configure configure.root $copycommand root.diff/configure.$ROOT_VERSION_MAJOR configure fi # # -- add qt to root # rootdir=qt if [ -d graf2d ]; then rootdir=graf2d/$rootdir fi mv $rootdir $rootdir.root $copycommand ../$qtRootDir/qt $rootdir/ rootdir=qtroot if [ -d gui/gui ]; then rootdir=gui/$rootdir fi mv $rootdir $rootdir.root $copycommand ../$qtRootDir/qtroot $rootdir/ rootdir=. $copycommand ../$qtRootDir/qtgui $rootdir/ $copycommand ../$qtRootDir/qt4ged $rootdir/ $copycommand ../$qtRootDir/qtged $rootdir/ $copycommand ../$qtRootDir/qtthread $rootdir/ $copycommand ../$qtRootDir/qtgl $rootdir/ $copycommand ../$qtRootDir/qtimage $rootdir/ # # -- base # echo " ---- Adjust build/win" $copycommand ../$qtRootDir/root.diff/build/win/compiledata.sh build/win/ # # -- base # echo " ---- Adjust base/src" rootdir=base if [ -d core ]; then rootdir=core/$rootdir fi $copycommand ../$qtRootDir/root.diff/base/inc/TPadEditorHelper.h $rootdir/inc $copycommand ../$qtRootDir/root.diff/base/src/TPadEditorHelper.cxx $rootdir/src $copycommand ../$qtRootDir/root.diff/base/src/TApplication.cxx $rootdir/src # # -- gui # rootdir=gui if [ -d gui/gui ]; then rootdir=gui/$rootdir fi $copycommand ../$qtRootDir/root.diff/gui/src/TGClient.cxx $rootdir/src # # -- clib # echo " ---- Adjust clib/src" rootdir=clib if [ -d core ]; then rootdir=core/$rootdir fi $copycommand ../$qtRootDir/root.diff/clib/src/Getline.c $rootdir/src # # -- gpad -- fix the ROOT 5.14 bug (see TPad.diff for the futher details) # rootdir=gpad if [ -d graf2d ]; then rootdir=graf2d/$rootdir fi #-- $copycommand ../$qtRootDir/root.diff/gpad/src/TPad.cxx $rootdir/src # # -- thread -- fix the Win32 CPP flag # if [ "$ROOT_VERSION" == "5.18.00" ]; then rootdir=thread if [ -d core ]; then rootdir=core/$rootdir fi $copycommand ../$qtRootDir/root.diff/thread1/Module.mk $rootdir/ $copycommand ../$qtRootDir/root.diff/thread1/src/TWin32Mutex.cxx $rootdir/src fi # -- test echo " ---- Install extra tests" cd test $copycommand ../../$qtRootDir/test/qt . $copycommand ../../$qtRootDir/test/qtRootShower . cd .. # -- config if [ -f root.diff/config/rootrc.in.$ROOT_VERSION_MAJOR ]; then echo " ---- Install config" cd config mv rootrc.in rootrc.in.hold $copycommand ../root.diff/config/rootrc.in.$ROOT_VERSION_MAJOR rootrc.in cd .. fi # # -- winnt # echo " ---- Install winnt" rootdir=winnt if [ -d core ]; then rootdir=core/$rootdir fi $copycommand ../$qtRootDir/root.diff/winnt/src/TWinNTSystem.cxx $rootdir/src # # -- Tutorials # echo " ---- Install tutorials " cd tutorials $copycommand ../../$qtRootDir/root.diff/tutorials/rootlogon.C . cd .. echo " ---- Install QT examples " $copycommand ../$qtRootDir/qtExamples . # # -- Build QGLViewer for Windows # export QTDIR=`cygpath -w $QTDIR` mkdir bin mkdir lib cd qtgl/qglviewer/QGLViewer export viewerPrefix=`cygpath -w $ROOTSYS` cmd /C qmake CONFIG+=$build_type PREFIX=$viewerPrefix cmd /C nmake cmd /C nmake install # # -- Install QGLViewer for Win32 # cd $build_type cp QGLViewer*.dll* $ROOTSYS/bin cp *.manifest $ROOTSYS/bin cp QGLViewer*.lib $ROOTSYS/lib/QGLViewer.lib cp QGLViewer*.prl $ROOTSYS/lib/QGLViewer.prl cd ../../../../ # # -- There is no separate step to buil QtRoot for Windows yet # touch $MYWD/done.qtroot fi touch $MYWD/done.unpackroot fi # # -- Configure and build ROOT # cd $MYWD if [ ! -f done.root ]; then cd root echo "Replacing \"native\" type of GUI plugin with \"qt\" and \"qtgui\"" mv config/rootrc.in config/rootrc.in.native cat config/rootrc.in.native | sed s/^Gui\.*Backend:\.*native\$/Gui\.Backend\:\ \ \ qt/ | sed s/^Gui\.*Factory:\.*native\$/Gui\.Factory:\ \ \ \ \ qtgui/ >config/rootrc.in if [ "$QT_PLATFORM" = "win" ]; then ./configure --build=$build_type $ROOT_PLATFORM --enable-qt --enable-table make fi if [ "$QT_PLATFORM" != "win" ]; then ./configure --build=$build_type $ROOT_PLATFORM --enable-table make -j $NCPUS echo no prefix - no make install make install fi touch $MYWD/done.root fi ##====================== QT-ROOT (2/2) ========================== cd $MYWD if [ ! -f $MYWD/done.qtroot ]; then QGLVIEWER_DIR=qtRoot/qtgl/qglviewer/QGLViewer #-- Build QGLViewer first cd $QGLVIEWER_DIR qmake CONFIG+=$build_type PREFIX=$QTROOTSYSDIR make make install # -- Build the QtRoot cd $MYWD cd qtRoot qmake CONFIG+=$build_type make -j $NCPUS make install cd $MYWD # ln -f -s $MYWD/qtRoot/qtgl/qglviewer/QGLViewer/libQGLViewer* $ROOTSYS/lib/ touch $MYWD/done.qtroot fi cd $MYWD # ROOTRC=root/etc/system.rootrc # --- ROOTRC=.rootrc # --- if [ -f $ROOTRC ]; then # --- rm $ROOTRC # --- fi # --- echo "To Activate Qt layer you need the custom rootrc file to be present either in yiour HOME or current directory" # --- echo "" > $ROOTRC # --- echo "## added by INSTALL_QTROOT.sh ##" >> $ROOTRC # --- echo "" >> $ROOTRC # --- cat qtRoot/qtExamples/QtGBrowser/rootrcqtgui >> $ROOTRC ##===================== example test ====================== cd $MYWD if [ "$QT_PLATFORM" != "win" ]; then cd qtRoot/qtExamples/HelloCanvas qmake make fi ##====================== the end ========================== cd $MYWD cp -rf set_environment.* root/bin/ echo "" echo "====================== DONE! =========================" echo "" echo "The local $build_type ROOT copy is Qt-enabled (patched rootrc)" echo "" if [ "USE_coin" == "yes" ]; then echo "you can use qtRoot/qtExamples/macros/rootgeom_coin.C to test COIN3D" echo "" fi echo "environment variables saved into $MYWD/set_environment.sh" echo " and $ROOTSYS/bin/set_environment.sh" echo " use it with: source $MYWD/set_environment.sh" echo " or append it to your .bash_profile" echo "" echo "if your shell is csh use $MYWD/set_environment.csh" echo "" if [ "$PLATFORM" == "Win" ]; then echo "" echo "if your shell is Windows Command Prompt use `cygpath -w $MYWD/set_environment.cmd`" echo " or `cygpath -w $ROOTSYS/bin/set_environment.cmd`" echo "" fi if [ "$PLATFORM" == "Darwin" ]; then ## mac-specific warnings echo " MAC-OSX: you should now create a folder in your home named .MacOSX" echo " and copy there the file environment.plist" echo "" fi echo "====================== BYE BYE! ======================" echo ""