#   Makefile for dvips.  Edit this first part of the file.
#
# modified for NMAKE 2 and EMX-0.8f/GCC on OS/2
# by rabe@mathematik.uni-bielefeld.de
# April, 12th 1993

# Attention: TABs als rule separators and writing rights in root dir required!

#   First, the things that absolutely must be edited for your system.


# use these definitionf for a production version
DEBUGFLAG = -s
OPTFLAG = -O2
ZFLAGS = -Zmt -Zomf
OX  = .obj
#
# use these definitions for debugging
# DEBUGFLAG = -g3
# OPTFLAG = 
# ZFLAGS =
# OX  = .o


# All DIRs must use a single \ as a directory separator.
# All PATHs must use \\ as a directory separator
# All '%' in strings (PKPATH) must be represented by '%%'


# Default drive for dvips/emTeX etc.
DRIVE = d:
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)
#   overridden by the environment variable TEXFONTS
# TFMPATH = c:\\emtex\\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...)
#   overridden by the environment variable TEXPKS or TEXPACKED or PKFONTS
# PKPATH = c:\\texfonts\\pixel.lj\\%ddpi\\%f.%p
PKPATH = \"$(DRIVE)\\texfonts\\pixel.lj\\%%ddpi\\%%f.%%p\"

# the default path to search for VF files (usually omits `.')
#   overridden by the environment variable VFFONTS
# VFPATH = c:\\texfonts\\vf
VFPATH = \"$(TEXPATH)\\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 = $(TEXDIR)\ps

# the default path to search for config files
#   overridden by the environment variable TEXCONFIG
# CONFIGPATH = .;c:\\emtex\\ps
CONFIGPATH = \".;$(TEXPATH)\\ps\"

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

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

# the defaultpath to search for header files
# HEADERPATH = .;c:\\emtex\\ps
HEADERPATH = \".;$(TEXPATH)\\ps\"

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

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

# the default path to search for emTeX font libraries
# FLIPATH = c:\\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_5;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 -DIBM6000 for compiling on IBM 6000 systems
# add -DCREATIONDATE if your system has a working time() and you want dated files
# (for VM/CMS, see the MKDVIPS.EXEC file in the vmcms subdirectory).
#
#   If you define FONTLIB, make sure to also give definitions to
#   FLIPATH and FLINAME.
#   For use with emTeX you may also want to set FONTPATH to "TEXTFM"
#
DEFS= -DTPIC -DDEBUG -DDEFRES=300 -DCREATIONDATE -DFONTLIB -DFONTPATH=\"TEXTFM\"

# your compiler
CC = gcc -Wall

# either use
# OPT = -g -Wall -funsigned-char
# or
# OPT = -O -s -Wall -funsigned-char
OPT = -funsigned-char $(DEBUGFLAG) $(OPTFLAG) $(ZFLAGS)
# libraries to include (-lm -lc on most systems)
#FLIBS= -lNeXT_s -lsys_s
#FLIBS= -lm -lc
FLIBS=

# 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

# 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)
# add -DOS2 for OS/2 32 bit (V2.x) (needs -DSYSV also)
# add -DMSDOS for MS-DOS systems (needs -DSYSV also)
# add -DDJGPP for MS-DOS GNU gcc's
SYS = -DSYSV -DOS2

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

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


PATHS = -DTFMPATH=$(TFMPATH) \
	-DPKPATH=$(PKPATH) \
	-DVFPATH=$(VFPATH) \
	-DHEADERPATH=$(HEADERPATH) \
	-DCONFIGPATH=$(CONFIGPATH) \
	-DCONFIGFILE=\"$(CONFIGFILE)\" \
	-DFONTSUBDIRPATH=$(FONTSUBDIRPATH) \
	-DFIGPATH=$(FIGPATH) \
	-DFLIPATH=$(FLIPATH) \
	-DFLINAME=$(FLINAME)

CFLAGS = $(DEFS) $(OPT) $(SYS) $(SECURE) $(EMTEX)

# default rules
.c$(OX):
	$(CC) -c $(CFLAGS) $<

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 \
	pprescan.c papersiz.c flib.c color.c bbox.c emspecial.c

OBJ = dospecial$(OX) dviinput$(OX) fontdef$(OX) loadfont$(OX) dvips$(OX) \
	tfmload$(OX) download$(OX) prescan$(OX) scanpage$(OX) skippage$(OX) \
	output$(OX) scalewidth$(OX) dosection$(OX) dopage$(OX) resident$(OX) \
	search$(OX) unpack$(OX) drawPS$(OX) header$(OX) makefont$(OX) \
	repack$(OX) virtualfont$(OX) dpicheck$(OX) finclude$(OX) \
	pprescan$(OX) papersiz$(OX) flib$(OX) color$(OX) bbox$(OX) \
	emspecial$(OX)

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

dvips.exe: $(OBJ)
	$(CC) $(CFLAGS) $(OBJ) $(LIBS) $(FLIBS) -o dvips.exe

dvips$(OX): dvips.c
	$(CC) -c $(CFLAGS) $(PATHS) dvips.c

afm2tfm.exe: afm2tfm.c
	$(CC) $(CFLAGS) -o afm2tfm.exe afm2tfm.c $(LIBS) $(FLIBS)

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

squeeze.exe : squeeze.c
	$(CC) $(CFLAGS) squeeze.c -o squeeze.exe $(LIBS) $(FLIBS)

tex.pro : tex.lpro squeeze.exe
	squeeze tex.lpro  tex.pro

texc.pro: texc.lpro squeeze.exe
	squeeze texc.lpro texc.pro

texc.lpro: texc.sh tex.lpro
	bash texc.sh tex.lpro texc.lpro
# If you dont have BASH, SED and RM, copy tex.lpr to texc.lpr
# then edit texc.lpr to remove the code
# for uncompressed fonts, and uncomment the
# code for unpacking compressed fonts

texps.pro : texps.lpro squeeze.exe
	squeeze texps.lpro texps.pro

special.pro : special.lpro squeeze.exe
	squeeze special.lpro special.pro

finclude.pro: finclude.lpro squeeze.exe
	squeeze finclude.lpro finclude.pro

color.pro: color.lpro squeeze.exe
	squeeze color.lpro color.pro

crop.pro: crop.lpro squeeze.exe
	squeeze crop.lpro crop.pro

install : afm2tfm.exe dvips.exe 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 $(TEXMACRODIR)
	copy afm2tfm.exe $(BINDIR)\afm2tfm.exe
	copy dvips.exe $(BINDIR)\dvips.exe
	copy pc\maketexp.cmd $(BINDIR)\maketexp.cmd
	copy tex.pro $(HEADERDIR)
	copy texc.pro $(HEADERDIR)
	copy texps.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 *.obj
	del dvips.exe
	del squeeze.exe
	del afm2tfm.exe
	del *.pro
	del *.bak
	del *.log

clean :
	del *.o
	del *.obj
	del squeeze.exe
	del *.bak
	del *.log

