# 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/mmucl2
BIN_DIR = $(BASE_DIR)/bin

# Which tclsh to use.

TCLSH = tclsh

# Where info files are stored.

INFO_DIR = $(BASE_DIR)/share/info

# Location of install-info

INSTALL_INFO = /sbin/install-info

# Location of install

INSTALL = install

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

VERSION = 1.5.2

.PHONY: install all clean gzip dist rpm test

all: mmucl2 mmucl.tcl

install: mmucl2
	$(INSTALL) -d $(LIB_DIR)/lib $(LIB_DIR)/interface $(LIB_DIR)/images
	$(INSTALL) -d $(LIB_DIR)/script $(LIB_DIR)/script/contrib
	$(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 script/*.tcl script/*.rc $(LIB_DIR)/script
	$(INSTALL) -cm 0644 script/contrib/*.tcl $(LIB_DIR)/script/contrib
	$(INSTALL) -cm 0755 mmucl2 $(BIN_DIR)
	$(INSTALL) -cm 0644 mmucl.info $(INFO_DIR)
	$(INSTALL_INFO) $(INFO_DIR)/mmucl.info --info-dir=$(INFO_DIR)

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

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
	makeinfo --html --no-split mmucl.texinfo

clean:
	rm -f mmucl2 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
	rpmbuild -bb mmucl.spec 

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

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