diff --git a/doc/Makefile.am b/doc/Makefile.am
index 7d3dcf41e6168b3ca0ecd0421380a56fb9dc4a52..bcb8914afb8ab6315c79ac5cf2dd6a66ce900fea 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.19 1999/06/26 21:56:56 ceder Exp $
+# $Id: Makefile.am,v 1.20 2001/04/16 18:16:32 ceder Exp $
 # Copyright (C) 1998-1999  Lysator Academic Computer Association.
 #
 # This file is part of the LysKOM server.
@@ -54,4 +54,133 @@ SUFFIXES = .texi .notab
 	@# ugly.  Ban tabs.
 	$(RM) $@
 	if grep -n '	' $< /dev/null ; then echo tabs detected ; exit 1; fi
+	gawk 'length($0) > 79 {print FILENAME ":" NR ": too long line"; e=1} \
+		END {exit(e)}' $<
 	echo no tabs found > $@
+
+# The stuff below is used to update the official WWW pages at
+# http://www.lysator.liu.se/lyskom/protocol/
+WWWROOT=/lysator/www/www-pages/html/lyskom/protocol
+PROTOEDITION=`sed -n 's/^@set PROTOEDITION //p' < $(srcdir)/Protocol-A.texi`
+WWWREV=$(WWWROOT)/$(PROTOEDITION)
+update-www: protocol-a.info Protocol-A.dvi Protocol-A.pdf
+	cd $(WWWROOT) || false
+	rm -rf $(WWWREV)
+	mkdir $(WWWREV)
+	tar cvf $(WWWROOT)/Protocol-A-$(PROTOEDITION)-info.tar.gz protocol-a.info*
+	cp $(srcdir)/Protocol-A.texi $(WWWROOT)/Protocol-A-$(PROTOEDITION).texi
+	cp Protocol-A.dvi $(WWWROOT)/Protocol-A-$(PROTOEDITION).dvi
+	cp Protocol-A.pdf $(WWWROOT)/Protocol-A-$(PROTOEDITION).pdf
+	ln -s ../Protocol-A-$(PROTOEDITION).texi $(WWWREV)/Protocol-A.texi
+	(cd $(WWWREV) && texi2html -glossary -menu -split_node Protocol-A.texi)
+	echo "Don't forget to edit $(WWWROOT)/index.html"
+
+Protocol-A.pdf: Protocol-A.texi
+	texi2pdf $(srcdir)/Protocol-A.texi
+
+check: check-doc
+
+check-doc: Protocol-A.notab lyskomd.notab
+	# Create a list of all aux-items.
+	sed -n 's/[0-9][0-9]* : \([^ ]*\) (.*/\1/p' \
+		$(top_srcdir)/run-support/aux-items.conf \
+	| tee aux-items.tmp \
+	| sed 's/.*/^@aux{&}$$/' \
+	> aux-items-@.tmp
+
+	# Create a list of all requests.
+	sed '/^#/d' $(top_srcdir)/src/server/fncdef.txt \
+	| awk '{print $$3}' \
+	| sed 's/_/-/g' \
+	| tee requests.tmp \
+	| sed 's/.*/^@req{&}$$/' \
+	> requests-@.tmp
+
+	# Create a list of all async messages.
+	sed -n -e '/#if 0/,/#endif/d' \
+	       -e 's/[ 	]*ay_\([^ ]*\) =.*/async_\1/p' \
+	       $(top_srcdir)/src/server/async.h \
+	| sed 's/_/-/g' \
+	| tee asyncs.tmp \
+	| sed 's/.*/^@async{&}$$/' \
+	> async-@.tmp
+
+	# Create a list of all miscinfos.
+	tac $(top_srcdir)/src/include/kom-types.h \
+	| sed -e '/} Info_type/,/typedef/!d' \
+	| sed -n -e 's/[ 	]*\([^ ]*\)[ 	][ 	]*=.*/\1/p' \
+	| sed 's/_/-/g' \
+	| grep -v unknown-info \
+	| tee miscs.tmp \
+	| sed 's/.*/^@misc{&}$$/' \
+	> miscs-@.tmp
+
+	# Create a list of all conf-type bits.
+	tac $(top_srcdir)/src/include/kom-types.h \
+	| sed -e '/} Conf_type/,/typedef/!d' \
+	| sed -n -e 's/.*unsigned int[ 	]*\([^ 	:]*\)[ 	]*:.*/\1/p' \
+	| sed -e 's/_/-/g' \
+	      -e 's/allow-anon/allow-anonymous/' \
+	      -e 's/letter-box/letterbox/' \
+	| grep -v reserved \
+	| tee conftypes.tmp \
+	| sed 's/.*/^@conftype{&}$$/' \
+	> conftypes-@.tmp
+
+	# Create a list of all types.  We do this from the
+	# documentation, and not the source, since the source has its
+	# own funny names in a few places.
+	sed -n 's/@tindex //p' < $(srcdir)/Protocol-A.texi \
+	| tee types.tmp \
+	| sed 's/.*/^@type{&}$$/' \
+	> types-@.tmp
+
+	# Create a list of all @x{}-constructs used.
+	sed -e '/^@c /d' \
+	    -e '/^@c$$/d' \
+	    -e '/^@comment /d' \
+	    -e '/^@macro /,/@end macro/d' \
+	    -e 's/@{//g' \
+	    -e 's/@}//g' \
+	    -e "`echo s/@/\\\\  ;echo @/g`" \
+	    $(srcdir)/Protocol-A.texi \
+	| sed -n 's/\(@[^{}]*{[^}]*}\).*/\1/p' \
+	| sort \
+	| uniq \
+	> constructs.tmp
+
+	# Remove the expected stuff.  @rarg{} and @aarg{} constructs
+	# are checked below, so ignore them here.  Various @ref
+	# constructs are checked by makeinfo, so we ignore them as
+	# well.  @t{} are not interresting.
+	# FIXME: @errocode{} should be checked.
+	# FIXME: @field{} should be checked.
+	# FIXME: @priv{} should be checked.
+	cat constructs.tmp \
+	| grep -v '@rarg{' \
+	| grep -v '@aarg{' \
+	| grep -v '@ref{' \
+	| grep -v '@xref{' \
+	| grep -v '@pxref{' \
+	| grep -v '@t{' \
+	| grep -v '@footnote{' \
+	| grep -v '@errorcode{' \
+	| grep -v '@field{' \
+	| grep -v '@priv{' \
+	| grep -v \
+	    -f aux-items-@.tmp \
+	    -f requests-@.tmp \
+	    -f types-@.tmp \
+	    -f async-@.tmp \
+	    -f miscs-@.tmp \
+	    -f conftypes-@.tmp \
+	> constructs-@.tmp
+	# If the diff command below finds any differences, you have to
+	# check that they are expected, and then manually update
+	# constructs.expected.  Please be careful when you examine the
+	# diff.
+	diff -u $(srcdir)/constructs.expected constructs-@.tmp
+
+	# Check @rarg{} and @karg{} constructs.  They are only allowed
+	# to refer to named arguments of the call they are documenting.
+	# FIXME