Build everything from source

From emergent
Jump to: navigation, search
Emergent Logo
Installing and Building Emergent
  • Build from source (expert)

This script builds emergent and all of its prerequisites from source. It is useful for *NIX systems where it is not possible to install the various dependency libraries that emergent builds on from packages.

You need to have subversion ('svn') and wget installed. In order to run this script you must save it to your hard drive as build_emergent.sh, and then type sh build_emergent.sh. Please do not run this script without reading the README section of its comments.

Also see cmake and configure for useful compiling information.

#!/bin/bash
# Build emergent and all of its prerequisites from source
# Copyright (C) 2009-2018  Brian Mingus, University of Colorado at Boulder
 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

################# <README> #################
# * Do *NOT* run this script without first considering whether you should modify the variables in Step 1
# * This script will take several hours to run.
# * You need approximately 5 GB of free space on your disk.
# * By default this script will build emergent in ~/emergent (~ means $HOME)
# * By default this script will build emergent's prerequisites in ~/emergent/src_build
# * In order to update emergent in the future: cd ~/emergent && svn up && cd build && make -j2 && make install
# * By default do *NOT* run this script as root
# * If you get cannot find library errors, or if you can not run emergent,
#   you may need to put the following lines (uncommented) at the end of your ~/.bashrc
# export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH
# export EMERGENT_PREFIX_DIR=$HOME
# PATH=$HOME/bin:$PATH
# * The latest version of this script was tested on Ubuntu Trusty
#   and the following packages were installed with apt-get: git libicu-dev ruby libxrender-dev
################# </README> #################

echo '###################################'
echo Step 1: Configuration
echo '###################################'

# Modifiable variables
INSTALL_PREFIX=$HOME               # If you want to install to the system set this to /usr/local and *RUN THE SCRIPT AS ROOT*
BUILD_DIR=$HOME/emergent/src_build # This is where we will download and build all packages before install
                                   # On stampede, set BUILD_DIR=$SCRATCH/emergent/src_build
export MAKEFLAGS="-j12"            # Change the integer to the number of cpus that you have available for building

# Do not modify anything below this line unless you are updating the script
CMAKE_VERSION=3.10.2
#JPG_VERSION=6b
PNG_VERSION=1.6.34
GPERF_VERSION=3.1
QT_VERSION=5.10.0
GSL_VERSION=1.16
ODE_VERSION=0.13
SVN_VERSION=1.8.9
APR_VERSION=1.5.1
APRUTIL_VERSION=1.5.3
READLINE_VERSION=6.3
TERMCAP_VERSION=1.3.1
BISON_VERSION=2.3
M4_VERSION=1.4.17
GPERF_VERSION=3.0.4
FLEX_VERSION=2.5.39

export QTDIR=$INSTALL_PREFIX/Trolltech/Qt-${QT_VERSION}
export COINDIR=$INSTALL_PREFIX
PATH=$QTDIR/bin:$INSTALL_PREFIX/bin:/bin:/usr/bin
LD_LIBRARY_PATH=$QTDIR/lib:$INSTALL_PREFIX/lib:/lib:/usr/lib

if [[ ! -d $INSTALL_PREFIX ]]
then
  mkdir $INSTALL_PREFIX
fi

if [[ -d $BUILD_DIR ]]
then
  rm -fr $BUILD_DIR
fi

mkdir -p $BUILD_DIR

if [[ -e ~/.bashrc ]]
then
    source ~/.bashrc
fi

getwikiurl () {
wget -q -O- "http://grey.colorado.edu/emergent/api.php?action=query&titles=File:$1&prop=imageinfo&iiprop=url&format=json" | tr '"' "\n" | grep images
}

echo '###################################'
echo Step 2: CMake
echo '###################################'

cd $BUILD_DIR
wget $(getwikiurl cmake-${CMAKE_VERSION}.tar.gz)
tar -xzf cmake-${CMAKE_VERSION}.tar.gz
cd cmake-${CMAKE_VERSION}
./configure --prefix=$INSTALL_PREFIX
make install

echo '###################################'
echo Step 3: jpeg
echo '###################################'

#cd $BUILD_DIR
#wget $(getwikiurl jpegsrc.v${JPG_VERSION}.tar.gz)
#tar -xzf jpegsrc.v${JPG_VERSION}.tar.gz
#cd jpeg-${JPG_VERSION}
#./configure --prefix=$INSTALL_PREFIX
#make install

