################################################################################
# Environment setup:
################################################################################
yum install flex-devel
yum install bison-devel
export CARTABUILDHOME=/export/home/cbt-el6-3/carta-work/cartabuild/

# Create directories:
cd /export/home/cbt-el6-3
sudo mkdir carta-work
sudo chown vsuorant.cvstaff carta-work
mkdir dependencies
cd dependencies

# Build gcc 4.8.2
curl -O -L http://mirrors-usa.go-parts.com/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.gz
tar xvfz gcc-4.8.2.tar.gz
mv gcc-4.8.2 gcc-4.8.2-src
cd gcc-4.8.2-src
./contrib/download_prerequisites
mkdir objdir
cd objdir/
$PWD/../gcc-4.8.2-src/configure --prefix=`pwd`/../gcc-4.8.2
make
make install
cd ..

export PATH=$CARTABUILDHOME/../dependencies/gcc-4.8.2/bin:$PATH

# Install libffi required by glib 2.32.4
sudo yum install libffi-devel

# Build glib 2.32.4

curl -O -L http://ftp.gnome.org/pub/gnome/sources/glib/2.32/glib-2.32.4.tar.xz
xz -d glib-2.32.4.tar.xz
tar xvf glib-2.32.4.tar
mv glib-2.32.4 glib-2.32.4-src
cd glib-2.32.4-src/
./configure --prefix=`pwd`/../glib-2.32.4
make
make install
cd ..
cd glib-2.32.4/lib/pkgconfig
export PKG_CONFIG_PATH=`pwd`
cd ../../../

# Build gstreamer 0.10.36
curl -O -L https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-0.10.36.tar.xz
xz -d gstreamer-0.10.36.tar.xz && tar xvf gstreamer-0.10.36.tar
mv gstreamer-0.10.36 gstreamer-0.10.36-src
cd gstreamer-0.10.36-src
./configure --prefix=`pwd`/../gstreamer-0.10.36
make
make install
cd ..
cd gstreamer-0.10.36/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:`pwd`
cd ../../../

# Build gstplugins 0.10.36
curl -O -L https://gstreamer.freedesktop.org/src/gst-plugins-base/gst-plugins-base-0.10.36.tar.gz
tar xvfz gst-plugins-base-0.10.36.tar.gz
mv gst-plugins-base-0.10.36 gst-plugins-base-0.10.36-src
cd gst-plugins-base-0.10.36-src/
./configure --prefix=`pwd`/../gst-plugins-base-0.10.36



################################################################################
# Install thirdparty packages
################################################################################

Note: Compile at least wcslib with Gcc 4.8.2 otherwise CMake gets confused and wants to recompile pgsbox

################################################################################
# Configuring workspace
################################################################################

# Create a working directory
cd /export/home/cbt-el6-3/
mkdir carta-work
cd carta-work

# Download Qt
curl -O -L http://download.qt.io/official_releases/qt/5.3/5.3.2/qt-opensource-linux-x64-5.3.2.run

# Run the installer and install into /export/home/cbt-el6-3/carta-work/Qt5.3.2/
# Include new Qt in PATH
export PATH=/export/home/cbt-el6-3/carta-work/Qt5.3.2/5.3/gcc_64/bin/:$PATH

# Create directories and download source
mkdir cartabuild
cd cartabuild
mkdir -p CARTAvis-externals/ThirdParty
cd CARTAvis-externals/ThirdParty

################################################################
# Download and configure Qwt
################################################################
curl -O -L http://downloads.sourceforge.net/project/qwt/qwt/6.1.2/qwt-6.1.2.tar.bz2
tar xvfj qwt-6.1.2.tar.bz2 && mv qwt-6.1.2 qwt-6.1.2-src
cd  qwt-6.1.2-src

# Change QWT_INSTALL_PREFIX in qwtconfig.pri to point to
$CARTABUILDHOME/CARTAvis-externals/ThirdParty/qwt-6.1.2

