#! /bin/sh

# $FreeBSD: ports/print/apsfilter6/scripts/configure,v 1.17 2000/09/09 09:31:31 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_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/ghostscript6
		;;
	\"GS_PDF_CRYPT\")
		echo RUN_DEPENDS+=gs:${PORTSDIR}/print/ghostscript6
		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\")
		echo RUN_DEPENDS+=bunzip2:${PORTSDIR}/archivers/bzip2
		;;
	\"FREEZE\")
		echo RUN_DEPENDS+=smbclient:${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
echo "post-install:"
echo "	@\${MKDIR} ${PREFIX}/apsfilter/filter"
echo "	@touch ${PREFIX}/apsfilter/filter/.keep_me"
 echo "	@\${ECHO} \"========================================================\""
 echo "	@\${ECHO} \"************ Post Installation Tasks *******************\""
 echo "	@\${ECHO} \"========================================================\""
if [ $TROFF ]
then
 echo "	@\${ECHO} \"If running FreeBSD < 4.0 and you want to print troff    \""
 echo "	@\${ECHO} \"files then you have to install the grog utility         \""
 echo "	@\${ECHO} \"from the groff sources:                                 \""
 echo "	@\${ECHO} \"    cp /usr/src/contrib/groff/grog/grog.sh /usr/bin/grog\""
 echo "	@\${ECHO} \"    chmod 555 /usr/bin/grog                             \""
 echo "	@\${ECHO} \"--------------------------------------------------------\""
fi
 echo "	@\${ECHO} \"*** Please Note                                    ***  \""
 echo "	@\${ECHO} \"To enable so called CLASS support without printing      \""
 echo "	@\${ECHO} \"the banner page (/etc/printcap: :sh:)                   \""
 echo "	@\${ECHO} \"apply the patch for lpr.c, see file INSTALL !!!         \""
 echo "	@\${ECHO} \"--------------------------------------------------------\""
 echo "	@\${ECHO} \"*** Printer installation / apsfilter setup         ***  \""
 echo "	@\${ECHO} \"    cd ${PREFIX}/share/apsfilter; ./SETUP                     \""
