DISTDIR=		${PORTSDIR}/distfiles/xc
DISTFILES1	=	xc-1.tar.gz xc-2.tar.gz xc-3.tar.gz
XFREE_DIFFS	=	XFree86-3.1.1.diff.gz
DISTFILES3	=	${XFREE_DIFFS}

.if !defined(MASTER_SITE_OVERRIDE)
#DISTFILES2 	=	fixes/fix-01 fixes/fix-02 fixes/fix-03 fixes/fix-04 \
#			fixes/fix-05 fixes/fix-06 fixes/fix-07 fixes/fix-08 \
#			fixes/fix-09 fixes/fix-10 fixes/fix-11 \
#			fixes/fix10fonts.Z
#XFREE_TAR	=	fixes/XFree86-3.1.1.tar.gz 
MASTER_SITE	=	ftp://ftp.x.org/pub/R6/
MASTER_SITE2	=	ftp://ftp.xfree86.org/pub/XFree86/3.1.1/patches/
.else
#DISTFILES2 	=	fix-01 fix-02 fix-03 fix-04 \
#			fix-05 fix-06 fix-07 fix-08 \
#			fix-09 fix-10 fix-11 \
#			fix10fonts.Z
#XFREE_TAR	=	XFree86-3.1.1.tar.gz 
MASTER_SITE	=	${MASTER_SITE_OVERRIDE}xc/
MASTER_SITE2	=	${MASTER_SITE_OVERRIDE}xc/
.endif
EXTRACT_ONLY	=	${DISTFILES1}

do-fetch:
	@if [ ! -d ${DISTDIR} ]; then \
		mkdir -p ${DISTDIR}; \
	fi
	@cd ${DISTDIR}; \
	 for file in ${DISTFILES1} ${DISTFILES2} ${XFREE_TAR}; do \
		f=`basename $$file`;\
		if [ ! -f $$f ]; then \
			echo ">> $$f doesn't seem to exist on this system."; \
			echo ">> Attempting to fetch it from a master site."; \
			${NCFTP} ${NCFTPFLAGS} ${MASTER_SITE}$${file}; \
			if [ ! -f $$f ]; then \
				echo ">> Couldn't fetch it - please try to retreive this";\
				echo ">> port manually into ${DISTDIR} and try again."; \
				exit 1; \
			else \
				echo "$$f fetched!"; \
			fi; \
	    	fi; \
	   done
	@cd ${DISTDIR}; \
	  for file in ${DISTFILES3}; do \
		if [ ! -f $$file ]; then \
			echo ">> $$file doesn't seem to exist on this system."; \
			echo ">> Attempting to fetch it from a master site."; \
			${NCFTP} ${NCFTPFLAGS} ${MASTER_SITE2}$${file}; \
			if [ ! -f $$file ]; then \
				echo ">> Couldn't fetch it - please try to retreive this";\
				echo ">> port manually into ${DISTDIR} and try again."; \
				exit 1; \
			else \
				echo "$$file fetched!"; \
			fi; \
	    fi \
	 done

pre-patch:
	@echo ${DISTDIR} > ${WRKDIR}/.ftp
