# wish location
WISH = /usr/local/bin/wish
# hfs location
HFSBIN = /usr/local/bin/hfs
#destination directory for tkhfs
BINDIR = /usr/local/bin

all: check

check:
	@if [ ! -s $(BINDIR) ]; then echo "Directory $(BINDIR) does not exist"; exit 1; fi
	@if [ ! -x $(WISH) ]; then echo "Can't find $(WISH)"; exit 1; fi
	@if [ ! -x $(HFSBIN) ]; then echo "Can't find $(HFSBIN)"; exit 1; fi

install: check
	@lib=`echo "puts [info library]"|tclsh`; \
	  if [ -f $$lib/FSBox.tcl ]; then echo "FSBox.tcl already in $$lib"; \
	  else echo "Copying FSBox.tcl in $$lib"; cp FSBox.tcl $$lib; fi
	@echo "installing tkhfs"
	@mkdir -p $(BINDIR)
	@sed -e s%/usr/local/bin/wish%$(WISH)% -e s%../hfs%$(HFSBIN)% \
		< tkhfs >$(BINDIR)/tkhfs
	@chmod ugo+x $(BINDIR)/tkhfs
	@echo install done
