# For the applicable copyright information see any of the 
# source files and the documentation.
# dvi->ps driver program Makefile.
INC = -I../h -I../../h

# GFLAG: -g option for compiling and linking
# GFLAG = -g
CFLAGS = $(GFLAG) $(INC)

LFLAGS = $(GFLAG)
DEFS =	-DTPIC=$(TPIC)

LINT_FLAGS =      $(INC) $(FONT_TYPES) $(DEFS)

INSTALL = install -c -s
LIB_DIR = ../../lib
SUP = ../../sup

SRC_PRIMARY = capab.c conv.c decodeargs.c dvi.c dviloop.c\
	emitc.c	fonts.c	gf.c main.c pass0.c pass1.c pdr.c pk.c\
	pos.c ps.c pxl.c search.c search2.c send.c send2.c shipc.c\
	switchps.c special.c
SRC_2 = special-lex.c

OBJ_PRIMARY = capab.o conv.o decodeargs.o dvi.o dviloop.o\
	emitc.o	fonts.o	gf.o main.o pass0.o pass1.o pdr.o pk.o\
	pos.o ps.o pxl.o search.o search2.o send.o send2.o shipc.o\
	switchps.o special.o
OBJ_2 = special-lex.o

# Compilation dependens on whether tpic is included or not.
#if (COND_TPIC == 1)
SRC_3 = tpic_support.c
OBJ_3 = tpic_support.o
#endif
SRC_ALL = $(SRC_PRIMARY) $(SRC_2) $(SRC_3)
OBJ_ALL = $(OBJ_PRIMARY) $(OBJ_2) $(OBJ_3)

all:	$(DVITPS_BINARY_NAME)

$(DVITPS_BINARY_NAME):	$(OBJ_ALL)
	cd $(LIB_DIR); make
	cd ../../otherc; make
	cc $(GFLAG) -o $@ $(OBJ_ALL) ../../otherc/sig.o ../../otherc/defaults.o $(LIB_DIR)/libics.a -lm

relink:
	$(RM) $(DVITPS_BINARY_NAME)
	make  $(DVITPS_BINARY_NAME)

install:	$(DVITPS_BINARY_NAME)
	$(RM) $(DRIVER_BINDIR)/$(DVITPS_BINARY_NAME)
	$(INSTALL) $(DVITPS_BINARY_NAME) $(DRIVER_BINDIR)/$(DVITPS_BINARY_NAME)

print:	Makefile $(SRC_PRIMARY) $(SRC_3) special-1.lex special-tokens.in special-2.lex
	$(PRINT_COMMAND) Makefile\
			special-1.lex special-tokens.in special-2.lex $(SRC_PRIMARY) $(SRC_3)

dvi.o:	dvi.c
	cc $(CFLAGS) -c dvi.c

special.o:	special.c
	cc $(CFLAGS) $(DEFS) -c special.c

special-lex.c:	special-1.lex special-tokens.in special-2.lex special-tokenlex.h
	cd $(SUP); make
	$(RM) $@ lexin.tmp
	$(SUP)/keywlex -c special-tokens.in |	\
		cat special-1.lex - special-2.lex  > lexin.tmp
	lex lexin.tmp
	$(RM) lexin.tmp
	mv lex.yy.c $@

special-tokenlex.h:	special-tokens.in
	cd $(SUP); make
	awk -f $(SUP)/tok-lex.awk special-tokens.in > $@

clean::
	$(RM) $(DVITPS_BINARY_NAME) special-lex.c special-tokenlex.h

lint:	$(SRC_ALL)
	lint $(LINT_FLAGS) $(SRC_ALL) > $@

TAGS:	$(SRC_ALL) Makefile
	etags $(SRC_ALL)

depend:	$(SRC_ALL)
	maketd -mIMakefile $(INC) $(SRC_ALL)

# DO NOT DELETE THIS LINE - make depend DEPENDS ON IT
A=../../h
B=../h

capab.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvitps.h capab.c

conv.o: $A/defs.h $A/units.h $B/dvitps.h conv.c

decodeargs.o: $A/defs.h $A/extfil.h $B/dvitps.h $B/emit.h decodeargs.c

dvi.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvi-com.h $B/dvitps.h \
	dvi.c

dviloop.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvitps.h $B/emit.h \
	dviloop.c

emitc.o: $A/defs.h $A/extfil.h $A/fontd.h $A/pdr.h $A/units.h $B/dvitps.h \
	$B/emit.h $B/gf-com.h emitc.c

fonts.o: $A/defs.h $A/extfil.h $A/fontd.h $A/tfm.h $A/units.h $B/dvitps.h \
	$B/emit.h fonts.c

gf.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvitps.h $B/gf-com.h \
	gf.c

main.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvitps.h $B/emit.h \
	main.c

pass0.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvi-com.h $B/dvitps.h \
	$B/emit.h pass0.c

pass1.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvi-com.h $B/dvitps.h \
	$B/emit.h pass1.c

pdr.o: $A/defs.h $A/extfil.h $A/fontd.h $A/pdr.h $A/units.h $B/dvitps.h \
	$B/emit.h pdr.c

pk.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvitps.h $B/pk-com.h \
	pk.c

pos.o: $A/defs.h $A/extfil.h $A/fontd.h $A/pdr.h $A/units.h $B/dvi-com.h \
	$B/dvitps.h $B/emit.h pos.c

ps.o: $A/defs.h $A/extfil.h $A/fontd.h $A/pdr.h $A/units.h $B/dvitps.h \
	$B/emit.h ps.c

pxl.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvitps.h $B/gf-com.h \
	pxl.c

search.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvitps.h search.c

search2.o: $A/extfil.h $A/fontd.h $A/units.h $B/dvitps.h search2.c

send.o: $A/extfil.h $A/units.h $B/dvitps.h $B/emit.h send.c

send2.o: $A/defs.h $A/extfil.h $A/units.h $B/dvitps.h $B/emit.h send2.c

shipc.o: $A/defs.h $A/extfil.h $A/fontd.h $A/units.h $B/dvitps.h $B/emit.h \
	shipc.c

switchps.o: $A/extfil.h switchps.c

special.o: $A/defs.h $A/extfil.h $A/units.h $B/dvi-com.h $B/dvitps.h \
	$B/emit.h special-tokenlex.h special.c

special-lex.o: special-lex.c special-tokenlex.h

tpic_support.o: $A/defs.h $B/dvitps.h $B/emit.h tpic_support.c

# *** Do not add anything here - It will go away. ***
