# Mark's MUd Client
############################################################

# Mmucl installs itself under BASE_DIR

BASE_DIR = /usr/local

# The startup script, mmucl, is put in BIN_DIR
# Everything else is put in LIB_DIR

LIB_DIR = $(BASE_DIR)/lib/mmucl
BIN_DIR = $(BASE_DIR)/bin

# Which tclsh to use.

TCLSH = tclsh8.2

# Where info files are stored.

INFO_DIR = $(BASE_DIR)/info

# Location of install-info

INSTALL_INFO = /sbin/install-info

# Location of install

INSTALL = install

###########################################################
# Don't edit anything beyond this point.

VERSION = 1.4.1

.PHONY: install all clean gzip dist rpm test

all: mmucl

install: mmucl
	$(INSTALL) -d $(LIB_DIR)/lib $(LIB_DIR)/interface $(LIB_DIR)/images
	$(INSTALL) -d $(BIN_DIR) $(INFO_DIR)
	$(INSTALL) -cm 0644 lib/*.tcl $(LIB_DIR)/lib	
	$(INSTALL) -cm 0644 images/*.gif $(LIB_DIR)/images
	$(INSTALL) -cm 0644 interface/*.tcl $(LIB_DIR)/interface
	$(INSTALL) -cm 0644 .tkconf $(LIB_DIR)
	$(INSTALL) -cm 0775 mmucl $(BIN_DIR)
	$(INSTALL) -cm 0644 mmucl.info $(INFO_DIR)
	$(INSTALL_INFO) $(INFO_DIR)/mmucl.info --info-dir=$(INFO_DIR)

mmucl: Makefile init
	echo "#! /bin/sh" > mmucl
	echo "# restart with tclsh \\" >> mmucl
	echo "exec $(TCLSH)" '"$$0" "$$@"' >> mmucl
	echo "" >> mmucl
	echo "array set config {" >> mmucl
	echo "lib_dir {$(LIB_DIR)}" >> mmucl
	echo "version {$(VERSION)}" >> mmucl
	echo "}" >> mmucl
	cat init >> mmucl
	chmod +x mmucl

mmucl.tcl: Makefile init
	echo "array set config {" > mmucl.tcl
	echo "lib_dir ." >> mmucl.tcl
	echo "version {$(VERSION)}" >> mmucl.tcl
	echo "}" >> mmucl.tcl
	cat init >> mmucl.tcl

mmucl.html: mmucl.texinfo
	texi2html -expandinfo -monolithic -menu $^

clean:
	rm -f mmucl mmucl.info mmucl.html mmucl.tcl

gzip:
	cd ..; tar cfvz mmucl-$(VERSION).tar.gz mmucl-$(VERSION) \
	--exclude CVS --dereference

rpm: gzip
	cp ../mmucl-$(VERSION).tar.gz /usr/src/redhat/SOURCES
	rpm -bb mmucl.spec 

test:
	$(TCLSH) mmucl.tcl --exec "cd test; source test.tcl"

dist: clean mmucl.tcl mmucl.info mmucl.html rpm
