# makefile for the dvi-to-(3812 || lj + || lj II || lj IIp ) filter.
#
CFLAGS=-O -s -Dunix
BINDIR=/usr/local/bin
MANDIR=/usr/man
MANSEC=1
CC=cc

# under Ultrix 4.1 use:
# CFLAGS=-O1 -s -Dunix

# for DEC alpha machines use
# LFLAGS=-lbsd
# CC=gcc
# CFLAGS=-Dunix -ansi -pedantic -Dalpha

# for gcc you might wish to set the following flags
CC=gcc
CFLAGS=-Dunix -ansi -pedantic -O2
# under Linux you might want to use the following configuration
CFLAGS=-Dunix -ansi -pedantic -O2 -m486

# of DO_SUBDIRS is specifies the fontpath is searched recursively
# for each subpart (applies to raster info and tfm files); the
# default search depth is bounded to 10
DO_SUBDIRS =
# DO_SUBDIRS = -DDO_SUBDIRECTORIES
DO_SUBDIRS = -DDO_SUBDIRECTORIES -DMAX_SUBDIR_SEARCH_DEPTH=2

# FONTAREA specifies the search path for locating raster information.
# if you are unhappy with dvi2xx's guess work, specify the path
# here, otherwise let it unspecified
FONTAREA =
# under Linux add the following path is used in most installations
FONTAREA = -DFONTAREA=\"/usr/TeX/lib/tex/fonts\"

# DEFAULT_TFM_PATH is the default search path for locating .tfm
# files. .tfm-files are only read by dvilj4. The pre configured
# search path ("/usr/local/lib/tex/fonts") is used when this
# variable is left empty
DEFAULT_TFM_PATH =
# under Linux add the following path is used in most installations
DEFAULT_TFM_PATH = -DDEFAULT_TFM_PATH=\"/usr/TeX/lib/tex/fonts\"


FLAGS = $(CFLAGS) $(FONTAREA) $(DEFAULT_TFM_PATH) $(DO_SUBDIRS)

OBJS=findlj.o find3812.o
HFILES=commands.h config.h
PROGRAMS=dvilj2p dvilj2 dvilj4 dvi3812 dvilj dviljp

all: $(PROGRAMS) dvi2xx.txt

dvi3812: dvi2xx.c find3812.o $(HFILES)
       $(CC) ${FLAGS} -DIBM3812 -o $@ dvi2xx.c find3812.o ${LFLAGS}

dvilj2p: dvi2xx.c findlj.o  $(HFILES)
       $(CC) ${FLAGS} -DLJ2P -o $@ dvi2xx.c findlj.o  ${LFLAGS}

dvilj2: dvi2xx.c findlj.o  $(HFILES)
       $(CC) ${FLAGS} -DLJ2 -o $@ dvi2xx.c findlj.o ${LFLAGS}

dvilj4: dvilj4.o findlj4.o tfm.o xmalloc.o $(HFILES)
       $(CC) -o $@ dvilj4.o findlj4.o tfm.o xmalloc.o ${LFLAGS}

dvilj4.o: dvi2xx.c $(HFILES)
       $(CC) ${FLAGS} -DLJ4 -c dvi2xx.c
       mv dvi2xx.o dvilj4.o

tfm.o: tfm.c
       $(CC) ${FLAGS} -DLJ -c tfm.c

dvilj: dvi2xx.c findlj.o  $(HFILES)
       $(CC) ${FLAGS} -DLJ -DSEVENBIT -o $@ dvi2xx.c findlj.o  ${LFLAGS}

dviljp: dvi2xx.c findlj.o  $(HFILES)
       $(CC) ${FLAGS} -DLJ2P -DSEVENBIT -o $@ dvi2xx.c findlj.o  ${LFLAGS}

findlj.o: findfile.c config.h
       $(CC) ${FLAGS} -DLJ -c findfile.c
       mv findfile.o $@

findlj4.o: findfile.c config.h
       $(CC) ${FLAGS} -DLJ4 -c findfile.c
       mv findfile.o $@

find3812.o: findfile.c config.h
       $(CC) ${FLAGS} -DIBM3812 -c findfile.c
       mv findfile.o $@

clean:
       rm -f core $(OBJS) $(PROGRAMS)

DISTFILES = \
       ./dvi2xx.c ./commands.h ./config.h ./findfile.c ./Makefile \
       ./tfm.c ./xmalloc.c \
       ./testpage.tex ./dvi2xx.history ./dvi2xx.man ./dvi2xx.txt \
       ./graybox.sty ./dvi2xx.make ./dvi2xx.051 ./README \
       ./MakeTeXPK ./lj3-filter ./printcap.sample ./README.vms \
       ./sample2.tex ./2up.sty ./README.dell-unix ./README.pcl \
       ./README.0.51alpha9

shar: $(DISTFILES)
       shar ${DISTFILES} > dvi2xx.shar


tar:
       pdtar zcvf dvi2xx.tar.Z ${DISTFILES}
       shar dvi2xx.tar.Z > dvi2xx.shar

testfiles:
       ./dvilj2 -eftable.lj2 ftable
       ./dvilj2p -eftable.lj2p ftable
       ./dvi3812 ftab2


install:
       @for f in $(PROGRAMS); do \
               echo installing $$f in $(BINDIR); \
               install -c $$f $(BINDIR); \
       done
       cp dvi2xx.man dvi2xx.$(MANSEC)
       install dvi2xx.$(MANSEC) $(MANDIR)/man$(MANSEC)

dvi2xx.txt: dvi2xx.man
       -nroff -man dvi2xx.man | col -b > dvi2xx.txt