#   Chaos:		    The Chess HAppening Organisation System	V5.3
#   Copyright (C)   1993    Jochen Wiedmann
#
#   This program is free software; you can rdistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#   This is the Makefile (DMake 2.1)
#

VERSION=5_3

REVISION=3


############################################################################
#   No special CFLAGS, except full error-checking and debugging
#   You might include one of the following:
#	-DAMIGA 	  Create Amiga executable
#	-DDEBUG 	  Watch NULL pointers in strlen, strcpy, printf, ...
#	-DDEBUG_PAIRINGS  Trace the pairing groups using printf
#
#   No special LFLAGS, except debugging
#
############################################################################

############################################################################
#
#   Use the following to compile with Dice.
#
############################################################################

CC	    = dcc
CFLAGS	    = -c -3.0 -proto
#CDEBUG     = -s -d1 -DDEBUG
CDEBUG	    =
OPTIMIZE    =
SYMFILE     = Chaos.m
SYMCFLAGS   = -H$(SYMFILE)=Chaos.h

LN	    = dcc
LFLAGS	    = -3.0 -lmui -lm -lc -LPacked:MUI/Developer/C/DLib -o
LDEBUG	    = -s -d1
#LDEBUG    =
FROM	    =


############################################################################
#
#   Use the following to compile with SAS-C.
#
############################################################################

#CC	     = sc
#CFLAGS      = STACKCHECK UTILITYLIBRARY NOICONS STANDARDIO DEFINE AMIGA
#CDEBUG      = DEBUG=FULLFLUSH
##CDEBUG     =
#OPTIMIZE    =
##OPTIMIZE   = OPTIMIZE
#SYMFILE     = Chaos.gst
#SYMCFLAGS   = GLOBALSYMBOLTABLE $(SYMFILE)
#
#LN	     = slink
#LFLAGS      = FROM LIB:c.o LIBRARY LIB:amiga.lib LIBRARY LIB:scm.lib \
#	       LIBRARY LIB:sc.lib SMALLCODE SMALLDATA NOICONS TO
#LDEBUG      = ADDSYM
##LDEBUG     =
#FROM	     = FROM
#


############################################################################
#
#   Other binaries
#
############################################################################
CATCOMP=FlexCat
CI=Ci
CO=Co
GTEX=GTeX
TEX=TeX
TEXINDEX=TexIndex
RM=Delete quiet
MAKEINFO=MakeInfo
LHA=LhA
CP=Copy
MV=mv





############################################################################
#
#   You should not need to change anything below.
#
############################################################################

#   Object-files which need Chaos.h
SYMOBJ	    = main.o MainAmi.o Memory.o Project.o ProjectAmi.o Players.o \
	      PlayersAmi.o Pairings.o PairingsAmi.o Rounds.o RoundsAmi.o \
	      Out.o OutAmi.o OutDWZ.o ARexxAmi.o

#   Object-files which don't need Chaos.h
AUTOOBJ     = DWZtabs.o Chaos_Cat.o

#   Doc-files
DOC	    = /doc/Chaos_deutsch.dvi /doc/Chaos_deutsch.guide \
	      /doc/Chaos_english.dvi /doc/Chaos_english.guide

#   Supported ARexx scripts
AREXX	    = /rexx/ChaosWindowOn.rexx /rexx/ChaosWindowOff.rexx \
	      /rexx/LoadTournament.rexx /rexx/SaveTournament.rexx \
	      /rexx/PrintTable.rexx /rexx/UpdateRatings.rexx

RCS	    = $(AREXX) /Chaos.info /doc.info /COPYING.info /COPYING \
	      /Install /s/Chaos_Project.info /s/Chaos_Menu \
	      /Install.Deutsch.info /Install.English.info \
	      /doc/Chaos_deutsch.dvi.info /doc/Chaos_deutsch.guide.info \
	      /doc/Chaos_english.dvi.info /doc/Chaos_english.guide.info \
	      main.c MainAmi.c Memory.c Project.c ProjectAmi.c Players.c \
	      PlayersAmi.c Pairings.c PairingsAmi.c Rounds.c RoundsAmi.c \
	      Out.c OutAmi.c OutDWZ.c ARexxAmi.c DWZtabs.c Chaos.h \
	      Chaos.cd Deutsch.ct Chaos_deutsch.texinfo \
	      Chaos_english.texinfo


