Environment Setup

###############################
# Prerequisites
###############################
Basic Casa development environment is installed as described here: https://safe.nrao.edu/wiki/bin/view/Software/CASA/CasaEnvSetupOSX1011?rev=15

###############################
# Download and install Qt
###############################
http://download.qt.io/official_releases/qt/5.3/5.3.2/qt-opensource-mac-x64-clang-5.3.2.dmg
https://sourceforge.net/projects/qwt/files/qwt/6.1.2/qwt-6.1.2.tar.bz2/download

# Add Qt5.3 to your path (needed for qmake) f.e.
export PATH=/Users/$USER/Qt5.3.2/5.3/clang_64/bin/:$PATH

# Fix qdevice.pri
# Open 
~/Qt5.3.2/5.3/clang_64/mkspecs/qdevice.pri
# with your favorite text editor and remove "10.8" from this line:
!host_build:QMAKE_MAC_SDK = macosx10.8

mkdir cartabuild
cd cartabuild
export CARTABUILDHOME=`pwd`
git clone https://github.com/Astroua/CARTAvis
mkdir -p CARTAvis-externals/ThirdParty
cd CARTAvis-externals/ThirdParty

############################
# Download and install qwt
############################

# Download the following link under CARTAvis-externals/ThirdParty
http://downloads.sourceforge.net/project/qwt/qwt/6.1.2/qwt-6.1.2.tar.bz2?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fqwt%2Ffiles%2Fqwt%2F6.1.2%2F&ts=1461767939&use_mirror=pilotfiber
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 ..
mkdir qwt
cd qwt
ln -s $CARTABUILDHOME/CARTAvis-externals/ThirdParty/qwt-6.1.2/lib/qwt.framework/Headers/ 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

################################
# Build and copy casacore and code
################################
Note: You can't use QT5 for this
Link or copy the following parts

Basic Casa build instructions can be found here: https://safe.nrao.edu/wiki/bin/view/Software/CASA/CasaBuildInstructions
Important: Add -DUseCrashReporter=0  to the cmake commands in the above link

cd $CARTABUILDHOME/CARTAvis-externals/ThirdParty/
mkdir imageanalysis
cd imageanalysis
ln -s /Users/$USER/tmp/trunk/darwin/include/casacode/ include
ln -s /Users/$USER/tmp/trunk/darwin/lib lib
cd ..
mkdir casacore
cd casacore
ln -s /Users/$USER/tmp/trunk/darwin/include include
ln -s /Users/$USER/tmp/trunk/darwin/lib lib

##############################
# Download and install wcslib
##############################
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 http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio3380.tar.gz
tar xvfz cfitsio3390.tar.gz && mv cfitsio cfitsio-src
cd cfitsio-src
./configure --prefix=`pwd`/../cfitsio/
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
FC=gfortran-mp-4.9  F77=gfortran-mp-4.9  LC_ALL=C CC=gcc CXX=g++ ./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


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

export PATH=/Users/$USER/Qt5.3.2/5.3/clang_64/bin/:$PATH

cd $CARTABUILDHOME/CARTAvis/carta/html5/common/skel
./generate.py source > /dev/null
./generate.py  > /dev/null

mkdir  $CARTABUILDHOME/build
cd  $CARTABUILDHOME/build

qmake NOSERVER=1 CARTA_BUILD_TYPE=dev $CARTABUILDHOME/CARTAvis/carta -r && make -j 4


################################################################################
# Fix paths
################################################################################

mkdir $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks
cd $CARTABUILDHOME/build

cp ./cpp/core/libcore.1.dylib $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks/
cp ./cpp/CartaLib/libCartaLib.1.dylib $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks/

install_name_tool -change qwt.framework/Versions/6/qwt $CARTABUILDHOME/CARTAvis-externals/ThirdParty/qwt-6.1.2/lib/qwt.framework/Versions/6/qwt $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/MacOS/desktop
install_name_tool -change qwt.framework/Versions/6/qwt $CARTABUILDHOME/CARTAvis-externals/ThirdParty/qwt-6.1.2/lib/qwt.framework/Versions/6/qwt $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks/libcore.1.dylib
install_name_tool -change libplugin.dylib $CARTABUILDHOME/build/cpp/plugins/CasaImageLoader/libplugin.dylib $CARTABUILDHOME/build/cpp/plugins/ImageStatistics/libplugin.dylib
install_name_tool -change libcore.1.dylib  $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks/libcore.1.dylib $CARTABUILDHOME/build/cpp/plugins/ImageStatistics/libplugin.dylib

