#
#   (AMIGA/SAS-C) Makefile for dvips
#

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

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

# for SYSV (and friends which use <string.h> instead of <strings.h>)
# define the c-compiler flag
# add -D_POSIX_SOURCE if you are POSIX (also define SYSV) (only relevant
# for subdir searching)
# SYS = -DSYSV

# Define this to be whatever you use for installation.  If you don't have
# install, use a script that invokes copy and chmod's the files
# appropriately.
# INSTALL = install
INSTALL = copy

# the default paper format, if other than letter.
# DEFPFMT = -DDEFPFMT=\"a4\"
DEFPFMT =

# where the installed binary goes
# BINDIR = /usr/bin
BINDIR = TeX:bin

# where the TFM files go
# TFMDIR = /usr/lib/tex/fonts/tfm
TFMDIR = TeX:fonts

# 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 = /LocalLibrary/Fonts/TeXFonts/tfm:$(TFMDIR)
TFMPATH = .,$(TFMDIR)

# where the PK files go.
# PKDIR = /usr/lib/tex/fonts/pk
PKDIR = TeX:pk

# 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 = /LocalLibrary/Fonts/TeXFonts/pk:$(PKDIR)
PKPATH = $(PKDIR)

# where the VF files go
# VFDIR = /usr/lib/tex/fonts/vf
VFDIR = TeX:vf

# the default path to search for VF files (usually omits `.')
# VFPATH = /LocalLibrary/Fonts/TeXFonts/vf:$(VFDIR)
VFPATH = $(VFDIR)

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

# where the config files go
# CONFIGDIR = /usr/lib/tex/ps
CONFIGDIR = TeX:config

# the default path to search for config files
# CONFIGPATH = .:$(CONFIGDIR)
CONFIGPATH = .,$(CONFIGDIR)

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

# where the header PS files go
# HEADERDIR = /usr/lib/tex/ps
HEADERDIR = tex:ps

# the default path to search for header files
# HEADERPATH = .:$(HEADERDIR)
HEADERPATH = .,$(HEADERDIR)

# where epsf.tex and rotate.tex go (usually the TeX macros directory)
# TEXMACRODIR = /usr/lib/tex/inputs
TEXMACRODIR = TeX:macros

# the default path to search for epsf and psfiles
# (usually the same as TeX's defaultinputpath)
# FIGPATH = .:..:/usr/lib/tex/inputs
FIGPATH = .,TeX:macros

# where the manual page goes
# MANDIR = /usr/local/text/man/man1
MANEXT = doc
MANDIR = man:

# add -DDEBUG to turn on debugging capability
# add -DTPIC for tpic support
# if the default resolution is not 300 dpi,
# add -DDEFRES=400 or whatever is required
# 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)
# AMIGA-PasTeX: add -DPASTEX to call Metafont via ARexx (CallMF funtions)
DEFS= -dTPIC -dDEBUG -dDEFRES=300 -dPASTEX

PASTEXSRC=amiga/rexx.c
PASTEXOBJ=amiga/rexx.o

# either use
# OPT = -g -Wall
# or
OPT = -O

# libraries to include (-lm -lc on most systems)
#FLIBS= -lNeXT_s -lsys_s
FLIBS= lib:lcm.lib lib:lc.lib

PATHS = -dTFMPATH="$(TFMPATH)" \
	-dPKPATH="$(PKPATH)" \
	-dVFPATH="$(VFPATH)" \
	-dHEADERPATH="$(HEADERPATH)" \
	-dCONFIGPATH="$(CONFIGPATH)" \
        -dCONFIGFILE="$(CONFIGFILE)" \
	-dFONTSUBDIRPATH="$(FONTSUBDIRPATH)" \
	-dFIGPATH="$(FIGPATH)"

#CFLAGS = $(DEFS) $(PATHS) $(OPT) $(SYS) $(SECURE) $(EMTEX) $(DEFPFMT)
# problems with command line length and $(PATH)
CFLAGS = $(DEFS) $(OPT) $(SYS) $(SECURE) $(EMTEX) $(DEFPFMT)

SRC = dospecial.c dviinput.c fontdef.c loadfont.c dvips.c tfmload.c \
	download.c prescan.c scanpage.c skippage.c output.c scalewidth.c \
	dosection.c dopage.c resident.c search.c unpack.c drawPS.c \
	header.c makefont.c repack.c virtualfont.c dpicheck.c finclude.c \
	flib.c $(PASTEXSRC)

OBJ = dospecial.o dviinput.o fontdef.o loadfont.o dvips.o tfmload.o \
	download.o prescan.o scanpage.o skippage.o output.o scalewidth.o \
	dosection.o dopage.o resident.o search.o unpack.o drawPS.o \
	header.o makefont.o repack.o virtualfont.o dpicheck.o finclude.o \
	flib.o $(PASTEXOBJ)

# files required to make a distribution
CONFIGFILES = config.ps psfonts.map
HEADERFILES = tex.lpro texc.script texps.lpro special.lpro finclude.lpro
FILES = $(CONFIGFILES) $(HEADERFILES) $(SRC) \
	Makefile INSTALLATION README rotsample.tex AGaramond-Demo.pfb \
	MakeTeXPK ../afm/Makefile epsf.tex epsf.sty rotate.tex rotate.sty \
        dvips.1 paths.h debug.h structures.h squeeze.c afm2tfm.c afm2tfm.1