#   Distribution-files
DISTBIN     = Chaos.info Chaos/Chaos Chaos/rexx/ChaosWindowOn.rexx \
	      Chaos/rexx/ChaosWindowOff.rexx \
	      Chaos/rexx/LoadTournament.rexx \
	      Chaos/rexx/SaveTournament.rexx \
	      Chaos/rexx/PrintTable.rexx Chaos/rexx/UpdateRatings.rexx \
	      Chaos/Chaos.info Chaos/doc.info Chaos/COPYING.info \
	      Chaos/COPYING Chaos/Install Chaos/s/Chaos_Project.info \
	      Chaos/s/Chaos_Menu Chaos/Install.Deutsch.info \
	      Chaos/Install.English.info \
	      Chaos/doc/Chaos_deutsch.dvi Chaos/doc/Chaos_deutsch.dvi.info \
	      Chaos/doc/Chaos_deutsch.guide Chaos/doc/Chaos_deutsch.guide.info \
	      Chaos/doc/Chaos_english.dvi Chaos/doc/Chaos_english.dvi.info \
	      Chaos/doc/Chaos_english.guide Chaos/doc/Chaos_english.guide.info \
	      Chaos/catalogs/Deutsch/Chaos.catalog \
	      Chaos/Readme.mui Chaos/Readme.mui.info

DISTSRC     = Chaos/src/main.c Chaos/src/MainAmi.c Chaos/src/Memory.c \
	      Chaos/src/Project.c Chaos/src/ProjectAmi.c \
	      Chaos/src/Players.c Chaos/src/PlayersAmi.c \
	      Chaos/src/Pairings.c Chaos/src/PairingsAmi.c \
	      Chaos/src/Rounds.c Chaos/src/RoundsAmi.c \
	      Chaos/src/Out.c Chaos/src/OutAmi.c Chaos/src/OutDWZ.c \
	      Chaos/src/ARexxAmi.c Chaos/src/DWZtabs.c Chaos/src/Chaos.h \
	      Chaos/src/Chaos.cd Chaos/src/Deutsch.ct \
	      Chaos/src/Chaos_deutsch.texinfo \
	      Chaos/src/Chaos_english.texinfo Chaos/src/NewCatalog.ct \
	      Chaos/src/Chaos_Cat.c Chaos/src/Chaos_Cat.h \
	      Chaos/src/Makefile Chaos/src/NonAmiga.c Chaos/src/NonAmiga.h \
	      Chaos/src/PORTING



#   Main targets: all clean dist doc ci freeze
all: /Chaos doc /Catalogs/Deutsch/Chaos.catalog

clean: binclean
	$(RM) $(DOC) *.aux *.cp *.ky *.log *.pg *.toc *.tp *.vr *.cps \
	      Chaos_Cat.h Chaos_Cat.c

binclean:
	$(RM) *.o *.sym *.dbg *.m *.gst

dist: all
	cd //
	$(RM) chaos$(VERSION)bin.lha chaos$(VERSION)src.lha
	$(LHA) a -x chaos$(VERSION)bin.lha $(DISTBIN)
	$(LHA) a -x chaos$(VERSION)src.lha $(DISTSRC)

doc:	$(DOC)

ci:
	$(CI) -l$(REVISION) $(RCS)

freeze:
	rcs -nV$(FREEZEVERSION): $(RCS)


#   doc-Rules
/doc/Chaos_deutsch.guide: Chaos_deutsch.texinfo
	$(MAKEINFO) --amiga-39 --fill-column 76 \
		    --output Chaos_deutsch.guide Chaos_deutsch.texinfo
	$(RM) /doc/Chaos_deutsch.guide
	$(MV) Chaos_deutsch.guide /doc/Chaos_deutsch.guide

