#
#	Extra makefile targets
#
#	I couldn't be bothered to take the time to make these
#	play nicely with the horrid autoconf/configure mechanism.
#
include Makefile

NULL=

HTML= \
	index.html \
	linuxtrade.1.html \
	linuxtrade.1-*.png \
	TODO.txt \
	banner*.gif \
	screen*.gif \
	sound*.wav \
	screen*.html \
	ChangeLog.txt \
	linuxtrade.1.pdf \
	linuxlinks.gif \
	iwalk88x30_2.gif \
	fmlogo.gif \
	linuxapps.gif \
	version.txt \
	$(NULL)

REGHTML= \
	reggate.html \
	register.html \
	regprob.html \
	reg1.js \
	reg2.js \
	$(NULL)

RPM= \
	tmp/RPMS/i386/$(PACKAGE)-$(VERSION)-$(RPM_RELEASE).i386.rpm \
	$(NULL)

TARBALL=$(PACKAGE)-$(VERSION).tar.gz
CYGBALL=$(PACKAGE)-$(VERSION)-cygwin.tar.gz

BACKSITE=~/.ncftp-website
BACKDIR=backup/$(PACKAGE)
WEBSITE=~/.ncftp-linuxtrade
WEBDIR=.

#
#	Populate website
#
version.txt: configure.in
	echo "$(PACKAGE)-$(VERSION)-$(RPM_RELEASE)" > $@

.lastupload:
	touch -d 00/00/00 $@

.lastbeta:
	touch -d 00/00/00 $@

rmstamp:
	rm -f .lastupload

weball: rmstamp web

SRC=backup
SRC=src
web:	dist rpm $(HTML) linuxtrade.1.pdf .lastupload
	NFILES=`find $(HTML) -newer .lastupload`; \
	ncftpput -m -f $(WEBSITE) $(WEBDIR) $$NFILES \
	&& ncftpput -m -f $(WEBSITE) $(WEBDIR)/RPMS $(RPM) \
	&& ncftpput -m -f $(WEBSITE) $(WEBDIR)/$(SRC) $(TARBALL) \
	&& touch .lastupload
	./ncftpdir2html -f $(WEBSITE) $(WEBDIR)/RPMS > tmp/index.html \
		|| exit 1
	ncftpput -m -f $(WEBSITE) $(WEBDIR)/RPMS tmp/index.html;
	./ncftpdir2html -x -f $(WEBSITE) $(WEBDIR)/$(SRC) > tmp/index.html \
		|| exit 1
	ncftpput -m -f $(WEBSITE) $(WEBDIR)/$(SRC) tmp/index.html;

webhtml: $(HTML) .lastupload
	NFILES=`find  $(HTML) -newer .lastupload`; \
	ncftpput -m -f $(WEBSITE) $(WEBDIR) $$NFILES && touch .lastupload

webindex: index.html
	ncftpput -m -f $(WEBSITE) $(WEBDIR) index.html;

beta:	dist rpm $(HTML) linuxtrade.1.pdf .lastbeta
	NFILES=`find $(HTML) -newer .lastbeta`; \
	ncftpput -m -f $(WEBSITE) $(WEBDIR)/beta $$NFILES \
	&& ncftpput -m -f $(WEBSITE) $(WEBDIR)/beta/RPMS $(RPM) \
	&& touch .lastbeta

#
#	CygWin binary tarball (run this target under Cygwin)
#
cygwin:
	rm -rf /tmp/usr
	$(MAKE) install-strip prefix=/tmp/usr
	(cd /tmp; tar cvf - usr) | gzip > $(CYGBALL)

cygweb:
	mount-vmware;
	ncftpput -m -f $(WEBSITE) $(WEBDIR)/cygwin \
		/mnt/vmware/cygwin/home/rick/lt2/$(CYGBALL);
	./ncftpdir2html -f $(WEBSITE) $(WEBDIR)/cygwin > tmp/index.html \
		|| exit 1
	ncftpput -m -f $(WEBSITE) $(WEBDIR)/cygwin tmp/index.html;
	root umount /mnt/vmware;

#
#	compile farm
#
cf:	dist
	scp $(TARBALL) rickrich@shell.sf.net:

#
#	Source code backup
#
backup: rmold
	ncftpput -m -f $(BACKSITE) $(BACKDIR) $(PACKAGE)-$(VERSION).tar.gz;

rmold:
	./ncftprm -f $(BACKSITE) $(BACKDIR) '*.tar.gz'

#
#	Documentation
#
.SUFFIXES: .1 .pdf .html

GROFF=groff
GROFF=/usr/local/test/bin/groff

linuxtrade.1.pdf: linuxtrade.1 GNUmakefile
	$(GROFF) -t -man linuxtrade.1 | ps2pdf - $@

linuxtrade.1.html: linuxtrade.1 GNUmakefile
	$(GROFF) -P-Ilinuxtrade.1 -P-o0 -P-i100 -t -man -Thtml linuxtrade.1 \
		| sed 's#</table>#&<br>#' > $@ || rm $@

TODO.txt: TODO
	cp -a TODO $@

ChangeLog.txt: ChangeLog
	cp -a ChangeLog $@

#
#	Tag release
#
tag:
	TAG=`echo "v$(VERSION)_$(RPM_RELEASE)" | sed 's/\./_/'`; \
		cvs tag -F "$$TAG"

allclean: distclean
	-rm -rf tmp
	-rm -f linuxtrade*.tar.gz
	-rm -f linuxtrade.1*.png
	-rm -f linuxtrade.1.html
	-rm -f linuxtrade.1.pdf
	-rm -f ChangeLog.txt
	-rm -f TODO.txt
	-rm -f core core.*

sendlsm:
	mutt -s add LSM@execpc.com < linuxtrade.lsm