qmake qwt.pro
make
make install
cd ..
# On Linux, the qwt can probably be directly symlinked to the appropriate qwt directory
mkdir qwt
cd qwt
ln -s $CARTABUILDHOME/CARTAvis-externals/ThirdParty/qwt-6.1.2/include include
ln -s $CARTABUILDHOME/CARTAvis-externals/ThirdParty/qwt-6.1.2/lib lib
cd ..

###############################
# Download and install qooxdoo
###############################

Copy
https://sourceforge.net/projects/qooxdoo/files/qooxdoo-current/3.5/qooxdoo-3.5-sdk.zip/download
to:
$CARTABUILDHOME/CARTAvis-externals/ThirdParty/

unzip qooxdoo-3.5-sdk.zip

################################
# Download and install rapidjson
################################

curl -O -L https://github.com/miloyip/rapidjson/archive/v1.0.2.tar.gz
tar xvfz v1.0.2.tar.gz
ln -s rapidjson-1.0.2 rapidjson

##############################
# Download and install wcslib
##############################
curl -O -L ftp://ftp.atnf.csiro.au/pub/software/wcslib/wcslib.tar.bz2
cp wcslib.tar.bz2 $CARTABUILDHOME/CARTAvis-externals/ThirdParty/
cd $CARTABUILDHOME/CARTAvis-externals/ThirdParty/
tar xvfj wcslib.tar.bz2 && mv wcslib-5.15/ wcslib-5.15-src
cd wcslib-5.15-src
./configure --prefix=`pwd`/../wcslib/
make install

##############################
# Download and install cfitsio
##############################
cd $CARTABUILDHOME/CARTAvis-externals/ThirdParty/
curl -O -L https://svn.cv.nrao.edu/casa/devel/cfitsio3380.tar.gz
tar xvfz cfitsio3380.tar.gz && mv cfitsio cfitsio-src
cd cfitsio-src
./configure --prefix=`pwd`/../cfitsio/
make 
make shared
make install
cd ..
ln -s cfitsio cfitsio-shared

##############################
# Download and install ast
##############################
cd $CARTABUILDHOME/CARTAvis-externals/ThirdParty/
curl -O -L https://svn.cv.nrao.edu/casa/devel/carta/ast-8.0.2.tar.gz
tar xvfz ast-8.0.2.tar.gz && mv ast-8.0.2 ast-8.0.2-src
cd ast-8.0.2-src
./configure --prefix=`pwd`/../ast/
make install
cd ..

##############################
# Download and install gsl
##############################
cd $CARTABUILDHOME/CARTAvis-externals/ThirdParty/
curl -O -L http://ftp.gnu.org/gnu/gsl/gsl-2.1.tar.gz
tar xvfz gsl-2.1.tar.gz && mv gsl-2.1 gsl-2.1-src
cd gsl-2.1-src
./configure --prefix=`pwd`/../gsl/
make install
cd ..

################################
# Build and copy casacore and code
################################
Note: You can't use QT5 for this
Link or copy the following parts
export CARTA_WORKDIR=/export/home/cbt-el6-3/carta-work

export LD_LIBRARY_PATH=/export/home/cbt-el6-3/carta-work/cartabuild/build/cpp/plugins/ImageStatistics/:/export/home/cbt-el6-3/carta-work/casa/trunk/linux/lib/://export/home/cbt-el6-3/carta-work/dependencies/glib-2.32.4/lib:/export/home/cbt-el6-3/carta-work/dependencies/gstreamer-0.10.36/lib:/export/home/cbt-el6-3/carta-work/dependencies/gst-plugins-base-0.10.36/lib::/export/home/cbt-el6-3/carta-work/cartabuild/CARTAvis-externals/ThirdParty/cfitsio/lib/:/export/home/cbt-el6-3/carta-work/dependencies/gcc-4.8.2/lib64/:export/home/cbt-el6-3/carta-work/casa/trunk/linux/lib:/export/home/cbt-el6-3/carta-work/casa/trunk/linux/lib/::/usr/lib64/casa/01/lib/

mkdir $CARTABUILDHOME/../casa
cd $CARTABUILDHOME/../casa
svn co https://svn.cv.nrao.edu/svn/casa/trunk
cd trunk/casacore
mkdir build && cd build

