# public_html/std
STUFF = index.top index.middle index.tail
all:	index.lmth index.html
index.lmth:	${STUFF}
	echo '<!-- WARNING DO NOT EDIT index.lmth, built from Makefile -->' > ${.CURDIR}/$@
	cat ${STUFF} >> ${.CURDIR}/$@
index.middle:	*.txt Makefile
	echo "" > ${.CURDIR}/$@
	@# the final sed in label tst: below doesn't work so work round it.
	@# echo '<LI><a name=dummy><small><small>Ignore this line</small></small>' >> ${.CURDIR}/$@
	grep -i subject: `ls -1 *\.txt`			\
		| sed -e 's/Subject:/subject:/'		\
		| sed -e 's/subject: /subject:/'	\
		| sed -e 's/subject://'		\
		| sort --ignore-case --ignore-nonprinting \
			--field-separator=: --key=2	\
		| sed -e 's/:/">/'		\
		| sed -e 'sx^x</a></li><li><a href="x'	\
		>> ${.CURDIR}/$@

tst:	*.txt Makefile
	| sed -e 's/\044/<Za><Zli>/' \
	> ${.CURDIR}/$@

clean:
	rm -f index.lmth
	make index.lmth		# Else the web page is wrecked if absent
	make index.html		# Else the web page is wrecked if absent
	ls -l index.lmth index.html	# make sure its there

.include <berklix.mk>
