#
#   Makefile for dvips.  Edit this first part of the file.
#
#   First, the things that absolutely must be edited for your system.

# modified for EMX-0.8g/GCC with NMAKE on OS/2 2.1.
# by rjl@monu1.cc.monash.edu.au
# 17th February 1994

# If using HPFS you may need to type 'nmake fixup' to truncate names.
# If using NDMAKE 4.5 under MS-DOS, PKPATH needs %% changed to %.
# If using Borland MAKER under MS-DOS, all paths need \\ changed to \\\\.

# compiler
EMXPATH = e:/emx
CC = gcc

# All DIRs must use a single \ as a directory separator.
# All PATHs must use \\ as a directory separator
DRIVE = c:
TEXDIR = $(DRIVE)\emtex
TEXPATH = $(DRIVE)\\emtex

# 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 = $(TEXPATH)\\tfm
TFMPATH = $(TEXPATH)\\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 = $(DRIVE)\\texfonts\\pixel.lj\\%ddpi\\%f.%p
PKPATH = $(DRIVE)\\texfonts\\pixel.lj\\%%ddpi\\%%f.%%p

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

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

# where the config files go
# CONFIGDIR = $(TEXDIR)\ps
CONFIGDIR = $(TEXDIR)\ps

# the default path to search for config files
# CONFIGPATH = .;$(TEXPATH)\\ps
CONFIGPATH = .;$(TEXPATH)\\ps

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

# where the header PS files go
# HEADERDIR = $(TEXDIR)\ps
HEADERDIR = $(TEXDIR)\ps

# the default path to search for header files
# HEADERPATH = .;$(TEXPATH)\\ps
HEADERPATH = .;$(TEXPATH)\\ps

# where epsf.tex and rotate.tex go (usually the TeX macros directory)
# TEXMACRODIR = $(TEXDIR)\texinput
TEXMACROPARENTDIR = $(TEXDIR)\texinput
TEXMACRODIR = $(TEXDIR)\texinput\dvips

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

# the default path to search for emTeX font libraries
# FLIPATH = $(DRIVE)\\texfonts
FLIPATH = $(DRIVE)\\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 -DFONTLIB -DDEFRES=300

OPT = -O -s

LINKOPT = -lm

# 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
# -DOS2 for OS/2 and MS-DOS with EMX extender
SYS = -DOS2

# where the installed binary goes
# BINDIR = c:\emtex
BINDIR = $(TEXDIR)

# where the manual page goes
# MANDIR = c:\emtex\doc
MANDIR = $(TEXDIR)\doc

#makefile.emx sets all paths in paths.rsp
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

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

all : afm2tfm.exe dvips32.exe tex.pro texps.pro texc.pro \
   special.pro finclude.pro color.pro crop.pro

# default rules

.SUFFIXES: .o .c

.c.o: 
	$(CC) -c $(CFLAGS) @paths.rsp $<

dvips32.exe: $(OBJ) gcclink.rsp
	$(CC) -o dvips32 @gcclink.rsp $(LINKOPT)
	emxbind $(EMXPATH)/bin/emx.exe dvips32 dvips32.exe -p

gcclink.rsp: pc/makefile.emx
	echo dospecia.o>gcclink.rsp
	echo dviinput.o>>gcclink.rsp
	echo fontdef.o>>gcclink.rsp
	echo loadfont.o>>gcclink.rsp
	echo dvips.o>>gcclink.rsp
	echo tfmload.o>>gcclink.rsp
	echo download.o>>gcclink.rsp
	echo prescan.o>>gcclink.rsp
	echo scanpage.o>>gcclink.rsp
	echo skippage.o>>gcclink.rsp
	echo output.o>>gcclink.rsp
	echo scalewid.o>>gcclink.rsp
	echo dosectio.o>>gcclink.rsp
	echo dopage.o>>gcclink.rsp
	echo resident.o>>gcclink.rsp
	echo search.o>>gcclink.rsp
	echo unpack.o>>gcclink.rsp
	echo drawPS.o>>gcclink.rsp
	echo header.o>>gcclink.rsp
	echo makefont.o>>gcclink.rsp
	echo repack.o>>gcclink.rsp
	echo virtualf.o>>gcclink.rsp
	echo dpicheck.o>>gcclink.rsp
	echo finclude.o>>gcclink.rsp
	echo pprescan.o>>gcclink.rsp
	echo papersiz.o>>gcclink.rsp
	echo flib.o>>gcclink.rsp
	echo color.o>>gcclink.rsp
	echo bbox.o>>gcclink.rsp
	echo emspecia.o>>gcclink.rsp