export CARTA_WORKDIR=/export/home/cbt-el6-3/carta-work

cmake  -DUseCrashReporter=0 -DBoost_NO_BOOST_CMAKE=1 -DCASA_BUILD=1 -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=../../linux -DBUILD_PYTHON=1 -DPYTHON_INCLUDE_DIR=/usr/lib64/casa/01/include/python2.7 -DPYTHON_LIBRARY=/usr/lib64/casa/01/lib/libpython2.7.so -DBOOST_ROOT=/usr/lib64/casa/01 -DCMAKE_BUILD_TYPE=Release -DCXX11=1 -DCMAKE_CXX_COMPILER=$CARTA_WORKDIR/dependencies/gcc-4.8.2/bin/g++ -DCMAKE_C_COMPILER=$CARTA_WORKDIR/dependencies/gcc-4.8.2/bin/gcc -DCMAKE_Fortran_COMPILER=$CARTA_WORKDIR/dependencies/gcc-4.8.2/bin/gfortran -DCFITSIO_LIBRARY=$CARTA_WORKDIR/cartabuild/CARTAvis-externals/ThirdParty/cfitsio/lib/libcfitsio.so -DCFITSIO_INCLUDE_DIR=$CARTA_WORKDIR/cartabuild/CARTAvis-externals/ThirdParty/cfitsio/include/ -DWCSLIB_LIBRARY=$CARTA_WORKDIR/cartabuild/CARTAvis-externals/ThirdParty/wcslib/lib/libwcs.so -DWCSLIB_INCLUDE_DIR=$CARTA_WORKDIR/cartabuild/CARTAvis-externals/ThirdParty/wcslib/include/ ..
make
make install

cd ../../code
mkdir build && cd build
cmake  -DUseCrashReporter=0 -DBoost_NO_BOOST_CMAKE=1 '-DEXTRA_C_FLAGS=-DPG_PPU -I/usr/include/wcslib' -Darch=linux -DBoost_NO_BOOST_CMAKE=1 -DCMAKE_BUILD_TYPE=Release -DCXX11=1 -DCMAKE_CXX_COMPILER=$CARTA_WORKDIR/dependencies/gcc-4.8.2/bin//g++ -DCMAKE_C_COMPILER=$CARTA_WORKDIR/dependencies/gcc-4.8.2/bin/gcc -DCMAKE_Fortran_COMPILER=$CARTA_WORKDIR/dependencies/gcc-4.8.2/bin//gfortran -DCFITSIO_ROOT_DIR=$CARTA_WORKDIR/cartabuild/CARTAvis-externals/ThirdParty/cfitsio/ -DCFITSIO_INCLUDE_DIR=$CARTA_WORKDIR/cartabuild/CARTAvis-externals/ThirdParty/cfitsio/include/ -DWCSLIB_ROOT_DIR=$CARTA_WORKDIR/cartabuild/CARTAvis-externals/ThirdParty/wcslib/ ..

make

cd $CARTABUILDHOME/CARTAvis-externals/ThirdParty/
mkdir imageanalysis
cd imageanalysis
ln -s $CARTABUILDHOME/../casa/trunk/linux/include/casacode/ include
ln -s $CARTABUILDHOME/../casa/trunk/linux/lib lib
cd ..
mkdir casacore
cd casacore
ln -s $CARTABUILDHOME/../casa/trunk/linux/include/casacore/ include
ln -s $CARTABUILDHOME/../casa/trunk/linux/lib lib

################################################################################
# Build Carta
################################################################################

