# Generated automatically from Makefile.in by configure.
# This file is a Makefile for tkgoodstuff.  If it has the name
# "Makefile.in" then it is a template for a Makefile; to generate the
# actual Makefile, run "./configure", which is a configuration script
# generated by the "autoconf" program (constructs like "@foo@" will
# get replaced in the actual Makefile.

SHELL =			/bin/sh

VERSION =		8.0
prefix =		$(RPM_INSTALL)/usr
exec_prefix =		${prefix}

# Where to create the tkgoodstuff library directory 
TKG_LIBRARY =		$(prefix)/lib/tkgoodstuff

# Where to put the executable scripts (tkgoodstuff, Dialer)
BIN_INSTALL_DIR =	$(exec_prefix)/bin

# english or french 
TKG_LANGUAGE =		english

# e.g., tkgwish4.1
EXECSHELL =		/usr/bin/tkgwish$(VERSION)

SRCDIR =		.
TCLSH =			/usr/bin/tclsh8.0
INSTALL =		/usr/bin/install -c
INSTALL_PROGRAM =	${INSTALL}
INSTALL_DATA =		${INSTALL} -m 644

all: bins scripts

bins:
	@cd libs; $(MAKE)

scripts:
	@for f in tkgoodstuff Dialer Help; do\
	    echo "creating $$f.tmp";\
	      cat $(SRCDIR)/tcl/$${f}.tcl | \
	      sed -e "s%!/bin/sh%!$(EXECSHELL)%" | \
	      sed -e "s%^set\ TKG(libdir).*$$%set\ TKG(libdir)\ $(TKG_LIBRARY)%" | \
	      sed -e "s%^set\ TKG(language).*$$%set\ TKG\(language\)\ $(TKG_LANGUAGE)%" > $$f.tmp; \
	done

install: install-libs install-library

install-libs:
	@cd libs; make install $(prefix)=$(RPM_INSTALL)/usr

install-library: scripts
	@(test -d  $(TKG_LIBRARY) || \
	    (echo "Creating directory $(TKG_LIBRARY)"; \
	    $(INSTALL) -d $(TKG_LIBRARY)))
	@for dir in tcl doc icons sample-rc; do \
	    (test -d  $(TKG_LIBRARY)/$$dir || \
	        (echo "Creating directory $(TKG_LIBRARY)/$$dir"; \
	    $(INSTALL) -d $(TKG_LIBRARY)/$$dir)); \
	    for f in `/bin/ls $(SRCDIR)/$$dir`; do \
	        echo "Installing $(TKG_LIBRARY)/$$dir/$$f";\
	        $(INSTALL_DATA) $(SRCDIR)/$$dir/$$f $(TKG_LIBRARY)/$$dir;\
	    done ;\
	done
	@$(INSTALL_PROGRAM) $(SRCDIR)/Help.tmp $(TKG_LIBRARY)/tcl/Help.tcl
	@echo "Installing (and creating) $(TKG_LIBRARY)/tcl/tclIndex"
	@$(TCLSH) $(SRCDIR)/mktclindex $(TKG_LIBRARY)/tcl
	@(test -d  $(BIN_INSTALL_DIR) || \
	    (echo "Creating directory $(BIN_INSTALL_DIR)"; \
	    $(INSTALL) -d $(BIN_INSTALL_DIR)))
	@for f in tkgoodstuff Dialer; do\
	    echo "Installing $(TKG_LIBRARY)/$$f";\
	    $(INSTALL_PROGRAM) $$f.tmp $(TKG_LIBRARY)/$$f;\
	    echo "Installing $(BIN_INSTALL_DIR)/$$f";\
	    /bin/rm -f $(BIN_INSTALL_DIR)/$$f;\
	    $(INSTALL_PROGRAM) $$f.tmp $(BIN_INSTALL_DIR)/$$f;\
	done
	@echo
	@echo "tkgoodstuff installation completed."
	@echo

Makefile: $(SRCDIR)/Makefile.in $(SRCDIR)/libs/Makefile.in
	$(SHELL) $(SRCDIR)/configure

clean:
	@rm -f *.tmp
	@cd libs; $(MAKE) clean
	@echo
	@echo "Cleaning done."
	@echo

distclean:
	@rm -f config.* Makefile *.tmp
	@cd libs; $(MAKE) distclean
