# $Id: Makefile,v 35000.34 2003/05/27 01:54:18 hawkeye Exp $
########################################################################
#
#  TinyFugue - programmable mud client
#  Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2002, 2003 Ken Keys
#
#  TinyFugue (aka "tf") is protected under the terms of the GNU
#  General Public Licence.  See the file "COPYING" for details.
#
#  DO NOT EDIT THIS FILE.  To change the default configuration,
#  see "unix/README".
#
########################################################################

# unix Makefile.
# This is invoked from top level make, so the working directory is the root.

SHELL = /bin/sh

default: files
# If the next rule were first, a few strange versions of make would try
# to make "install", "all", AND "files", instead of just "install".

install all files: src/Makefile src/config.h _log
	cd ./src; { $(MAKE) $@ 2>&1; echo; cat exitmsg; } | \
	    { tee -a ../Build.log || cat; }

configure: configure.in
	autoconf

reconfigure:  unconfigure install

unconfigure:
	rm -f src/Makefile src/config.h

config src/Makefile src/config.h: Makefile unix/Config unix/tfconfig unix/unix.mak
	@rm -f ../src/Makefile ../src/config.h ../Build.log tfconfig.log
#	Use tfconfig to create config files.  If it fails, we don't exit
#	now, we want to create Build.log first.  Instead, we rm src/Makefile
#	but not src/config.h;  this lets 'install' continue on to '_log'.
#	('install' probably got here via the src/Makefile dependancy; if we
#	rm'd src/config.h, then 'install' would come back here again for the
#	src/config.h dependancy.)  Then, '_log' will create Build.log and,
#	if an error occured in this rule, '_log' will exit.
#	Note: tee eats exit code of tfconfig, so we couldn't use it anyway.
#	Note: some buggy versions of bash can't handle using descriptor 3 here.
	-@cd unix; \
		{ ./tfconfig $(TFVER) 2>&1 4>../src/config.h 5>vars.mak || \
		rm -f ../src/Makefile; } | \
			tee tfconfig.log

_log:
	-@{ cat unix/tfconfig.log; echo; } > Build.log
#	Exit now if there were errors in tfconfig.
	@test -f src/Makefile && test -f src/config.h
#	No errors.  Save info in Build.log, and continue.
	-@{ cat unix/vars.mak; echo; } >> Build.log
	-@{ cat src/config.h; echo; } >> Build.log

clean:
	cd ./src; rm -f *.o Makefile core* exitmsg config.h typescript*
	cd ./unix; rm -f vars.mak *.log functest* libtest* test.c a.out

distclean:  clean
	rm -f Build.log
#	cd ./tf-lib; rm -f tf-help.idx
	cd ./src; rm -f tf makehelp tags
	cd ./src; rm -f tf.pixie* tf.Addrs* tf.Counts*

spotless cleanest veryclean:  distclean
	cd ./src; rm -f tf.1.catman

uninstall:
	cd ./src; $(MAKE) uninstall

./src/tf.1.catman:  ./src/tf.1.nroffman
	TERM=vt100; nroff -man ./src/tf.1.nroffman > ./src/tf.1.catman

srcdist: ./src/tf.1.catman

help ./tf-lib/tf-help ./tf-lib/tf-help.idx: __always__
	if test -d ./help; then cd ./help; $(MAKE); fi

bogus-makefile:
	cp bogus.mak Makefile

disttest: __always__
	@{ test ! -d CVS && test "`basename \`pwd\``" = "tf-$(TFVER)"; } || \
	    { echo '"make dist" should be run from a CVS exported directory.'; \
	    false; }

dist: disttest srcdist distclean help bogus-makefile configure
	chmod -R ugo+r .
	cd ..; tar -zcf tf-$(TFVER).tar.gz -X tf-$(TFVER)/EXCLUDE tf-$(TFVER)
	cd ..; zip -qlr tf-$(TFVER).zip tf-$(TFVER) \
	    -x `sed -e 's;^;tf-$(TFVER)/;' tf-$(TFVER)/EXCLUDE`
	ln -s help tf-$(TFVER)-help
	tar -zcf tf-$(TFVER)-help.tar.gz tf-$(TFVER)-help/. --exclude 'html2tf*'
	rm tf-$(TFVER)-help
	mv tf-$(TFVER)-help.tar.gz ..

gzdist: ./tf-lib/tf-help ../tf-$(TFVER).tar
	cd ..; gzip tf-$(TFVER).tar

tcp.com:
	cd ..; scp tf-$(TFVER).tar.gz tf-$(TFVER).zip tf-$(TFVER)-help.tar.gz \
	    tcp.com:

# XXX
laurel: devhome files
	cp CHANGES $$HOME/www/tf/

__always__:

# hack to get around a bug in BSDi (and FreeBSD?) make.
make:

