
PERL		=	/usr/local/bin/perl
SKELTON_FILE	=	skelton.html
TDF2HTML	=	tdf2html.pl
TEMP		=	/tmp

TARGET		=	index.html

# for upload
# FTP client
# dos telnet (ignore .netrc)
FTP		=	ftp -n -s:${TMPFILE}
# enable .netrc
#FTP		=	cat ${TMPFILE} | ftp

# server setting
FTP_SERVER	=	ftp.bar.com
SERVER_DIR	=	public_html
TMPFILE	=	upload.tmp


################################################################
.SUFFIXES: .tdf .html .tex

.tdf.html:
	${PERL} ${TDF2HTML} -s ${SKELTON_FILE} $? > ${TEMP}/$@
	cp ${TEMP}/$@ $@
	@rm ${TEMP}/$@

all:	${TARGET}

clean:	
	rm -f ${TARGET}


upload: init_tmp ${TARGET} ${UPLOAD_FILES}
	echo cd ${SERVER_DIR} >> ${TMPFILE}
	(for f in $? ; do echo put $$f; done) >> ${TMPFILE}	
	echo quit >> ${TMPFILE}
	${FTP} ${FTP_SERVER}
	rm -f ${TMPFILE}
	touch $@

init_tmp:
	# .ftp_login is needed if MS-DOS
	@if [ "${WINDIR}" = "" ] ; then \
		touch .ftp_login; \
	fi
	@if [ ! -f .ftp_login ] ; then \
		echo "ERROR: create .ftp_login, such as "; \
		echo "user your-name"; \
		echo "your-password"; \
		exit 1; \
	fi
	cp .ftp_login ${TMPFILE};
	echo bin >> ${TMPFILE}