# Set the LD_LIBRARY_PATH for build dependencies
export CARTA_WORKDIR=/export/home/cbt-el6-3/carta-work
export LD_LIBRARY_PATH=$CARTA_WORKDIR/cartabuild/build/cpp/plugins/ImageStatistics/:$CARTA_WORKDIR/casa/trunk/linux/lib/:/$CARTA_WORKDIR/dependencies/glib-2.32.4/lib:$CARTA_WORKDIR/dependencies/gstreamer-0.10.36/lib:$CARTA_WORKDIR/dependencies/gst-plugins-base-0.10.36/lib::$CARTA_WORKDIR/cartabuild/CARTAvis-externals/ThirdParty/cfitsio/lib/:$CARTA_WORKDIR/dependencies/gcc-4.8.2/lib64/:export/home/cbt-el6-3/carta-work/casa/trunk/linux/lib:$CARTA_WORKDIR/casa/trunk/linux/lib/::/usr/lib64/casa/01/lib/

# Create build directory
export CARTABUILDHOME=/export/home/cbt-el6-3/carta-work/cartabuild/
cd $CARTABUILDHOME
git clone https://github.com/Astroua/CARTAvis  # Move this after the configuration

# Make sure that carta/cpp/common_config.pri points to the following directories
CASACOREDIR=../../ThirdParty/casacore
#ASTLIBDIR = ../../ThirdParty/ast
WCSLIBDIR=../../ThirdParty/wcslib
CFITSIODIR=../../ThirdParty/cfitsio
IMAGEANALYSISDIR=../../ThirdParty/imageanalysis


# Run qooxdoo code generation
cd $CARTABUILDHOME/CARTAvis/carta/html5/common/skel
./generate.py source > /dev/null
./generate.py  > /dev/null


# You may also need to modify CARTAvis/carta/cpp/common.pri to not try to use gcc4.8

mkdir build
cd build

# Use the correct qmake and gcc version
export PATH=/export/home/cbt-el6-3/carta-work/Qt5.3.2/5.3/gcc_64/bin/:/export/home/cbt-el6-3/carta-work/dependencies/gcc-4.8.2/bin:$PATH

# Run qmake and build
qmake NOSERVER=1 CARTA_BUILD_TYPE=dev $CARTABUILDHOME/CARTAvis/carta -r
make -j 2

svn co https://svn.cv.nrao.edu/svn/casa/development_tools/packaging
cd packaging/scripts/

export cartaversion='6.0.0'
./make-app-carta  -ni -v version=$cartaversion type=DEV out=/tmp ws=$CARTABUILDHOME/build/cpp/desktop

# For some reason this guy didn't get copied by make-app-carta. Need to investigate.
cp /export/home/cbt-el6-3/carta-work/dependencies/gcc-4.8.2/lib64/libstdc++.so.6 /tmp/carta-DEV-$cartaversion/lib/

# Fix Qt
cp -r /export/home/cbt-el6-3/carta-work/Qt5.3.2/5.3/gcc_64/plugins/platforms /tmp/carta-DEV-$cartaversion//bin/
cp /export/home/cbt-el6-3/carta-work/Qt5.3.2/5.3/gcc_64/lib/libQt5DBus.so.5 /tmp/carta-DEV-$cartaversion//lib/

# Gather the html and copy qooxdoo
cp -r /export/home/cbt-el6-3/carta-work/cartabuild/CARTAvis/carta/html5 /tmp/carta-DEV-$cartaversion//etc
rm /tmp/carta-DEV-$cartaversion/etc/html5/common/qooxdoo-3.5-sdk
cp -r /export/home/cbt-el6-3/carta-work/cartabuild/CARTAvis/Externals/ThirdParty/qooxdoo-3.5-sdk /tmp/carta-DEV-$cartaversion//etc/html5/common/qooxdoo-3.5-sdk

# Fix ImageStatistics RUNPATH (dependency to CasaImageLoader)

chrpath -c -r '$ORIGIN/../../lib/:$ORIGIN/../../plugins/CasaImageLoader/' /tmp/carta-DEV-$cartaversion//plugins/ImageStatistics/libplugin.so

#################################
# Copy Python 2.7 over
#################################
cp -r /usr/lib64/casa/01/lib/python2.7 /tmp/carta-DEV-$cartaversion/lib/

#################################
# Add sample images
#################################

curl -O -L https://svn.cv.nrao.edu/casa/devel/carta/cartaimages.tar.gz && tar xvfz cartaimages.tar.gz -C /tmp/carta-DEV-$cartaversion/etc && rm cartaimages.tar.gz