echo '###################################'
echo Step 4: png
echo '###################################'

cd $BUILD_DIR
wget $(getwikiurl libpng-${PNG_VERSION}.tar.gz)
tar -xzf libpng-${PNG_VERSION}.tar.gz
cd libpng-${PNG_VERSION}
./configure --prefix=$INSTALL_PREFIX
make install

echo '###################################'
echo Step 4: gperf
echo '###################################'

cd $BUILD_DIR
wget $(getwikiurl gperf-${GPERF_VERSION}.tar.gz)
tar -xzf gperf-${GPERF_VERSION}.tar.gz
cd gperf-${GPERF_VERSION}
./configure --prefix=$INSTALL_PREFIX
make install

echo '###################################'
echo Step 5: Qt
echo If you're reading this: Qt may (as of 2018) no longer be safe to compile under -j. Try make -j1 explicitly, then after a while, make -j12
echo '###################################'

cd $BUILD_DIR
wget $(getwikiurl qt-everywhere-src-${QT_VERSION}.tar.gz)
tar -xf qt-everywhere-src-${QT_VERSION}.tar.gz
cd qt-everywhere-src-${QT_VERSION}
./configure -prefix $QTDIR -opensource -qt-xcb -icu -confirm-license
make install

echo '###################################'
echo Step 6: Coin
echo '###################################'

cd $BUILD_DIR
rm -fr coin_trunk
svn checkout --username anonymous --password emergent https://grey.colorado.edu/svn/coin3d/coin/trunk coin_trunk
cd coin_trunk
./configure --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 7: Quarter
echo '###################################'

cd $BUILD_DIR
rm -fr quarter_trunk
svn checkout --username anonymous --password emergent https://grey.colorado.edu/svn/coin3d/quarter/trunk quarter_trunk
cd quarter_trunk
export CPPFLAGS="-I$QTDIR/include/QtCore -I$QTDIR/include/QtWidgets -I$QTDIR/include/QtOpenGL -I$QTDIR/include/QtGui -fPIC"
./configure --prefix=$INSTALL_PREFIX --disable-pkgconfig --disable-debug --with-qt=$QTDIR --with-qt-designer-plugin-path=$QTDIR/plugins/designer
make $MAKE_JOBS
make install
unset CPPFLAGS

echo '###################################'
echo Step 8: GNU Scientific Library
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/gsl-${GSL_VERSION}.tar.gz
tar -xzf gsl-${GSL_VERSION}.tar.gz
cd gsl-${GSL_VERSION}
./configure --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 9: Open Dynamics Engine
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/ode-${ODE_VERSION}.tar.gz
tar -xzf ode-${ODE_VERSION}.tar.gz
cd ode-${ODE_VERSION}
./configure --enable-shared --disable-static --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 10: Apache Portable Runtime
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/apr-${APR_VERSION}.tar.gz
wget ${FTP_REPO}/apr-util-${APRUTIL_VERSION}.tar.gz
tar -xzf apr-${APR_VERSION}.tar.gz
tar -xzf apr-util-${APRUTIL_VERSION}.tar.gz
cd apr-${APR_VERSION}
./configure --enable-shared --disable-static --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install
cd ../apr-util-${APRUTIL_VERSION}
./configure --prefix=$INSTALL_PREFIX --with-apr=$HOME/bin/apr-1-config
make $MAKE_JOBS
make install

echo '###################################'
echo Step 11: Subversion
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/subversion-${SVN_VERSION}.tar.gz
tar -xzf subversion-${SVN_VERSION}.tar.gz
cd subversion-${SVN_VERSION}
./configure --enable-shared --disable-static --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 12: Termcap
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/termcap-${TERMCAP_VERSION}.tar.gz
tar -xzf termcap-${TERMCAP_VERSION}.tar.gz
cd termcap-${TERMCAP_VERSION}
./configure --enable-shared --disable-static --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 12: Readline
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/readline-${READLINE_VERSION}.tar.gz
tar -xzf readline-${READLINE_VERSION}.tar.gz
cd readline-${READLINE_VERSION}
./configure --enable-shared --disable-static --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 13: M4
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/m4-${M4_VERSION}.tar.gz
tar -xzf m4-${M4_VERSION}.tar.gz
cd m4-${M4_VERSION}
./configure --enable-shared --disable-static --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 13: Bison
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/bison-${BISON_VERSION}.tar.gz
tar -xzf bison-${BISON_VERSION}.tar.gz
cd bison-${BISON_VERSION}
./configure --enable-shared --disable-static --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 13: Gperf
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/gperf-${GPERF_VERSION}.tar.gz
tar -xzf gperf-${GPERF_VERSION}.tar.gz
cd gperf-${GPERF_VERSION}
./configure --enable-shared --disable-static --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 13: Flex
echo '###################################'

