--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,39 @@
+SHELL=/bin/bash
+pkgdocdir=/usr/share/gap/pkg/nq/doc
+DOCDIR=$(DESTDIR)$(pkgdocdir)
+MKDIR=$(CURDIR)
+MANUAL=manual
+DIRS=.
+doc:
+	cd ..; echo 'PushOptions(rec(relativePath:="../../..")); \
+               Read("makedoc.g");' | \
+		gap -q -l 'debian/gaproot;/usr/share/gap';
+	ronn --roff -o ../ ../debian/anu-nq.ronn
+clean:
+	rm -f $(DIRS)/*.{html,txt,css,js}
+	rm -f $(DIRS)/make_manuals.out $(DIRS)/mathjax
+	rm -f $(DIRS)/$(MANUAL).{aux,bbl,blg,brf,idx,ilg,ind,log,out,pnr,toc.gz,dvi,pdf}
+	rm -f $(DIRS)/manual.{lab,six,six.gz}
+	rm -f title.xml nqbib.xml.bib
+	rm -f ../anu-nq.1
+install: install-pdf install-help install-html
+install-pdf:
+	test -d $(DOCDIR)/$(DIRS) || install -d $(DOCDIR)/$(DIRS)
+	set -e; for man in $(DIRS); do \
+	  install -o root -g root -m 0644 $$man/manual.pdf $(DOCDIR)/$$man;\
+	done
+install-help:
+	test -d $(DOCDIR)/$(DIRS) || install -d $(DOCDIR)/$(DIRS)
+	set -e; for man in $(DIRS); do \
+	  gzip -k --best --no-name $$man/manual.six; \
+	  install -o root -g root -m 0644 $$man/nqbib.xml $(DOCDIR)/$$man; \
+	  install -o root -g root -m 0644 $$man/nqbib.xml.bib $(DOCDIR)/$$man; \
+	  install -o root -g root -m 0644 $$man/manual.six.gz $(DOCDIR)/$$man; \
+	  install -o root -g root -m 0644 $$man/*.txt $(DOCDIR)/$$man; \
+	done
+install-html:
+	test -d $(DOCDIR)/$(DIRS) || install -d $(DOCDIR)/$(DIRS)
+	set -e; for man in $(DIRS); do \
+	  install -o root -g root -m 0644 $$man/*.{html,css,js} $(DOCDIR)/$$man;\
+	  ln -s `readlink mathjax` $(DOCDIR)/$$man/mathjax;\
+	done
