# ------------------------------------------------------------------------
# LAST EDIT: Mon Oct 23 20:44:53 1995 by Christian Krone (gutamil.v12.de!krischan) 
# ------------------------------------------------------------------------
# $Id: Makefile,v 1.18 1995/10/27 00:15:21 krischan Exp $
# ------------------------------------------------------------------------

# ------------------------------------------------------------------------
# In welchen Pfad soll das ausfuehrbare Programm und wohin die Library?
# ------------------------------------------------------------------------
 BIN_DIR = /usr/bin/X11
 LIB_DIR = /usr/lib/X11/patience-1.8

# ------------------------------------------------------------------------
# Maschinen- und installationsabhaengiger Teil des Makefiles, dessen
# Variablendefinitionen evtl. den Gegebenheiten der aktuellen Umgebung
# bzw. den persoenlichen Praeferenzen angepasst werden muessen.
# Die genauere Bedeutung der Variablen steht im Handbuch, Abschnitt 5.
# ------------------------------------------------------------------------
 WISH = /usr/bin/wish

 TKLIBS = -L/usr/X386/lib -L/usr/lib/tcl -ltk -ltcl -lm -lX11
 CFLAGS = -O -I/usr/include/tcl
 CC = gcc

 WITH_NOWEB = test -z noweb

# ------------------------------------------------------------------------
# Im nun folgenden Teil des Makefiles sollten eigentlich keine Aenderungen
# mehr noetig sein, um die Patience zu portieren...
# ------------------------------------------------------------------------
# Copyright (c) 1995 Christian Krone, Varziner Str. 12, D-12161 Berlin
# All rights reserved.
# ------------------------------------------------------------------------
# Permission is hereby granted, without written agreement and without
# license or royalty fees, to use, copy, modify, and distribute this
# software and its documentation for any purpose, provided that the
# above copyright notice and the following two paragraphs appear in
# all copies of this software.
# ------------------------------------------------------------------------
# IN NO EVENT SHALL CHRISTIAN KRONE BE LIABLE TO ANY PARTY FOR DIRECT,
# INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
# OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF CHRISTIAN
# KRONE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------
# CHRISTIAN KRONE SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
# "AS IS" BASIS, AND CHRISTIAN KRONE HAS NO OBLIGATION TO PROVIDE
# MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
# ------------------------------------------------------------------------

 SRC = patience.nw
 SPR = spiel/canfield.spr spiel/klHarfe.spr spiel/standard.spr \
       spiel/streit.spr   spiel/spider.spr  spiel/seahaven.spr
 TCL = patience.tcl patsh.tcl regelEdit.tcl dppatd.tcl tclIndex
 TXT = app-default text/deutsch text/english
 DOC = manual/pat-deutsch.ps     manual/pat-english.ps    \
       manual/pat-deutsch.tty    manual/pat-english.tty   \
       manual/cat6/pat-deutsch.6 manual/cat6/pat-english.6

 FILES = patience-1.8/patience.tcl		\
	 patience-1.8/patsh.tcl			\
	 patience-1.8/regelEdit.tcl		\
	 patience-1.8/dppatd.tcl		\
	 patience-1.8/patsh.c			\
	 patience-1.8/tclIndex			\
	 patience-1.8/spiel			\
	 patience-1.8/text			\
	 patience-1.8/app-default		\
	 patience-1.8/bitmaps/icon		\
	 patience-1.8/bitmaps/normal		\
	 patience-1.8/Makefile			\
	 patience-1.8/README			\
	 patience-1.8/LIESMICH			\
	 patience-1.8/INSTALL-deutsch		\
	 patience-1.8/INSTALL-english		\
	 patience-1.8/patience.nw		\
	 patience-1.8/manual/pat-deutsch.tty	\
	 patience-1.8/manual/pat-english.tty	\
	 patience-1.8/manual/cat6/pat-deutsch.6	\
	 patience-1.8/manual/cat6/pat-english.6	\
	 patience-1.8/install.tcl

 FONTS = patience-1.8/bitmaps/sw		\
	 patience-1.8/bitmaps/gross		\
	 patience-1.8/bitmaps/goyette		\
	 patience-1.8/bitmaps/bunt		\
	 patience-1.8/bitmaps/sager		\
	 patience-1.8/bitmaps/traub

 MANS = patience-1.8/manual/pat-deutsch.ps	\
	 patience-1.8/manual/pat-english.ps	\
	 patience-1.8/manual/man6/pat-deutsch.6	\
	 patience-1.8/manual/man6/pat-english.6

