#!/bin/bash

package=OpenSIFT
version=-gs-1.1.2

progname=$0

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

prefix=$GEXTOPENCV_INSTALLED

opt_run_untar $force_untar $auto_untar $package $version
#opt_run_configure $force_config $auto_config $package $version $prefix

# Only compile if necessary - we don't edit these source files.
if type -p siftfeat; then
  echo "found sift in PATH"
  _SIFT=siftfeat
elif [[ -x "$GEXTOPENCV_INSTALLED/linux/bin/siftfeat" ]]; then
  echo "found sift in openCV/linux/bin"
  _SIFT="$GEXTOPENCV_INSTALLED/linux/bin/siftfeat"
fi

#if [[ "$_CMAKE" ]]; then
#  _VERSION=$("$_CMAKE" --version 2>&1 | sed 's/.*cmake version \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/;1q')
#  echo "cmake version $_VERSION"
#fi

if [[ ! "$_SIFT" ]]; then
  opt_run_make $compile   $package $version
  #opt_run_make $install   $package $version "install"
  cd $package$version
  echo "installing executables..."
  cp "bin/dspfeat" "$GEXTOPENCV_INSTALLED/bin/dspfeat"
  cp "bin/match" "$GEXTOPENCV_INSTALLED/bin/match"
  cp "bin/siftfeat" "$GEXTOPENCV_INSTALLED/bin/siftfeat"
  cd -
else
  echo "$package$version already available => no need to recompile"
fi

opt_run_make $clean     $package $version "clean"
opt_run_make $distclean $package $version "distclean"

opt_run_tarclean $tarclean $package $version