LD = blink
LDFLAGS = FROM lib:c.o

all : afm2tfm dvips tex.pro texps.pro texc.pro special.pro finclude.pro

dvips : $(OBJ)
	$(LD) WITH amiga/dvips.lnk

afm2tfm: afm2tfm.c
	$(CC) -b0 $(CFLAGS) afm2tfm.c
	$(LD) TO afm2tfm FROM lib:c.o afm2tfm.o LIB $(FLIBS)


dvips.o		: dvips.c paths.h structures.h debug.h Makefile
dospecial.o	: dospecial.c structures.h debug.h Makefile
dviinput.o	: dviinput.c structures.h debug.h Makefile
fontdef.o	: fontdef.c structures.h debug.h Makefile
loadfont.o	: loadfont.c paths.h structures.h debug.h Makefile
dvips.o		: dvips.c structures.h debug.h Makefile
tfmload.o	: tfmload.c paths.h structures.h debug.h Makefile
download.o	: download.c structures.h debug.h Makefile
prescan.o	: prescan.c structures.h debug.h Makefile
scanpage.o	: scanpage.c structures.h debug.h Makefile
skippage.o	: skippage.c structures.h debug.h Makefile
output.o	: output.c structures.h debug.h Makefile
scalewidth.o	: scalewidth.c structures.h debug.h Makefile
dosection.o	: dosection.c structures.h debug.h Makefile
dopage.o	: dopage.c structures.h debug.h Makefile
resident.o	: resident.c paths.h structures.h debug.h Makefile
search.o	: search.c structures.h debug.h Makefile
unpack.o	: unpack.c structures.h debug.h Makefile
drawPS.o	: drawPS.c structures.h debug.h Makefile
header.o	: header.c structures.h debug.h Makefile
makefont.o	: makefont.c structures.h debug.h Makefile
repack.o	: repack.c structures.h debug.h Makefile
virtualfont.o	: virtualfont.c structures.h debug.h Makefile
dpicheck.o	: dpicheck.c structures.h debug.h Makefile
finclude.o	: finclude.c structures.h debug.h Makefile
flib.o		: flib.c paths.h structures.h debug.h Makefile

# PASTEX:
amiga/rexx.o	: amiga/rexx.c
	$(CC) $(CFLAGS) -oamiga/rexx.o amiga/rexx.c


squeeze : squeeze.o
	$(LD) TO squeeze FROM lib:c.o squeeze.o LIB $(FLIBS)

tex.pro : tex.lpro squeeze
	squeeze <tex.lpro > tex.pro

texc.pro: texc.lpro squeeze
	squeeze <texc.lpro >texc.pro

texc.lpro: texc.script tex.lpro
	rx amiga/texc.rexx tex.lpro texc.lpro

texps.pro : texps.lpro squeeze
	squeeze <texps.lpro >texps.pro

special.pro : special.lpro squeeze
	squeeze <special.lpro >special.pro

finclude.pro : finclude.lpro squeeze
	squeeze <finclude.lpro >finclude.pro

install : afm2tfm dvips MakeTeXPK \
	tex.pro texc.pro texps.pro special.pro finclude.pro \
	config.ps psfonts.map epsf.tex epsf.sty rotate.tex rotate.sty \
	dvips.1 afm2tfm.1
	- makedir $(BINDIR)
	- makedir $(HEADERDIR)
	- makedir $(CONFIGDIR)
	- makedir $(MANDIR)
	- makedir $(TEXMACRODIR)
	$(INSTALL) afm2tfm $(BINDIR)/afm2tfm
	$(INSTALL) dvips $(BINDIR)/dvips
	$(INSTALL) tex.pro $(HEADERDIR)
	$(INSTALL) texc.pro $(HEADERDIR)
	$(INSTALL) texps.pro $(HEADERDIR)
	$(INSTALL) special.pro $(HEADERDIR)
	$(INSTALL) finclude.pro $(HEADERDIR)
	$(INSTALL) config.ps $(CONFIGDIR)/$(CONFIGFILE)
	$(INSTALL) psfonts.map $(CONFIGDIR)
	$(INSTALL) epsf.tex $(TEXMACRODIR)
	$(INSTALL) epsf.sty $(TEXMACRODIR)
	$(INSTALL) rotate.tex $(TEXMACRODIR)
	$(INSTALL) rotate.sty $(TEXMACRODIR)
	-$(INSTALL) dvips.1 $(MANDIR)dvips.$(MANEXT)
	-$(INSTALL) afm2tfm.1 $(MANDIR)afm2tfm.$(MANEXT)

veryclean :
	delete \#?.o dvips squeeze afm2tfm texc.lpro \#?.pro \#?.bak \#?.log \#?.dvi \#?.info

clean :
	delete \#?.o squeeze afm2tfm \#?.bak \#?.log \#?.dvi

lint :
	lint $(DEFS) $(PATHS) $(SRC)
	lint $(DEFS) squeeze.c
	lint $(DEFS) afm2tfm.c
