File: install_tiemu.sh - Tab length: 1 2 4 8 - Lines: on off - No wrap: on off

#! /bin/sh

# This script automates the compilation and installation of tiemu
# from the SVN repository.
# IMPORTANT: * remove equivalent packages, if any, before running this script.
#            * see below for prerequisites (dependencies).
#
# libti* and tiemu are compiled with a proposed set of configuration options,
# but you may wish to use others. The complete list is available through
# `./configure --help` run in $SRCDIR/tilp/libticonv, $SRCDIR/tilp/libtifiles,
# $SRCDIR/tilp/libticables, $SRCDIR/tilp/libticalcs, $SRCDIR/tiemu/tiemu.


# The place where the sources will be stored.
SRCDIR="$HOME/lpg"

# The prefix where the binaries will be installed, e.g. $HOME, /usr, /usr/local, /usr/share.
#
# NOTES:
# * if installing to e.g. $HOME or /usr/local, you'll certainly have to execute
# $ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/lib/pkgconfig
# (or the equivalent setenv command for csh derivatives).
# and put it in your ~/.bashrc (~/.cshrc, etc.), before executing this script.
#
# * after successful installation, you may have to add $PREFIX/bin to $PATH,
# and $PREFIX/lib to $LD_LIBRARY_PATH, for the SVN versions of libti* and tiemu
# to get picked up.
PREFIX="$HOME"


# Mandatory dependencies for compiling and running libti* and tiemu:
# (Debian and Fedora package names are given)
# * pkg-config
# * GNU autoconf, automake, libtool
# * glib 2.x development files (libglib2.0-dev, glib2-devel)
# * zlib development files (zlib1g-dev, zlib-devel)
# * libusb development files (libusb-dev, libusb-devel)
# * GTK+ 2.x and Glade development files (libgtk2.0-dev + libglade2-dev, gtk2-devel + libglade2-devel)
# * SDL 1.2 development files (libsdl1.2-dev, SDL-devel)
# * libncurses 5 development files (libncurses5-dev, ncurses-devel)
# * GNU gettext
# * GNU bison, flex
# * GNU groff, texinfo
# * XDG utils
#
# Optional dependencies:
# * KDE 3.x development files (kdelibs4-dev, kdelibs3-devel), if you want to compile TIEmu with support for the KDE file dialog.
#   (this implies Qt development files)
# * DBus-Glib development files (libdbus-glib-1-dev, dbus-devel + dbus-glib-devel), if you want to compile TIEmu with D-Bus support.


# Checkout/update, `configure`, `make` and `make install` the given module
handle_one_module() {
  module_name="$1"
  shift # Kick the first argument, so as to be able to pass the rest to configure.

  if [ -d "$module_name" -a -d "$module_name/.svn" ]; then
    echo "Updating $module_name"
    cd "$module_name"
    svn up || return 1
    cd ../..
  else
    echo "Checking out $module_name"
    svn co "http://svn.tilp.info/repos/$module_name/trunk" "$module_name" || return 1
  fi

  cd "$module_name"
  echo "Configuring $module_name"
  ./configure "--prefix=$PREFIX" $@ || return 1
  echo "Building $module_name"
  make || return 1
  echo "Installing $module_name"
  make install || return 1
  cd ../..
}

echo "Creating output folder if necessary"
mkdir -p "$SRCDIR/tilp" || exit 1
mkdir -p "$SRCDIR/tiemu" || exit 1

cd "$SRCDIR"
handle_one_module tilp/libticonv || exit 1
# Useful configure options include --disable-nls.
handle_one_module tilp/libtifiles || exit 1
# Useful configure options include --disable-nls, --enable-logging.
handle_one_module tilp/libticables --enable-logging || exit 1
# Useful configure options include --disable-nls.
handle_one_module tilp/libticalcs || exit 1

# Useful configure options include --disable-gdb, --with-dbus and --without-kde.
handle_one_module tiemu/tiemu --disable-gdb --with-dbus || exit 1