#!/bin/sh
# This is a wrapper script to let LyX/Cygwin use either a native Win32 or
# Cygwin version of epstopdf (coming with either teTeX or MikTeX).
#
# This script simply changes all input pathnames into Windows or Cygwin
# pathnames depending on which version of epstopdf is being used.
# If the pathnames contain spaces, either enclose them in double quotes
# or escape the spaces. For example:
# epstopdf --outfile="output file.pdf" "input file.eps"
# epstopdf --outfile=output\ file.pdf input\ file.eps
#
# 2007-02-15 Enrico Forestieri
# =======================================================================

# The program to call (This should be in the PATH)
prog=epstopdf.exe

# If no epstopdf.exe is in the PATH, hope we have the cygwin script
if [ "`which $prog 2>/dev/null`" = "" ]; then
    prog=/usr/bin/epstopdf
    flag=""
else
    flag="-m"
fi

while [ $# -gt 0 ] ; do
    case "$1" in
	-*=*) opt=`echo "$1" | cut -d= -f1`
	      file=`echo "$1" | cut -d= -f2-`
	      file=`cygpath $flag -- "$file"`
	      prog="$prog $opt='\"$file\"'"
	      ;;
	-*)   prog="$prog $1"
	      ;;
	*)    prog="$prog '`cygpath $flag -- "$1"`'"
	      ;;
    esac
    shift
done

eval "exec $prog"