install_name_tool -change libCartaLib.1.dylib  $CARTABUILDHOME//build/cpp/desktop/desktop.app/Contents/Frameworks/libCartaLib.1.dylib $CARTABUILDHOME/build/cpp/plugins/ImageStatistics/libplugin.dylib
install_name_tool -change libcore.1.dylib  $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks/libcore.1.dylib $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/MacOS/desktop
install_name_tool -change libCartaLib.1.dylib  $CARTABUILDHOME//build/cpp/desktop/desktop.app/Contents/Frameworks/libCartaLib.1.dylib $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/MacOS/desktop
install_name_tool -change libCartaLib.1.dylib  $CARTABUILDHOME//build/cpp/desktop/desktop.app/Contents/Frameworks/libCartaLib.1.dylib $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks/libcore.1.dylib

for f in `find . -name libplugin.dylib`; do install_name_tool -change libcore.1.dylib  $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks/libcore.1.dylib $f; done
for f in `find . -name libplugin.dylib`; do install_name_tool -change libCartaLib.1.dylib  $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks/libCartaLib.1.dylib $f; done
for f in `find . -name "*.dylib"`; do install_name_tool -change libwcs.5.15.dylib  $CARTABUILDHOME/CARTAvis-externals/ThirdParty/wcslib/lib/libwcs.5.15.dylib $f; echo $f; done
for f in `find . -name libplugin.dylib`; do install_name_tool -change libCartaLib.1.dylib  $CARTABUILDHOME/build/cpp/desktop/desktop.app/Contents/Frameworks/libCartaLib.1.dylib $f; done

#####################
# Create bundle
#####################

svn co https://svn.cv.nrao.edu/svn/casa/development_tools/packaging
cd packaging/scripts
rm -rf /tmp/Carta.app && ./make-app-carta -ni -v out=/tmp  ws=$CARTABUILDHOME/build/cpp/desktop/desktop.app

#####################################################
# Fix libqcocoa.dylib dependency and loader paths
#####################################################

mkdir /tmp/Carta.app/Contents/MacOS/platforms/
cp /Users/$USER/Qt5.3.2//5.3/clang_64/plugins/platforms/libqcocoa.dylib /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
install_name_tool -change /Users/$USER/Qt5.3.2/5.3/clang_64/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport @loader_path/../../Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport  /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
install_name_tool -change /Users/$USER/Qt5.3.2/5.3/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets @loader_path/../../Frameworks/QtWidgets.framework/Versions/5/QtWidgets /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
install_name_tool -change /Users/$USER/Qt5.3.2/5.3/clang_64/lib/QtGui.framework/Versions/5/QtGui @loader_path/../../Frameworks/QtGui.framework/Versions/5/QtGui /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
install_name_tool -change /Users/$USER/Qt5.3.2/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore @loader_path/../../Frameworks/QtCore.framework/Versions/5/QtCore  /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
otool -L /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib

########################
# Fix Resources
########################

# Create local config.json file
mkdir /tmp/Carta.app/Contents/Resources/config
printf '%s\n%s\n%s\n%s\n%s\n' '{' '"pluginDirs":[' '"$(APPDIR)/../Plugins/"' ']' '}' > /tmp/Carta.app/Contents/Resources/config/config.json

# Copy html in the application directory

cp -r $CARTABUILDHOME/CARTAvis/carta/VFS/DesktopDevel /tmp/Carta.app/Contents/Resources/html

#######################
# Fix Qt packaging
#######################

./fixCartaQt.sh

########################
# Copy sample images over
########################
curl -O -L https://svn.cv.nrao.edu/casa/devel/carta/cartaimages.tar.gz && tar xvfz cartaimages.tar.gz -C /tmp/Carta.app/Contents/Resources/ && rm cartaimages.tar.gz

Run

ulimit -n 2000
./desktop --config ../Resources/config/config.json --html `pwd`/../Resources/html/desktop/desktopIndex.html --scriptPort 9999 /opt/casa/01//Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyfits/tests/data/test0.fits

Qt 5.7 mods

mkdir /tmp/Carta.app/Contents/MacOS/platforms/
cp /Users/$USER/Qt5.7.0/5.7/clang_64/plugins/platforms/libqcocoa.dylib /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
install_name_tool -change @rpath/QtGui.framework/Versions/5/QtGui @loader_path/../../Frameworks/QtGui.framework/Versions/5/QtGui   /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
install_name_tool -change @rpath/QtCore.framework/Versions/5/QtCore @loader_path/../../Frameworks/QtCore.framework/Versions/5/QtCore /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
install_name_tool -change @rpath/QtDBus.framework/Versions/5/QtDBus  @loader_path/../../Frameworks/QtDBus.framework/Versions/5/QtDBus  /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
install_name_tool -change @rpath/QtPrintSupport.framework/Versions/5/QtPrintSupport @loader_path/../../Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
install_name_tool -change @rpath/QtWidgets.framework/Versions/5/QtWidgets @loader_path/../../Frameworks/QtWidgets.framework/Versions/5/QtWidgets /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib
otool -L /tmp/Carta.app/Contents/MacOS/platforms/libqcocoa.dylib

-- VilleSuoranta - 2016-04-28
Topic revision: r16 - 2017-03-21, 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