afm2tfm.exe: afm2tfm.c paths.rsp
	$(CC) $(CFLAGS) @paths.rsp afm2tfm.c -o afm2tfm $(LINKOPT) 
	emxbind $(EMXPATH)/bin/emx.exe afm2tfm afm2tfm.exe

paths.rsp: pc\makefile.emx
	echo -I$(EMXPATH)/include> paths.rsp
	echo -L$(EMXPATH)/lib>> paths.rsp
	echo -funsigned-char>> paths.rsp
	echo -DCREATIONDATE>> paths.rsp
	echo -DTFMPATH="$(TFMPATH)">> paths.rsp
	echo -DPKPATH="$(PKPATH)">> paths.rsp
	echo -DVFPATH="$(VFPATH)">> paths.rsp
	echo -DHEADERPATH="$(HEADERPATH)">> paths.rsp
	echo -DCONFIGPATH="$(CONFIGPATH)">> paths.rsp
	echo -DCONFIGFILE="$(CONFIGFILE)">> paths.rsp
	echo -DFONTSUBDIRPATH="$(FONTSUBDIRPATH)">> paths.rsp
	echo -DFIGPATH="$(FIGPATH)">> paths.rsp
	echo -DFLIPATH="$(FLIPATH)">> paths.rsp
	echo -DFLINAME="$(FLINAME)">> paths.rsp

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

squeeze.exe : squeeze.c paths.rsp
	$(CC) $(CFLAGS) @paths.rsp squeeze.c -o squeeze
	emxbind $(EMXPATH)/bin/emx.exe squeeze squeeze.exe

tex.pro : tex.lpr squeeze.exe
	squeeze tex.lpr  tex.pro

texc.pro: texc.lpr squeeze.exe
	squeeze texc.lpr texc.pro

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


texps.pro : texps.lpr squeeze.exe
	squeeze texps.lpr texps.pro

special.pro : special.lpr squeeze.exe
	squeeze special.lpr special.pro

finclude.pro: finclude.lpr squeeze.exe
	squeeze finclude.lpr finclude.pro

color.pro: color.lpr squeeze.exe
	squeeze color.lpr color.pro

crop.pro: crop.lpr squeeze.exe
	squeeze crop.lpr crop.pro

install : afm2tfm.exe dvips32.exe pc/maketexp.bat pc/maketexp.cmd \
	tex.pro texc.pro texps.pro special.pro finclude.pro color.pro crop.pro \
	pc/config.ps psfonts.map epsf.tex epsf.sty rotate.tex rotate.sty \
	dvips.tex dvipsmac.tex colordvi.sty colordvi.tex blackdvi.sty \
	blackdvi.tex pc/dvips.doc pc/afm2tfm.doc
	-mkdir $(BINDIR)
	-mkdir $(HEADERDIR)
	-mkdir $(CONFIGDIR)
	-mkdir $(MANDIR)
	-mkdir $(TEXMACROPARENTDIR)
	-mkdir $(TEXMACRODIR)
	copy afm2tfm.exe $(BINDIR)\afm2tfm.exe
	copy dvips32.exe $(BINDIR)\dvips32.exe
	copy pc\maketexp.bat $(BINDIR)\maketexp.bat
	copy pc\maketexp.cmd $(BINDIR)\maketexp.cmd
	copy tex.pro $(HEADERDIR)
	copy texc.pro $(HEADERDIR)
	copy texps.pro $(HEADERDIR)
	copy special.pro $(HEADERDIR)
	copy finclude.pro $(HEADERDIR)
	copy color.pro $(HEADERDIR)
	copy crop.pro $(HEADERDIR)
	copy pc\config.ps $(CONFIGDIR)\$(CONFIGFILE)
	copy psfonts.map $(CONFIGDIR)
	copy epsf.tex $(TEXMACRODIR)
	copy epsf.sty $(TEXMACRODIR)
	copy rotate.tex $(TEXMACRODIR)
	copy rotate.sty $(TEXMACRODIR)
	copy colordvi.sty $(TEXMACRODIR)
	copy colordvi.tex $(TEXMACRODIR)
	copy blackdvi.sty $(TEXMACRODIR)
	copy blackdvi.tex $(TEXMACRODIR)
	copy dvips.tex $(TEXMACRODIR)
	copy dvipsmac.tex $(TEXMACRODIR)
	copy pc\dvips.doc $(MANDIR)
	copy pc\afm2tfm.doc $(MANDIR)