cd $BUILD_DIR
wget ${FTP_REPO}/flex-${FLEX_VERSION}.tar.gz
tar -xzf flex-${FLEX_VERSION}.tar.gz
cd flex-${FLEX_VERSION}
./configure --enable-shared --disable-static --prefix=$INSTALL_PREFIX
make $MAKE_JOBS
make install

echo '###################################'
echo Step 13: WebKit
echo '###################################'

cd $BUILD_DIR
git clone git://gitorious.org/webkit/webkit.git
WEBKIT_OUTPUTDIR=$QTDIR/
#LD_LIBRARY_FLAGS=$BUILD_DIR/qt-everywhere-opensource-src-${QT_VERSION}/qtwebkit/Source/WTF/icu/
webkit/Tools/Scripts/build-webkit --no-webkit1 --minimal --qt --makeargs="$MAKE_JOBS"

echo '###################################'
echo Step 13: emergent
echo '###################################'

cd $BUILD_DIR
svn checkout --username anonymous --password emergent http://grey.colorado.edu/svn/emergent/emergent/trunk $HOME/emergent/
cd $HOME/emergent
mkdir build
./configure --qt5 --prefix=$INSTALL_PREFIX
cd build
make $MAKE_JOBS
make install

echo "###################################"
echo "Step 11: You're done. Type emergent at the command line."
echo ""
echo "If you did a local install (not into /usr/local) then you can start emergent like this:"
echo "LD_LIBRARY_PATH=$INSTALL_PREFIX/lib:$QTDIR/lib:\$LD_LIBRARY_PATH $INSTALL_PREFIX/bin/emergent"
echo ""
echo "If you get errors regarding missing libraries, or your shell cant see emergent, put this at the end of your ~/.bashrc:"
echo "LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH"
echo "PATH=$HOME/bin:$PATH"
echo "###################################"

Reference Information on Prerequisite Libraries

These are all the libraries that emergent depends upon -- on most Build procedures, these libraries are available as pre-compiled, easy-to-use packages of one form or another. This information is just for general reference and in case you want to update or otherwise do something special with a particular library.

Current versions of each relevant package are always available on our ftp site:

ftp://grey.colorado.edu/pub/emergent or https://grey.colorado.edu/emergent_ftp/

The prerequisites are generally the same across operating systems but always check the operating system specific build instructions for version info.

Package Cur Version Main URL Download URL Docs URL
Qt (gui and OS api) 5.6.1 (LTS) (also works with old versions, back to 4.8 or so) https://www.qt.io/ https://www1.qt.io/offline-installers/ http://doc.qt.io/qt-5/reference-overview.html
Coin & Quarter (3D scenegraph & Qt api) 3.1.3 We have our own patched version that is required: Coin3d Coin3d
ODE (Physics sim) 0.14 http://ode.org/ https://bitbucket.org/odedevs/ode/ http://opende.sourceforge.net/wiki/index.php/Manual
GSL (math library) 1.13 http://www.gnu.org/software/gsl/ ftp://ftp.gnu.org/gnu/gsl/ http://www.gnu.org/software/gsl/manual/html_node/
cmake (build system) 3.6.1 (NOTE: avoid anything before 2.8.4) http://www.cmake.org/ https://cmake.org/download/ https://cmake.org/documentation/
subversion (required from v6.2.0) 1.9.4 http://subversion.apache.org http://subversion.apache.org/packages.html (use WANdisco, full package for mac, installs in /opt/subversion)
libsndfile (sound file load / save -- optional, needed for auditory) 1.0.26 http://www.mega-nerd.com/libsndfile/ http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.26.tar.gz n/a