#
#   Makefile for dvips on the ATARI machines with gcc
#

VER=5.58

# all machines with 68000:
TTV=ST
TTCOPT=
TTLOPT=

# all machines with 68030 && 68881:
#TTV=TT
#TTCOPT=-m68020 -m68881
#TTLOPT=-lgnu020

# all machines with 68030 but without 68881:
#TTV=Falcon
#TTCOPT=-m68020
#TTLOPT=

SHELL=c:\\bin\\mupfel.ttp

# compiler
CC=gcc

# All DIRs must use a single \ as a directory separator.
# All PATHs must use \\ as a directory separator

# the default path to search for TFM files 
# (this usually is identical to TeX's defaultfontpath, which omits `.')
# (private fonts are given an explicit directory, which overrides the path)
# TFMPATH = c:\\emtex\\tfm
TFMPATH=c:\\emtex\\tfm

# the default path to search for PK files (usually omits `.')
# Don't forget to add the directory that
# MakeTeXPK puts the files!  (In this case, /LocalLibrary/Fonts...)
# PKPATH = c:\\texfonts\\pixel.lj\\%ddpi\\%f.%p
PKPATH=c:\\texfonts\\pixel.lj\\%ddpi\\%f.%p

# the default path to search for VF files (usually omits `.')
# VFPATH = c:\\texfonts\\vf
VFPATH=c:\\texfonts\\vf

# additional directories in which to search for subdirectories to find
# both tfm and pk files
FONTSUBDIRPATH= 

# where the config files go
# CONFIGDIR = c:\emtex\ps
CONFIGDIR=c:\emtex\ps

# the default path to search for config files
# CONFIGPATH = .;c:\\emtex\\ps
CONFIGPATH=.;c:\\emtex\\ps

# the name of your config file
# CONFIGFILE = config.ps
CONFIGFILE=config.ps

# where the header PS files go
# HEADERDIR = c:\emtex\ps
HEADERDIR=c:\emtex\ps

# the default path to search for header files
# HEADERPATH = .;c:\\emtex\\ps
HEADERPATH=.;c:\\emtex\\ps

# where epsf.tex and rotate.tex go (usually the TeX macros directory)
# TEXMACRODIR = c:\emtex\texinput
TEXMACRODIR=c:\emtex\texinput

# the default path to search for epsf and psfiles
# (usually the same as TeX's defaultinputpath)
# FIGPATH = .;..;c:\\emtex\\texinput
FIGPATH=.;..;c:\\emtex\\texinput

# the default path to search for emTeX font libraries
# FLIPATH = c:\\texfonts
FLIPATH=c:\\texfonts

# the names of emTeX font libraries
# FLINAME = lj_0;lj_h;lj_1;lj_2;lj_3;lj_4;lj_5a;lj_5b;lj_sli
FLINAME=lj_0;lj_h;lj_1;lj_2;lj_3;lj_4;lj_5a;lj_5b;lj_sli

# change -DDEFRES=300 or whatever is required
#    if the default resolution is not 300 dpi,
# add -DDEBUG to turn on debugging capability
# add -DTPIC for tpic support
# add -DFONTLIB to search font libraries
# add -DSEARCH_SUBDIRECTORIES to search the FONTSUBDIRPATH.
# add -DHAVE_GETCWD if you have getcwd (relevant only for subdir searching)
# add -DCREATIONDATE if your system has a working time() and you want dated files
#   If you define FONTLIB, make sure to also give definitions to
#   FLIPATH and FLINAME.
#
DEFS=-DTPIC -DDEBUG -DDEFRES=300 -DFONTLIB -DCREATIONDATE

OPT=$(TTCOPT)

LINKOPT=-lpml $(TTLOPT) -lgem

# If you are compiling dvips for suid or other privileges, you will
# definitely want to define the following symbol; else don't.
# SECURE = -DSECURE
SECURE=

# If you want EMTEX specials, define the following.
EMTEX=-DEMTEX

# define the c-compiler flag
# -DMSDOS for MS-DOS systems
SYS=-DMSDOS

# where the installed binary goes
# BINDIR = c:\emtex
BINDIR=c:\emtex

# where the manual page goes
# MANDIR = c:\emtex\doc
MANDIR=c:\emtex\doc

#ATARI sets all paths in atari.h
CFLAGS=$(OPT) $(SYS) $(SECURE) $(EMTEX) $(DEFS) 

SRC=dospecia.c dviinput.c fontdef.c loadfont.c dvips.c tfmload.c \
	download.c prescan.c scanpage.c skippage.c output.c scalewid.c \
	dosectio.c dopage.c resident.c search.c unpack.c drawps.c \
	header.c makefont.c repack.c virtualf.c dpicheck.c finclude.c \
	pprescan.c papersiz.c flib.c color.c bbox.c emspecia.c \
	popen.c