.SUFFIXES: .nw .tex .dvi .tcl .spr .ps .ps .tty

patience : patience.tcl patsh.tcl regelEdit.tcl tclIndex Makefile
	@echo "Creating of the executable patience..."
	@echo "#!${WISH} -f"			>  patience
	@echo "set patienceVersion 1.8"         >> patience
	@echo "set patiencePath \"${LIB_DIR}\"" >> patience
	@cat  patience.tcl			>> patience
	@chmod a+x patience

patc : patience.tcl patsh Makefile
	@echo "Erzeugen der ausfuehrbaren Datei patc..."
	@echo "#!${LIB_DIR}/patsh -f"		>  patc
	@echo "set patienceVersion 1.8"         >> patc
	@echo "set patiencePath \"${LIB_DIR}\"" >> patc
	@cat  patience.tcl			>> patc
	@chmod a+x patc

dppatd : dppatd.tcl Makefile
	@echo "Creating of the executable dppatd..."
	@echo "#!${WISH} -f"			>  dppatd
	@echo "set patienceVersion 1.8"         >> dppatd
	@echo "set patiencePath \"${LIB_DIR}\"" >> dppatd
	@cat  dppatd.tcl			>> dppatd
	@chmod a+x dppatd

install : patience dppatd
	mv patience ${BIN_DIR}

installc : patc
	mv patc ${BIN_DIR}/patience

auslieferung : tclDateien regeln texte doc

tarfile : auslieferung
	@mv Makefile Makefile.org
	@sed -e '/^ ..._DIR/d'			\
	     -e 's/^#\(...\)_DIR/ \1_DIR/'	\
	     -e 's/test -z noweb/test -z noweb/'	\
	     -e 's/wish/wish/'		\
		 < Makefile.org > Makefile
	@tar cvfz /tmp/patience-1.8.tar.gz -C .. ${FILES} ${FONTS}
	@mv Makefile.org Makefile

manfile :
	@tar cvfz /tmp/patienceman-1.8.tar.gz -C .. ${MANS}

tclDateien : ${TCL}
patience.tcl  : patience.nw
	@if ${WITH_NOWEB}; then echo notangle patience.tcl; \
		notangle -Rpatience.tcl  patience.nw > patience.tcl; \
	 fi
tclIndex      : patience.nw
	@if ${WITH_NOWEB}; then echo notangle tclIndex; \
		notangle -RtclIndex      patience.nw > tclIndex; \
	 fi
patsh.tcl     : patience.nw
	@if ${WITH_NOWEB}; then echo notangle patsh.tcl; \
		notangle -Rpatsh.tcl     patience.nw > patsh.tcl; \
	 fi
regelEdit.tcl : patience.nw
	@if ${WITH_NOWEB}; then echo notangle regelEdit.tcl; \
		notangle -RregelEdit.tcl patience.nw > regelEdit.tcl; \
	 fi
dppatd.tcl    : patience.nw
	@if ${WITH_NOWEB}; then echo notangle dppatd.tcl; \
		notangle -Rdppatd.tcl    patience.nw > dppatd.tcl; \
	 fi
patsh.c       : patience.nw
	@if ${WITH_NOWEB}; then echo notangle patsh.c; \
		notangle -Rpatsh.c       patience.nw > patsh.c; \
	 fi

regeln : ${SPR}
spiel/standard.spr : patience.nw
	@if ${WITH_NOWEB}; then echo notangle spiel/standard.spr; \
		notangle -Rstandard.spr patience.nw > spiel/standard.spr; \
	 fi
