# ASTROLOG -*- Makefile -*- for Matt Dillon's nice DICE (Amiga)
#
# (c)Copyright 1995 by Tobias Ferber,  All Rights Reserved

# $VER: $Id: DMakefile,v 1.8 1995/08/11 12:17:02 tf Exp $

CC      = dcc
CFLAGS  = -3.1 -030 -882 -s
#CFLAGS  = -DMUIGUI -3.1 -030 -s

AS      = a68k
AFLAGS  = -d -Idinclude:amiga20/asm/

RM      = delete quiet
CP      = copy quiet clone

objs = astrolog.o data.o data2.o general.o io.o \
 calc.o matrix.o placalc.o placalc2.o \
 charts0.o charts1.o charts2.o charts3.o intrpret.o \
 xdata.o xgeneral.o xdevice.o xcharts0.o xcharts1.o xcharts2.o xscreen.o

xobjs = amiga.o rastport.o getkey.o xtras.o
#xobjs = amiga-mui.o getkey.o

srcs = $(objs:*.o:*.c) $(xobjs:*.o:*.c)
libs = -lm -lc -lamiga30
#libs = -lm -lc -lmuil -lamiga30
prog = astrolog

# for the documentation

stem        = astrolog
suffix      = texi
#suffix      = texinfo
makeguide   = makeguide --amiga-39
#makeguide   = makeinfo --amiga
guide2doc   = guide2doc
#guide2doc   = ag2txt
texindex    = texindex
tex         = virtex &tex
dvips       = dvips

# for the distribution

distfiles= astrolog.000 astrolog.030 astrolog.dat \
 Helpfile.440 Update.440 README.440 LRZ5_24 CHI_24 file_id.diz

arcname = ast44pl5
distdir = $(arcname)

#

all: $(prog)

$(prog): $(objs) $(xobjs) ellipse.o
	$(CC) $(CFLAGS) -mC $(libs) -o %(left) %(right)

$(objs) $(xobjs): $(srcs)
	$(CC) $(CFLAGS) -mC -mD -c -o %(left) %(right)

ellipse.o: ellipse.asm
	$(AS) %(right) $(AFLAGS) -o%(left)

# .PHONY targets

000:
	echo >ram:000.cvt "*"-030 -882*"->*"*";"
	cvt -s -f ram:000.cvt DMakefile -o %s.000
	delete quiet ram:000.cvt
	dmake -a -f DMakefile.000 astrolog
	rename astrolog astrolog.000

030:
	dmake -a astrolog
	rename astrolog astrolog.030

bumprev:
	execute cico

clean:
	$(RM) $(prog) $(objs) $(xobjs)
	$(RM) $(stem).(log|toc|aux|cp|fn|vr|ky|pg|au|cps|fns|vrs|kys|pgs|aus|tp) ShowDVI.log

veryclean: clean
	$(RM) $(prog).000 $(prog).030
	$(RM) $(stem).(guide|doc|dvi|ps) astdev.doc

# documentation

docs: guide index dvi ps

guide: $(stem).guide

$(stem).guide: $(stem).$(suffix)
	$(makeguide) -o %(left) %(right)

# $(tex) generiert die .(log|toc|aux|dvi) dateien

dvi: $(stem).dvi

$(stem).dvi: $(stem).$(suffix)
	$(tex) %(right)

ps: $(stem).ps

$(stem).ps: $(stem).dvi
	$(dvips) $(stem).dvi

# $(texindex) creates the #?.(cps|fns|vrs|kys|pgs|aus) files

index:
	$(texindex) $(stem).cp
	$(texindex) $(stem).fn
	$(texindex) $(stem).vr
	$(texindex) $(stem).ky
	$(texindex) $(stem).pg
	$(texindex) $(stem).au

book: $(stem).$(suffix)
	$(tex) $(stem).$(suffix)
	$(tex) $(stem).$(suffix)
	$(texindex) $(stem).cp
	$(texindex) $(stem).fn
	$(texindex) $(stem).vr
	$(texindex) $(stem).ky
	$(texindex) $(stem).pg
	$(texindex) $(stem).au
	$(tex) $(stem).$(suffix)

# autodocs

astdev.doc: amiga.c xtras.c rastport.c
	adoc -c -t -I -Wall -o %(left) #?.(c|h)

# This used to be the distribution target before we included source code and documentation

usrdist:
	mkdir $(distdir)
	$(CP) $(distfiles) $(distdir)/
	mkdir $(distdir)/doc
	$(CP) $(stem).$(suffix) $(stem).guide $(stem).dvi $(stem).ps astdev.doc $(distdir)/doc/
	mkdir $(distdir)/src
	$(CP) $(srcs) $(xobjs:"*.o":"*.c") ellipse.s ellipse.asm DMakefile Makefile Distfile $(distdir)/src/
	lha -a -e -r -x a $(arcname).lha $(distdir)
	delete all quiet $(distdir)

#

dist:
	mkdir $(distdir)-000 $(distdir)-030 $(distdir)-doc $(distdir)-src
        cpdist -D000 $(distdir)-000/
        cpdist -D030 $(distdir)-030/
        cpdist -DDOC $(distdir)-doc/
        cpdist -DSRC $(distdir)-src/
	lha -a -e -r -x a $(arcname)-000.lha $(distdir)-000
	lha -a -e -r -x a $(arcname)-030.lha $(distdir)-030
	lha -a -e -r -x a $(arcname)-doc.lha $(distdir)-doc
	lha -a -e -r -x a $(arcname)-src.lha $(distdir)-src
	delete all quiet $(distdir)-000 $(distdir)-030 $(distdir)-doc $(distdir)-src
	$(CP) readme.amiga $(arcname)-000.readme
	$(CP) readme.amiga $(arcname)-030.readme
	$(CP) readme.amiga $(arcname)-doc.readme
	$(CP) readme.amiga $(arcname)-src.readme

distclean:
	delete all quiet $(distdir)-(000|030|doc|src)(%|.lha|.readme)

#	tar cf $(arcname).tar $(distdir)
#	gzip -9 $(arcname).tar