veryclean :
	-del *.o
	-del dvips32.exe
	-del dvips32
	-del squeeze.exe
	-del squeeze
	-del afm2tfm.exe
	-del afm2tfm
	-del *.pro
	-del paths.rsp
	-del gcclink.rsp

clean :
	-del *.o
	-del dvips32
	-del squeeze.exe
	-del squeeze
	-del afm2tfm
	-del paths.rsp
	-del gcclink.rsp

	
# convert long names to 8.3 names
fixup:
	-rename dosection.c   dosectio.c
	-rename dospecial.c   dospecia.c
	-rename emspecial.c   emspecia.c
	-rename scalewidth.c  scalewid.c
	-rename virtualfont.c virtualf.c
	-rename tex.lpro      tex.lpr
	-rename texc.lpro     texc.lpr
	-rename texps.lpro    texps.lpr
	-rename special.lpro  special.lpr
	-rename finclude.lpro finclude.lpr
	-rename color.lpro    color.lpr
	-rename crop.lpro     crop.lpr
	-rename ..\PSlatex\avantgarde.sty avantgar.sty

# convert short 8.3 names to original long names
long:
	-rename dosectio.c   dosection.c
	-rename dospecia.c   dospecial.c
	-rename emspecia.c   emspecia..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
	-rename installa     INSTALLATION
	-rename maketexp     MakeTeXPK
	-rename config.lin   config.lino
	-rename config.pos   config.post3x3
	-rename rotsampl.tex rotsample.tex
	-rename ..\PSlatex\avantgar.sty  avantgarde.sty

# used for creating zip file
zip:
	copy ..\PSlatex\*.* $(TEXMACRODIR)
	-mkdir $(TEXDIR)\tfm
	copy ..\PStfms\*.* $(TEXDIR)\tfm
	-mkdir $(DRIVE)\texfonts
	-mkdir $(DRIVE)\texfonts\vf
	copy ..\PSvfs\*.* $(DRIVE)\texfonts\vf
	copy pc\README.pc $(DRIVE)\ 
	$(DRIVE)
	cd \ 
	dir /f /s /l emtex > emtex.lst
	dir /f /s /l texfonts >> emtex.lst
	remove -w emtex\remove\dvips.rem emtex.lst
	-del dvipsexe.zip
	zip -r dvipsexe README.pc emtex texfonts

# used for converting Unix EOL to OS/2 EOL
# when dvips.tar has been extracted under OS/2.
eol:
	-flip -m *.*
	cd contrib
	-flip -m *.*
	cd bbfig
	-flip -m *.*
	cd ..\psfig
	-flip -m *.*
	cd ..\psfntmac
	-flip -m *.*
	cd ..\pspic
	-flip -m *.*
	cd ..\..\mvs
	-flip -m *.*
	cd ..\pc
	-flip -m *.*
	cd ..\reencode
	-flip -m *.*
	cd ..\vmcms
	-flip -m *.*
	cd ..\vms
	-flip -m *.*
	cd ..
