#!/bin/sh
# Wrapper file for pcd2html tools

BIN=`basename $0`

if ! `echo $1 | grep -q clean` ; then
  # if Argument does not contain "clean" check for call outisde of Midnight Commander
  if `pstree | grep -q -- "--mc--.*--${BIN}--"` ; then 
    echo "Please avoid starting ${BIN} out of Midnight Commander because it might destroy email address"
    exit
  fi
fi

if [ _$1 != _ ] ; then
  case "$1" in
    clean)
      echo -n "Clean unused files"
      echo "."
      ;;
    distclean)
      echo -n "Clean all things created by ${BIN}"
      echo "."
      ;;
    data)
      echo -n "Create archive of PCD handling data"
      echo "."
      ;;
    html)
      echo -n "Create archive of ready HTML data"
      echo "."
      ;;
    create_html)
      echo -n "Create HTML file to show image $2"
      echo "."
      ${datadir}/pcd2html_create_html $2
      exit
      ;;
    *)
      echo "Usage: ${BIN} {data|html|clean|distclean|create_html <filename>}"
      exit 1
  esac
fi
PATH="${datadir}:$PATH"
export PATH
make -f ${datadir}/Makefile $1
# make -f ${datadir}/Makefile -k $1