################################################################################
# Run
################################################################################

# LD_LIBRARY_PATH
#export LD_LIBRARY_PATH=/export/home/cbt-el6-3/carta-work/cartabuild/build/cpp/plugins/ImageStatistics/:/export/home/cbt-el6-3/carta-work/casa/trunk/linux/lib/://export/home/cbt-el6-3/carta-work/dependencies/glib-2.32.4/lib:/export/home/cbt-el6-3/carta-work/dependencies/gstreamer-0.10.36/lib:/export/home/cbt-el6-3/carta-work/dependencies/gst-plugins-base-0.10.36/lib::/export/home/cbt-el6-3/carta-work/cartabuild/CARTAvis-externals/ThirdParty/cfitsio/lib/:/export/home/cbt-el6-3/carta-work/dependencies/gcc-4.8.2/lib64/:export/home/cbt-el6-3/carta-work/casa/trunk/linux/lib/export/home/cbt-el6-3/carta-work/casa/trunk/linux/lib/::/usr/lib64/casa/01/lib/

# Run in workspace
# ulimit -n 2000; ./cpp/desktop/desktop --html /export/home/cbt-el6-3/carta-work/cartabuild/CARTAvis/carta/html5/desktop/desktopIndex.html --scriptPort 9999


################################################################################
# Remove Casa versions of cfitsio and wcslib to avoid confusion with the packaging
################################################################################
=======================================================================================================================================================================================================================================
 Package                                                           Arch                                              Version                                                    Repository                                        Size
=======================================================================================================================================================================================================================================
Removing:
 cfitsio                                                           x86_64                                            3.350-01.el6                                               @casa                                            4.1 M
Removing for dependencies:
 casa-prerelease-bin                                               x86_64                                            4.6.0-19.el6                                               @casa                                             60 M
 casa-prerelease-shared                                            x86_64                                            4.6.0-19.el6                                               @casa                                            140 M
 casa-release-bin                                                  x86_64                                            4.6.0-19.el6                                               @casa                                             60 M
 casa-release-shared                                               x86_64                                            4.6.0-19.el6                                               @casa                                            140 M
 casa-stable-bin                                                   x86_64                                            4.7.59-2.el6                                               @casa                                             60 M
 casa-stable-shared                                                x86_64                                            4.7.59-2.el6                                               @casa                                            143 M
 casa-test                                                         x86_64                                            4.7.59-2.el6                                               @casa                                             28 k
 casa-test-bin                                                     x86_64                                            4.7.59-2.el6                                               @casa                                             60 M
 casa-test-shared                                                  x86_64                                            4.7.59-2.el6                                               @casa                                            143 M
 cfitsio-devel                                                     x86_64                                            3.350-01.el6                                               @casa                                            189 k
 wcslib-devel                                                      x86_64                                            4.7-03.el6                                                 @casa                                            6.8 M

Transaction Summary
=======================================================================================================================================================================================================================================
Remove       12 Package(s)

Installed size: 818 M
Is this ok [y/N]: y

Removed:
  cfitsio.x86_64 0:3.350-01.el6

Dependency Removed:
  casa-prerelease-bin.x86_64 0:4.6.0-19.el6     casa-prerelease-shared.x86_64 0:4.6.0-19.el6     casa-release-bin.x86_64 0:4.6.0-19.el6     casa-release-shared.x86_64 0:4.6.0-19.el6     casa-stable-bin.x86_64 0:4.7.59-2.el6
  casa-stable-shared.x86_64 0:4.7.59-2.el6      casa-test.x86_64 0:4.7.59-2.el6                  casa-test-bin.x86_64 0:4.7.59-2.el6        casa-test-shared.x86_64 0:4.7.59-2.el6        cfitsio-devel.x86_64 0:3.350-01.el6
  wcslib-devel.x86_64 0:4.7-03.el6

-- VilleSuoranta - 2016-05-27
Topic revision: r11 - 2016-11-08, VilleSuoranta
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding NRAO Public Wiki? Send feedback