#! /bin/sh

# $FreeBSD: ports/print/apsfilter/scripts/configure,v 1.25 2002/10/29 08:48:22 andreas Exp $

if [ "$BATCH" != "yes" ]; then

#
# configure - apsfilter package dependency configuration
#

/usr/bin/dialog --title "supported file types" --clear \
	--checklist "\n\
Select file types you want to print:" -1 -1 14	\
A4		"A4 papersize"					ON	\
LETTER		"letter papersize"				OFF	\
LETTERDJ	"letter + special DeskJet adjustements"		OFF	\
GS		"Postscript for non-PS printer, needs X11"	ON	\
GS_NO_X11	"Postscript for non-PS printer, no X11"		OFF	\
GS_PDF_CRYPT	"print encrypted PDF files using gs"		ON	\
PSUTILS		"for pseudo duplex printing + paper handling"	ON	\
A2PS		"ASCII files in different styles/orientation"	ON	\
ACROREAD4	"PDF files, needs Linux emulation"		ON	\
CONVERT		"support for lots of graphic file formats"	ON	\
DVIPS		"TeX DVI files"					OFF	\
FIG2DEV		"XFIG drawings"					OFF	\
HTML2PS		"HTML documents"				OFF	\
TROFF		"Troff documents"				OFF	\
ATALK		"remote printing on AppleTalk remote printer"	OFF	\
SAMBA		"remote printing on Windows remote printer"	OFF	\
BZIP2		"print bunzip2 compressed documents"		OFF	\
FREEZE		"print freeze compressed documents"		OFF	\
2> /tmp/apsfilter-checklist.$$

retval=$?

if [ -s /tmp/apsfilter-checklist.$$ ]; then
	set `cat /tmp/apsfilter-checklist.$$`
fi
rm -f /tmp/apsfilter-checklist.$$

case $retval in
	0)	if [ -z "$*" ]; then
			echo "Nothing selected"
		fi
		;;
	1)	echo "Cancel pressed."
		exit 1
		;;
esac

/bin/mkdir -p ${WRKDIRPREFIX}${CURDIR}
exec > ${WRKDIRPREFIX}${CURDIR}/Makefile.inc

while [ "$1" ]; do
    case $1 in
	\"A4\")
		PAPERSIZE=a4
		echo "PAPERSIZE=a4"
		;;
	\"LETTER\")
		PAPERSIZE=letter
		echo "PAPERSIZE=letter"
		;;
	\"LETTERDJ\")
		PAPERSIZE=letterdj
		echo "PAPERSIZE=letterdj"
		;;
	\"GS\")
		echo RUN_DEPENDS+=gs:${PORTSDIR}/print/ghostscript-gnu
		;;
	\"GS_NO_X11\")
		echo RUN_DEPENDS+=gs:${PORTSDIR}/print/ghostscript-gnu-nox11
		;;
	\"GS_PDF_CRYPT\")
		echo PDFENCRYPT=YES
		;;
	\"PSUTILS\")
		case $PAPERSIZE in
		    letter)
			echo RUN_DEPENDS+=psnup:${PORTSDIR}/print/psutils-letter
			;;
		    letterdj)
			echo RUN_DEPENDS+=psnup:${PORTSDIR}/print/psutils-letter
			;;
		    a4)
			echo RUN_DEPENDS+=psnup:${PORTSDIR}/print/psutils-a4
			;;
		esac
		;;
	\"A2PS\")
		case $PAPERSIZE in
		    letter)
			echo RUN_DEPENDS+=a2ps:${PORTSDIR}/print/a2ps-letter
			;;
		    letterdj)
			echo RUN_DEPENDS+=a2ps:${PORTSDIR}/print/a2ps-letterdj
			;;
		    a4)
			echo RUN_DEPENDS+=a2ps:${PORTSDIR}/print/a2ps-a4
			;;
		esac
		;;
	\"ACROREAD4\")
		echo RUN_DEPENDS+=acroread4:${PORTSDIR}/print/acroread4
		;;
	\"CONVERT\")
		echo RUN_DEPENDS+=convert:${PORTSDIR}/graphics/ImageMagick
		;;
	\"DVIPS\")
		echo RUN_DEPENDS+=dvips:${PORTSDIR}/print/teTeX
		;;
	\"FIG2DEV\")
		echo RUN_DEPENDS+=fig2dev:${PORTSDIR}/print/transfig
		;;
	\"HTML2PS\")
		case $PAPERSIZE in
		    letter)
		      echo RUN_DEPENDS+=html2ps:${PORTSDIR}/print/html2ps-letter
		      ;;
		    letterdj)
		      echo RUN_DEPENDS+=html2ps:${PORTSDIR}/print/html2ps-letter
		      ;;
		    a4)
		      echo RUN_DEPENDS+=html2ps:${PORTSDIR}/print/html2ps-a4
		      ;;
		esac
		;;
	\"TROFF\")
		TROFF=YES
		;;
	\"ATALK\")
		echo RUN_DEPENDS+=pap:${PORTSDIR}/net/netatalk
		;;
	\"SAMBA\")
		echo RUN_DEPENDS+=smbclient:${PORTSDIR}/net/samba
		;;
	\"BZIP2\")
		if [ ! -x /usr/bin/bzip2 ]; then
			echo RUN_DEPENDS+=bunzip2:${PORTSDIR}/archivers/bzip2
		fi
		;;
	\"FREEZE\")
		echo RUN_DEPENDS+=melt:${PORTSDIR}/archivers/freeze
		;;
    esac
    shift
done

fi # if $BATCH

# if batch, then start creating Makefile.inc here
if [ "$BATCH" = "yes" ]; then
	/bin/mkdir -p ${WRKDIRPREFIX}${CURDIR}
	exec > ${WRKDIRPREFIX}${CURDIR}/Makefile.inc
fi
