SHELL = /bin/sh

version_id = 2.0

distname = sunet-$(version_id)

distdir = /tmp

DISTFILES = COPYING README RELEASE \
	    Makefile packages.scm \
	    start-web-server \
	    httpd/*.scm ftpd/*.scm lib/*.scm \
	    doc/man.pdf doc/html \
	    doc/latex/*.tex doc/latex/*.sty doc/latex/*.t2p doc/latex/*.hdir \
	    web-server

sunet-$(version_id).tar.gz:

.PHONY: dist

dist:
	cd doc/latex && $(MAKE) html
	cd doc/latex && $(MAKE) man.pdf && cp -p man.pdf ..
	cd web-server/root/htdocs && ln -sf ../../../doc/html sunet-manual
	distname=$(distname) &&						\
	distfile=$(distdir)/$$distname.tar.gz &&			\
	if [ -d $(distdir) ] &&						\
	   [ -w $$distfile -o -w $(distdir) ]; then			\
		rm -f $$distname &&					\
		ln -s . $$distname &&					\
		files='' &&						\
		for i in $(DISTFILES); do				\
			if [ "$$i" != "c/sysdep.h" ]; then		\
				files="$$files $$distname/$$i";		\
			fi						\
		done &&							\
		tar --exclude .cvsignore --exclude CVS -cf - $$files |	\
			gzip --best >$$distfile &&			\
		rm $$distname;						\
	else								\
		echo "Can't write $$distfile" >&2;			\
		exit 1;							\
	fi