#!/bin/tcsh

# A wrapper to call ghostscript in the correct folder.
# By Richard Koch, July 29, 2001, following similar code by
# Gerben Wierda

if ("$argv[1]" == "Panther") then
    set filename = "$argv[3]"
    /usr/bin/pstopdf "${filename}"
    
else


    set mygspath = "$argv[2]"
    if (-x ${mygspath}/ps2pdf) then
        setenv PATH "${mygspath}:${PATH}"
        rehash


        set gsversion = `gs --version`
        set major =  `echo $gsversion | cut -d. -f1`
        set minor =  `echo $gsversion | cut -d. -f2`

        if ( $major >= 10 || ( $major >= 9 && $minor >= 51 ) ) then
            set filename = "$argv[3]"
            ps2pdf -dALLOWPSTRANSPARENCY "${filename}"

        else
            set filename = "$argv[3]"
            ps2pdf  "${filename}"
	
        endif

    endif
	
endif
