#!/bin/bash

#package=MediaInfo-CLI
package=MediaInfo_CLI
#version=-0.7
version=_0.7.99_GNU_FromSource

progname=$0

source ../../cascade-make/lib/cascade-lib.bash

prefix=$GEXTVIDEO_INSTALLED

#opt_run_untar $force_untar $auto_untar $package $version ".tar.bz2"
opt_run_untar $force_untar $auto_untar $package $version 

#opt_run_configure $force_config $auto_config $package $version "$prefix" \
#         "--with-ogg=$prefix"
#opt_run_make $compile   $package $version
#opt_run_make $install   $package $version "install"
#opt_run_make $clean     $package $version "clean"
#opt_run_make $distclean $package $version "distclean"


opt_run_tarclean $tarclean $package $version

if [ $tarclean = "1" ] ;then
  exit
fi

if [ -d ${package}_GNU_FromSource ] ; then
  echo "****"
  echo "* Always (for now) have it run the automatic script for MediaInfo"
  echo "****"

# Run an automatic script that will configure and compile MediaInfo with the dependencies
  ( echo "[pushd ${package}_GNU_FromSource]" ; \
    cd ${package}_GNU_FromSource ; \
    ./CLI_Compile.sh )

    if [ $? != 0 ] ; then
        echo "      Error encountered running the automatic script of $progname"
        exit 1
    fi
    echo "[popd]"
fi


if [ $install = "1" ] ; then
  ( echo "[pushd ${package}_GNU_FromSource]" ; \
    cd ${package}_GNU_FromSource/MediaInfo/Project/GNU/CLI ; \
    cp -p mediainfo $GEXTVIDEO_INSTALLED/bin )

  if [ $? != 0 ] ; then
      echo "      Error encountered running *install* stage of $progname"
      exit 1
  fi
  echo "[popd]"
fi