/doc/Chaos_english.guide: Chaos_english.texinfo
	$(MAKEINFO) --amiga-39 --fill-column 76 \
		    --output Chaos_english.guide Chaos_english.texinfo
	$(RM) /doc/Chaos_english.guide
	$(MV) Chaos_english.guide /doc/Chaos_english.guide

/doc/Chaos_deutsch.dvi: Chaos_deutsch.texinfo
	$(GTEX) Chaos_deutsch.texinfo
	$(TEXINDEX) Chaos_deutsch.cp
	$(GTEX) Chaos_deutsch.texinfo
	$(RM) /doc/Chaos_deutsch.dvi
	$(MV) Chaos_deutsch.dvi /doc/Chaos_deutsch.dvi
	$(RM) *.fn *.cp *.vr *.tp *.ky *.pg *.aux *.log *.toc *.cps

/doc/Chaos_english.dvi: Chaos_english.texinfo
	$(TEX) Chaos_english.texinfo
	$(TEXINDEX) Chaos_english.cp
	$(TEX) Chaos_english.texinfo
	$(RM) /doc/Chaos_english.dvi
	$(MV) Chaos_english.dvi /doc/Chaos_english.dvi
	$(RM) *.fn *.cp *.vr *.tp *.ky *.pg *.aux *.log *.toc *.cps


#   source-Rules
/Chaos: $(SYMOBJ) $(AUTOOBJ)
	$(LN) $(LFLAGS) /Chaos $(FROM) $(SYMOBJ) $(AUTOOBJ) $(LDEBUG)

main.o: main.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) main.c

MainAmi.o: MainAmi.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) MainAmi.c

Memory.o: Memory.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) Memory.c

Project.o: Project.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) Project.c

ProjectAmi.o: ProjectAmi.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) ProjectAmi.c

Players.o: Players.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) Players.c

PlayersAmi.o: PlayersAmi.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) PlayersAmi.c

Pairings.o: Pairings.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) Pairings.c

PairingsAmi.o: PairingsAmi.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) PairingsAmi.c

Rounds.o: Rounds.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) Rounds.c

RoundsAmi.o: RoundsAmi.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) RoundsAmi.c

Out.o: Out.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) Out.c

OutAmi.o: OutAmi.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) OutAmi.c

OutDWZ.o: OutDWZ.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) OutDWZ.c

ARexxAmi.o: ARexxAmi.c $(SYMFILE)
	$(CC) $(CDEBUG) $(OPTIMIZE) $(SYMCFLAGS) $(CFLAGS) ARexxAmi.c

DWZtabs.o: DWZtabs.c
	$(CC) $(CDEBUG) $(OPTIMIZE) $(CFLAGS) DWZtabs.c

Chaos_Cat.o: Chaos_Cat.c Chaos_Cat.h
	$(CC) $(CDEBUG) $(OPTIMIZE) $(CFLAGS) Chaos_Cat.c


#   Localizing stuff
Chaos_Cat.c: Chaos.cd C_c_V20.sd
	$(CATCOMP) Chaos.cd Chaos_Cat.c=C_c_V20.sd \
		   NEWCTFILE NewCatalog.ct

Chaos_Cat.h: Chaos.cd C_h.sd
	$(CATCOMP) Chaos.cd Chaos_Cat.h=C_h.sd

/Catalogs/Deutsch/Chaos.catalog: Chaos.cd Deutsch.ct
	$(CATCOMP) Chaos.cd Deutsch.ct CATALOG=/Catalogs/Deutsch/Chaos.catalog


#   Dice-specific
Chaos.m: Chaos.h Chaos_Cat.h
	$(RM) Chaos.m


#   SAS-specific
Chaos.gst: Chaos.h Chaos_Cat.h
	$(CC) $(CDEBUG) $(OPTIMIZE) $(CFLAGS) \
	      MAKEGLOBALSYMBOLTABLE Chaos.gst Chaos.h
