#!/bin/bash

package=vigra
version=-1.9.0

progname=$0

source ../cascade-make/lib/cascade-lib.bash GEXT_HUGIN ../.. $*

prefix=$GEXTHUGIN_INSTALLED

# Whether force_config is set for this package depends on CMake test
# to see if 'release' directory has been created or no
if [ $auto_config = "1" ] ; then
  if [ ! -d $package$version/release ]; then
    force_config=1
  fi
fi

opt_run_untar $force_untar $auto_untar $package $version

if [ $force_config = "1" ] ; then
  echo "[pushd $package$version]"
  ( cd $package$version ; \
    if [ ! -d release ] ; then \
      echo "Creating 'release' directory" ; \
      mkdir release ; \
    fi ; \
    cd release ; \
    cmake -D CMAKE_INSTALL_PREFIX=$prefix \
           ..;
    PKG_CONFIG_PATH=$prefix/lib/pkgconfig:${PKG_CONFIG_PATH};
    export PKG_CONFIG_PATH;
   )
  if [ $? != 0 ] ; then
      echo "      Error encountered running *configure* stage of $progname"
      exit 1
  fi
  echo "[popd]"
else
  if [ $auto_config = "1" ] ; then
    echo "Found top-level for ${progname%.*} => no need to run configure/initialize CMake"
  fi
fi

opt_run_cmake $compile $package $version "release"
opt_run_cmake $install $package $version "release" "install"
opt_run_cmake $clean $package $version "release" "clean"
opt_run_cmake $distclean $package $version "release" "distclean"

opt_run_tarclean $tarclean $package $version

