release_timestamp: VERSION
	mkdir RELEASE
	test "`cat VERSION`" != "`head -1 release_timestamp`"
	echo "`cat VERSION`" > release_timestamp
	DATE=`LC_ALL= ;LANG= ;date` \
        && echo $$DATE >>release_timestamp \
        && cvs commit -m "* New release `cat VERSION` at $$DATE" release_timestamp
	cp Makefile.release RELEASE \
	&& cd RELEASE \
	&& cvs co cardwords \
	&& make -f Makefile.release in_release_directory

in_release_directory: 
	#
	# Check if we are in the right directory:
	# ---------------------------------------
	pwd | grep /RELEASE$$
	#
	# We are in the right directory.
	#
	# Make the "upload" directory and store the scripts for automated ftp
	# upload in there:
	# -------------------------------------------------------------------
	mkdir upload                 # Dir for script for ftp-upload
	mv cardwords/ftplib.? upload # files not being released
	mv cardwords/cardwords_upload.c upload # -"-
	mv cardwords/cardwords_upload.sh upload
	chmod 400 upload/cardwords_upload*
	(cd cardwords && make cardwords_version.hh) # Needed for upload
	mv cardwords/cardwords_version.hh upload
	cc -o upload/cardwords_upload upload/*.c # test if compiles
	rm -f upload/cardwords_upload
	#
	# Make the "source" directory and store all packages there for upload:
	# --------------------------------------------------------------------
	mkdir source
	(cd cardwords && make doc)
	mv cardwords/README.html . # Creates the README.html directory.
	tar cf source/README.html.tar README.html
	gzip -9 source/README.html.tar
	mv cardwords/README.ps source
	gzip -9 source/README.ps
	cp cardwords/COPYING source
	#
	# Make the screenshots directory:
	# -------------------------------
	mkdir screenshots
	mv cardwords/cardwords_gtk.png screenshots
	#
	# Removing files that are not needed in the distributed package:
	# --------------------------------------------------------------
	rm -r cardwords/CVS
	rm cardwords/freshmeat_announce.txt
	(cd cardwords && make cleaner)
	rm -f cardwords/cardwords_upload.expect
	rm -f cardwords/compiler_error.cc
	rm -f cardwords/2namespace.sed
	#
	# Make the .tar.gz source package:
	# --------------------------------
	tar cf `(echo -n "source/cardwords-"; cat cardwords/VERSION; echo -n ".tar")` cardwords
	gzip -9 source/cardwords-*.tar
	#
	# Create the lsm file:
	# --------------------
	(cd cardwords && make -f Makefile.release lsm)
	mv cardwords/cardwords-*.lsm source
	#
	# Create the homepage file (index.html):
	# --------------------------------------
	(cd cardwords && m4 --prefix-builtins <index.html.m4 >../index.html)
	#
	# Remove the uncompressed distribution and the currently executed
	# Makefile.release:
	# ---------------------------------------------------------------
	rm -rf cardwords
	rm Makefile.release
	#
	# The RELEASE directory is complete.
	# ----------------------------------
lsm:
	(LC_ALL= ; LANG= ;m4 --prefix-builtins <lsm.m4 >`echo -n "cardwords-" && cat VERSION && echo -n ".lsm"`)
