#####################################################################
#                     MAKEFILE FOR TKSOL                            #
#####################################################################

           RM = rm -f
          SED = sed
        CHMOD = chmod
         ECHO = echo
        MKDIR = mkdir -p
      INSTALL = install -c -m 644

    BINSCRIPT = -e 's+@cardbitmaps@+$(CARDBITMAPS)+g' \
                -e 's+@downbitmaps@+$(DOWNBITMAPS)+g' \
                -e 's+@wish@+$(WISH)+g'

    MANSCRIPT = -e 's+@cardbitmaps@+$(CARDBITMAPS)+g' \
                -e 's+@downbitmaps@+$(DOWNBITMAPS)+g'

############################################
# Absolute pathname of the wish executable #
############################################
WISH = /usr/imports/bin/wish

####################################################
# Directory where the script tksol will be located #
####################################################
BINDIR = /homes/bao/src/test/tksol

#####################################################
# Directory where the tksol manpage will be located #
#####################################################
MANDIR = /homes/bao/src/man

####################################################################
# Directory where the bitmaps for the faceup cards will be located #
####################################################################
CARDBITMAPS = /homes/bao/src/test/tksol/cardbitmaps

######################################################################
# Directory where the bitmaps for the facedown cards will be located #
######################################################################
DOWNBITMAPS = /homes/bao/src/test/tksol/downbitmaps


all: tksol tksol.1

tksol: tksol.in Makefile
	$(SED) $(BINSCRIPT) tksol.in > tksol

tksol.1: tksol.man Makefile
	$(SED) $(MANSCRIPT) tksol.man > tksol.1

clean:
	$(RM) tksol tksol.1

install: instbin instman instbitmap

instbin: tksol
	-$(MKDIR) $(BINDIR)
	$(INSTALL) tksol $(BINDIR)/tksol
	$(CHMOD) a+x $(BINDIR)/tksol

instbitmap:
	@echo 'Installing bitmaps for faceup cards ...'
	-$(MKDIR) $(CARDBITMAPS)
	@cd cardbitmaps; \
            $(INSTALL) * $(CARDBITMAPS)
	@echo 'Installing bitmaps for facedown cards ...'
	-$(MKDIR) $(DOWNBITMAPS)
	@cd downbitmaps; \
            $(INSTALL) * $(DOWNBITMAPS)

instman: tksol.1
	-$(MKDIR) $(MANDIR)
	$(INSTALL) tksol.1 $(MANDIR)/tksol.1