OBJ=dospecia.o dviinput.o fontdef.o loadfont.o dvips.o \
        tfmload.o download.o prescan.o scanpage.o skippage.o \
        output.o scalewid.o dosectio.o dopage.o resident.o \
        search.o unpack.o drawps.o header.o makefont.o repack.o \
        virtualf.o dpicheck.o finclude.o \
        pprescan.o papersiz.o flib.o color.o bbox.o emspecia.o \
        popen.o

all : afm2tfm.ttp dvips.ttp tex.pro texps.pro texc.pro \
   special.pro finclude.pro color.pro crop.pro

# default rules

.SUFFIXES: .o .c

.c.o: 
	echo "compiling: $<"
	$(CC) -O -c $(CFLAGS) $<

dvips.ttp: $(OBJ)
	echo "Linking dvips.ttp"
	gcc -o dvips.ttp $(OBJ) $(LINKOPT)
	xstrip dvips.ttp
	cp dvips.ttp atari\$(TTV)

afm2tfm.ttp: afm2tfm.c atari/makefile
	echo "Making afm2tfm.ttp"
	$(CC) $(CFLAGS) afm2tfm.c -o afm2tfm.ttp $(LINKOPT) 
	xstrip afm2tfm.ttp
	cp afm2tfm.ttp atari\$(TTV)

atari.h: atari/makefile
	echo "Making ATARI-$(TTV)-Version of DVIPS"
	echo '#define TFMPATH "$(TFMPATH)"' > atari.h
	echo '#define PKPATH "$(PKPATH)"' >> atari.h
	echo '#define VFPATH "$(VFPATH)"' >> atari.h
	echo '#define HEADERPATH "$(HEADERPATH)"' >> atari.h
	echo '#define CONFIGPATH "$(CONFIGPATH)"' >> atari.h
	echo '#define CONFIGFILE "$(CONFIGFILE)"' >> atari.h
	echo '#define FONTSUBDIRPATH "$(FONTSUBDIRPATH)"' >> atari.h
	echo '#define FIGPATH "$(FIGPATH)"' >> atari.h
	echo '#define FLIPATH "$(FLIPATH)"' >> atari.h
	echo '#define FLINAME "$(FLINAME)"' >> atari.h
	echo '#undef BANNER' >> atari.h
	echo '#define BANNER "This is dvips $(VER) Copyright 1986, 1994 Radical Eye Software\n%%ATARI-$(TTV)-Version modified by Andreas_Schrell@rs.maus.de\n"' >> atari.h

$(OBJ) : atari.h dvips.h debug.h paths.h

squeeze.ttp : squeeze.c atari/makefile
	echo "Making squeeze.ttp"
	$(CC) $(CFLAGS) squeeze.c -o squeeze.ttp
	xstrip squeeze.ttp
	cp squeeze.ttp atari\$(TTV)

tex.pro : tex.lpro squeeze.ttp
	squeeze tex.lpro  tex.pro

texc.pro: texc.lpro squeeze.ttp
	squeeze texc.lpro texc.pro

texc.lpro: tex.lpro
	echo 'This does "texc.scr tex.lpro texc.lpro" on Unix'
	echo 'For MSDOS, copy tex.lpro to texc.lpro'
	echo 'then edit texc.lpro to remove the code'
	echo 'for uncompressed fonts and uncomment the'
	echo 'code for unpacking compressed fonts'

texps.pro : texps.lpro squeeze.ttp
	squeeze texps.lpro texps.pro

special.pro : special.lpro squeeze.ttp
	squeeze special.lpro special.pro

finclude.pro: finclude.lpro squeeze.ttp
	squeeze finclude.lpro finclude.pro

color.pro: color.lpro squeeze.ttp
	squeeze color.lpro color.pro

crop.pro: crop.lpro squeeze.ttp
	squeeze crop.lpro crop.pro

veryclean :
	rm -f *.o dvips.ttp squeeze.ttp afm2tfm.ttp *.pro atari.h

clean :
	rm -f *.o atari.h dvips.ttp
	
fixup:
	rename dosectio.c   dosection.c
	rename dospecia.c   dospecial.c
	rename emspecia.c   emspecial.c
	rename scalewid.c   scalewidth.c
	rename virtualf.c   virtualfont.c
	rename tex.lpr      tex.lpro
	rename texc.lpr     texc.lpro
	rename texps.lpr    texps.lpro
	rename special.lpr  special.lpro
	rename finclude.lpr finclude.lpro
	rename color.lpr    color.lpro
	rename crop.lpr     crop.lpro