spiel/canfield.spr : patience.nw
	@if ${WITH_NOWEB}; then echo notangle spiel/canfield.spr; \
		notangle -Rcanfield.spr patience.nw > spiel/canfield.spr; \
	 fi
spiel/klHarfe.spr  : patience.nw
	@if ${WITH_NOWEB}; then echo notangle spiel/klHarfe.spr; \
		notangle -RklHarfe.spr  patience.nw > spiel/klHarfe.spr; \
	 fi
spiel/streit.spr   : patience.nw
	@if ${WITH_NOWEB}; then echo notangle spiel/streit.spr; \
		notangle -Rstreit.spr   patience.nw > spiel/streit.spr; \
	 fi
spiel/spider.spr   : patience.nw
	@if ${WITH_NOWEB}; then echo notangle spiel/spider.spr; \
		notangle -Rspider.spr   patience.nw > spiel/spider.spr; \
	 fi
spiel/seahaven.spr : patience.nw
	@if ${WITH_NOWEB}; then echo notangle spiel/seahaven.spr; \
		notangle -Rseahaven.spr patience.nw > spiel/seahaven.spr; \
	 fi

texte : ${TXT}
text/deutsch	   : patience.nw
	@if ${WITH_NOWEB}; then echo notangle text/deutsch; \
		notangle -Rtext/deutsch patience.nw > text/deutsch; \
	 fi
text/english	   : patience.nw
	@if ${WITH_NOWEB}; then echo notangle text/english; \
		notangle -Rtext/english patience.nw > text/english; \
	 fi
app-default	   : patience.nw
	@if ${WITH_NOWEB}; then echo notangle app-default; \
		notangle -Rapp-default  patience.nw > app-default; \
	 fi

doc : ${DOC}

src_doc/patience.tex: patience.nw
	noweave -x patience.nw > src_doc/patience.tex

manual/cat6/pat-deutsch.6 : manual/pat-deutsch.tex
	manual/tex2rof < manual/pat-deutsch.tex > manual/man6/pat-deutsch.6
	groff -Tascii manual/man6/pat-deutsch.6 > manual/cat6/pat-deutsch.6
manual/cat6/pat-english.6 : manual/pat-english.tex
	manual/tex2rof < manual/pat-english.tex > manual/man6/pat-english.6
	groff -Tascii manual/man6/pat-english.6 > manual/cat6/pat-english.6

patsh : patsh.o
	${CC} patsh.o -o patsh ${TKLIBS}

clean : 
	@echo "Loeschen der z.Z. nicht bearbeiteten Quellen..."
	@for src in ${SRC}; do [ ! -w $$src ] && rm -f $$src; done; :
	@echo "Loeschen der z.Z. nicht bearbeiteten Spielregeln..."
	@for spr in ${SPR}; do [ ! -w $$spr ] && rm -f $$spr; done; :
	@echo "Loeschen der erzeugten Textdateien..."
	@rm -f ${TXT}
	@echo "Loeschen der erzeugten Tcl-Dateien..."
	@rm -f ${TCL}
	@echo "Loeschen des ausfuehrbaren Programms..."
	@rm -f patience patc patsh patsh.o
	@echo "Loeschen der erzeugten Dokumentationen..."
	@rm -f ${DOC}
	@echo "Loeschen aller sonstigen Zwischendateien..."
	@find . -print | egrep ".dvi|.aux|.log" | xargs rm -f

.tex.dvi:
	@echo "Rerun to get cross-references right" > $*.log
	@-while tail -15 $*.log |					\
              grep "Rerun to get cross-references right" > /dev/null;	\
        do (cd `dirname $*`; latex "\scrollmode \input `basename $*`"); done

.dvi.ps :
	@cd `dirname $*`; dvips -o `basename $*.ps` `basename $*.dvi`
.tex.tty :
	manual/tex2tty < $*.tex > $*.tty
