# MAKEFILE DTL  -- S RAHTZ S.RAHTZ@ELSEVIER.CO.UK
VERSION = 1.0

PREFIX = C:/USR/LOCAL
EXEC_PREFIX = ${PREFIX}

# ARCHITECTURE-DEPENDENT EXECUTABLES.
BINDIR = ${EXEC_PREFIX}/BIN

# ARCHITECTURE-INDEPENDENT EXECUTABLES.
SCRIPTDIR = $(BINDIR)

# ARCHITECTURE-DEPENDENT FILES, SUCH AS LIB*.A FILES.
LIBDIR = ${EXEC_PREFIX}/LIB

# ARCHITECTURE-INDEPENDENT FILES.
DATADIR = ${PREFIX}/SHARE

# HEADER FILES.
INCLUDEDIR = ${PREFIX}/INCLUDE

# GNU .INFO* FILES.
INFODIR = ${PREFIX}/INFO

# UNIX MAN PAGES.
MANEXT = 1
MANDIR = ${PREFIX}/MAN/MAN$(MANEXT)

# TEX SYSTEM-SPECIFIC DIRECTORIES. NOT ALL OF THE FOLLOWING ARE RELEVANT
# FOR ALL PROGRAMS, BUT IT SEEMS CLEANER TO COLLECT EVERYTHING IN ONE PLACE.

# THE DEFAULT PATHS ARE NOW IN KPATHSEA/TEXMF.IN. PASSING ALL THE
# PATHS TO SUB-MAKES CAN MAKE THE ARG LIST TOO LONG ON SYSTEM V.
# NOTE THAT IF YOU MAKE CHANGES BELOW, YOU WILL HAVE TO MAKE THE
# CORRESPONDING CHANGES TO TEXMF.IN OR TEXMF.CNF YOURSELF.

# THE ROOT OF THE MAIN TREE.
TEXMF = C:/USR/LOCAL/SHARE/TEXMF

# THE DIRECTORY USED BY VARFONTS.
VARTEXFONTS = C:/VAR/TEX/FONTS

# REGULAR INPUT FILES.
TEXINPUTDIR = $(TEXMF)/TEX
MFINPUTDIR = $(TEXMF)/METAFONT
MPINPUTDIR = $(TEXMF)/METAPOST
MFTINPUTDIR = $(TEXMF)/MFT

# DVIPS'S EPSF.TEX, ROTATE.TEX, ETC. GET INSTALLED HERE;
# DITTO FOR DVILJ'S FONTS SUPPORT.
DVIPS_PLAIN_MACRODIR = $(TEXINPUTDIR)/PLAIN/DVIPS
DVILJ_LATEX2E_MACRODIR = $(TEXINPUTDIR)/LATEX/DVILJ

# MKTEX.CNF, TEXMF.CNF, ETC.
WEB2CDIR = $(TEXMF)/WEB2C

# THE TOP-LEVEL FONT DIRECTORY.
FONTDIR = $(TEXMF)/FONTS

# MEMORY DUMPS (.FMT/.BASE/.MEM).
FMTDIR = $(WEB2CDIR)
BASEDIR = $(FMTDIR)
MEMDIR = $(FMTDIR)

# POOL FILES.
TEXPOOLDIR = $(WEB2CDIR)
MFPOOLDIR = $(TEXPOOLDIR)
MPPOOLDIR = $(TEXPOOLDIR)

# WHERE THE .MAP FILES FROM FONTNAME ARE INSTALLED.
FONTNAMEDIR = $(TEXMF)/FONTNAME

# FOR DVIPS CONFIGURATION FILES, PSFONTS.MAP, ETC.
DVIPSDIR = $(TEXMF)/DVIPS

# FOR DVIPS .PRO FILES, GSFTOPK'S RENDER.PS, ETC.
PSHEADERDIR = $(DVIPSDIR)

# IF A FONT CAN'T BE FOUND CLOSE ENOUGH TO ITS STATED SIZE, WE LOOK FOR
# EACH OF THESE SIZES IN THE ORDER GIVEN.  THIS COLON-SEPARATED LIST IS
# OVERRIDDEN BY THE ENVVAR TEXSIZES, AND BY A PROGRAM-SPECIFIC VARIABLE
# (E.G., XDVISIZES), AND PERHAPS BY A CONFIG FILE (E.G., IN DVIPS).
# THIS LIST MUST BE SORTED IN ASCENDING ORDER.
DEFAULT_TEXSIZES = 300:600

# END OF PATHS.MAKE.
# COMMON.MAKE -- USED BY ALL MAKEFILES.
SHELL = SH

TOP_SRCDIR = .
SRCDIR = .

CC = CL
CFLAGS = -nologo -O2 -MD -DWIN32=1 -DKPATHSEA=1 $(XCFLAGS)
CPPFLAGS =  $(XCPPFLAGS)

YDEFS = -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE \
-D_CRT_OBSOLETE_NO_DEPRECATE -D_SECURE_SCL=0

DEFS = -DHAVE_CONFIG_H $(XDEFS) $(YDEFS)

# Kpathsea needs this for compiling, programs need it for linking.
LIBTOOL =

# You can change [X]CPPFLAGS, [X]CFLAGS, or [X]DEFS, but
# please don't change ALL_CPPFLAGS or ALL_CFLAGS.
# prog_cflags is set by subdirectories of web2c.
ALL_CPPFLAGS = $(DEFS) -I. -I$(srcdir) $(prog_cflags) \
  -I$(kpathsea_parent) -I$(kpathsea_srcdir_parent) $(CPPFLAGS)
ALL_CFLAGS = $(ALL_CPPFLAGS) $(CFLAGS) -c
compile = $(CC) $(ALL_CFLAGS)

.SUFFIXES: .c .obj # in case the suffix list has been cleared, e.g., by web2c
.c.obj:
	$(compile) $<

# Installation.
INSTALL = cp
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = $(INSTALL_PROGRAM)
INSTALL_DATA = ${INSTALL}
INSTALL_LIBTOOL_LIBS = INSTALL_DATA='$(INSTALL_DATA)' $(LIBTOOL) install-lib
INSTALL_LIBTOOL_PROG = INSTALL_PROGRAM='$(INSTALL_PROGRAM)' $(LIBTOOL) install-prog

# Creating (symbolic) links.
LN = ln

# We use these for many things.
kpathsea_parent = ..
kpathsea_dir = $(kpathsea_parent)/kpathsea
kpathsea_srcdir_parent = $(top_srcdir)/..
kpathsea_srcdir = $(kpathsea_srcdir_parent)/kpathsea
kpathsea = $(kpathsea_dir)/kpathsealib.lib

#M#ifeq ($(CC), gcc)
#M#XDEFS = -D__USE_FIXED_PROTOTYPES__ -Wall -Wpointer-arith $(warn_more)
#M#CFLAGS = -pipe -g $(XCFLAGS)
#M#endif
# End of common.make.
# programs.make -- used by Makefiles for executables only.

# Don't include $(CFLAGS), since ld -g under Linux forces
# static libraries, e.g., libc.a and libX*.a.
LDFLAGS =  $(XLDFLAGS)

# proglib is for web2c; 
# XLOADLIBES is for the installer.
LIBS = 
LOADLIBES = $(proglib) $(kpathsea) $(LIBS) $(XLOADLIBES)

# May as well separate linking from compiling, just in case.
CCLD = $(CC)
link_command = $(CCLD) -Fe$@ $(LDFLAGS) 

# When we link with Kpathsea, have to take account that it might be a
# shared library, etc.
kpathsea_link = $(link_command)
# End of programs.make.

prog_cflags = -DNeedFunctionPrototypes -DHAVE_CONFIG_H \
	-I$(kpathsea_dir) -I$(kpathsea_srcdir)
# We don't use Kpathsea, so don't overload fopen and stuff
DEFS = -DNO_DEBUG

objects=dv2dt.obj dt2dv.obj
program = dv2dt.exe dt2dv.exe

programs = $(program)

default: $(programs)
all: $(programs)

dv2dt.exe: dv2dt.obj $(kpathsea)
	$(kpathsea_link) dv2dt.obj setargv.obj $(kpathsea)

dt2dv.exe: dt2dv.obj $(kpathsea)
	$(kpathsea_link) dt2dv.obj setargv.obj $(kpathsea)

BINS=dt2dv.exe dv2dt.exe
install: $(BINS)
	cp -p $(BINS) c:/usr/local/txdir/w32tex/bin
	cp -p $(BINS) c:/usr/work/edrive/wk/dist/DVITOOLS/bin/

uninstall: uninstall-exec uninstall-data

install-exec: all
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir)
	for p in $(programs); do $(INSTALL_LIBTOOL_PROG) $(bindir) $$p; done
uninstall-exec:
	for p in $(programs); do rm -f $(bindir)/$$p; done

install-data: 
	$(SHELL) $(top_srcdir)/../mkinstalldirs  $(mandir)
	$(INSTALL_DATA) $(srcdir)/dv2dt.man $(mandir)/dv2dt.1
	$(INSTALL_DATA) $(srcdir)/dt2dv.man $(mandir)/dt2dv.1

uninstall-data: 
	rm -f $(mandir)/dv2dt.1
	rm -f $(mandir)/dt2dv.1

# dist.make -- making distribution tar files.
#M#top_distdir = $(distname)-$(version)
#M#top_files = ChangeLog Makefile.in README configure.in configure \
#M#  install.sh acklibtool.m4 config.guess config.sub klibtool \
#M#  mkinstalldirs add-info-toc rename unbackslsh.awk withenable.ac
#M#distdir = $(top_distdir)/$(distname)
#M#kpathsea_distdir = ../$(distname)/$(top_distdir)/kpathsea
#M#ln_files = AUTHORS ChangeLog INSTALL NEWS README *.in *.h *.c \
#M#  configure *.make
#M#
#M#dist_rm_predicate = -name Makefile
#M#dist: all depend pre-dist-$(distname)
#M#	rm -rf $(top_distdir)*
#M#	mkdir -p $(distdir)
#M#	cd .. && make Makefile ./configure
#M#	cd .. && ln $(top_files) $(distname)/$(top_distdir)
#M#	cp -p $(top_srcdir)/../dir $(top_distdir)
#M#	-ln $(ln_files) $(distdir)
#M#	ln $(program_files) $(distdir)
#M#	cd $(kpathsea_dir); $(MAKE) distdir=$(kpathsea_distdir) \
#M#	  ln_files='$(ln_files)' distdir
#M#	cp -pr ../make ../etc ../djgpp $(top_distdir)
#M#	rm -rf $(top_distdir)/make/CVS
#M#	rm -rf $(top_distdir)/etc/CVS
#M#	rm -rf $(top_distdir)/etc/autoconf/CVS
#M#	rm -rf $(top_distdir)/djgpp/CVS
#M## Remove the extra files our patterns got us.
#M#	cd $(top_distdir); rm -f */c-auto.h
#M#	find $(top_distdir) \( $(dist_rm_predicate) \) -exec rm '{}' \;
#M#	find $(top_distdir) -name \.*texi -exec egrep -ni '	| ::|xx[^}]' \;
#M## Now handle the contrib dir.
#M#	mkdir -p $(top_distdir)/contrib && \
#M#	  cp -p ../contrib/{ChangeLog,INSTALL,Makefile,README,*.c,*.h} \
#M#	        $(top_distdir)/contrib
#M#	$(MAKE) post-dist-$(distname)
#M#	cd $(distdir); test ! -r *.info || touch *.info*
#M#	chmod -R a+rX,u+w $(top_distdir)
#M#	GZIP=-9 tar chzf $(top_distdir).tar.gz $(top_distdir)
#M#	rm -rf $(top_distdir)
# End of dist.make.
# config.make -- autoconf rules to remake the Makefile, c-auto.h, etc.
#M#ac_dir = $(top_srcdir)/../etc/autoconf
#M#autoconf = $(ac_dir)/acspecific.m4 $(ac_dir)/acgeneral.m4 $(ac_dir)/acsite.m4
#M#autoheader = $(ac_dir)/acconfig.h $(ac_dir)/autoheader.m4
#M#
#M## I define $(autoconf) to acgeneral.m4 and the other Autoconf files, so
#M## configure automatically gets remade in the sources with a new Autoconf
#M## release.  But it would be bad for installers with Autoconf to remake
#M## configure (not to mention require Autoconf), so I take out the variable
#M## $(autoconf) definition before release.
#M## 
#M## BTW, xt.ac isn't really required for dvipsk or dviljk, but it doesn't
#M## seem worth the trouble.
#M## 
#M#configure_in = $(srcdir)/configure.in $(kpathsea_srcdir)/common.ac \
#M#  $(kpathsea_srcdir)/withenable.ac $(kpathsea_srcdir)/xt.ac \
#M#  $(kpathsea_srcdir_parent)/acklibtool.m4
#M#$(srcdir)/configure: $(configure_in) $(autoconf)
#M#	cd $(srcdir) && autoconf -m $(ac_dir)
#M#
#M## And make sure that --enable-maintainer-mode is used if configure is
#M## called from the makefiles.  We do not try to do this through the
#M## cache, lest the option sneaks into a global cache file.
#M#enablemaintflag = --enable-maintainer-mode

# This rule isn't used for the top-level Makefile, but it doesn't hurt.
# We don't depend on config.status because configure always rewrites
# config.status, even when it doesn't change. Thus it might be newer
# than c-auto.h when we don't need to remake the latter.
c-auto.h: stamp-auto
stamp-auto: $(srcdir)/c-auto.in
	$(SHELL) config.status
	date >stamp-auto

#M## autoheader reads acconfig.h (and c-auto.h.top) automatically.
#M#$(srcdir)/c-auto.in: $(srcdir)/stamp-auto.in
#M#$(srcdir)/stamp-auto.in: $(configure_in) $(autoheader) \
#M#  $(kpathsea_srcdir)/acconfig.h
#M#	cd $(srcdir) && autoheader -m $(ac_dir) -l $(kpathsea_srcdir)
#M#	date >$(srcdir)/stamp-auto.in

# End of config.make.

info dvi check:

# clean.make -- cleaning.

clean:
	rm *.obj *.exe *~	

# Although we can remake configure and c-auto.in, we don't remove
# them, since many people may lack Autoconf.  Use configclean for that.
maintainer-clean:: distclean
	rm -f *.info*

extraclean::
	rm -f *.aux *.bak *.bbl *.blg *.dvi *.log *.pl *.tfm *.vf *.vpl
	rm -f *.*pk *.*gf *.mpx *.i *.s *~ *.orig  *.rej *\#*
	rm -f CONTENTS.tex a.out core mfput.* texput.* mpout.*

configclean:
	rm -f configure c-auto.in c-auto.h stamp-*
# End of clean.make.
# rdepend.make -- rules for remaking the dependencies.
#M## 
#M## Have to use -M, not -MM, since we use <kpathsea/...> instead of
#M## "kpathsea/..." in the sources.  But that means we have to remove the
#M## directory prefixes and all the system include files.
#M## And <kpathsea/paths.h> is generated, not part of the distribution.
#M## 
#M## And, there's no need for any installer/user to ever run this, it can
#M## only cause trouble. So comment it out in the distribution.
#M## (It doesn't work when the source and build directories are different.)
#M#ifndef c_auto_h_dir
#M#c_auto_h_dir = .
#M#endif
#M#
#M#depend depend.make:: $(c_auto_h_dir)/c-auto.h \
#M#  $(top_srcdir)/../make/rdepend.make 
#M#	$(CC) -M $(ALL_CPPFLAGS) -I$(c_auto_h_dir) *.c \
#M#	  | sed -e 's,\(\.\./\)\+kpathsea/,$$(kpathsea_srcdir)/,g' \
#M#	        -e 's,$$(kpathsea_srcdir)/c-auto.h,$$(kpathsea_dir)/c-auto.h,g' \
#M#	        -e 's,$$(kpathsea_srcdir)/paths.h,$$(kpathsea_dir)/paths.h,g' \
#M#	        -e 's,/usr[^ ]* ,,g' \
#M#	        -e 's,/usr[^ ]*$$,,g' \
#M#	        -e 's,dvi2xx.o,dvilj.o dvilj2p.o dvilj4.o dvilj4l.o,' \
#M#	        -e 's,lex.yy,$$(LEX_OUTPUT_ROOT),g' \
#M#	  | $(top_srcdir)/../unbackslsh.awk \
#M#	  >depend.make
#M## If kpathsea, we're making .lo library objects instead of .o's.
#M#	pwd | grep -v kpathsea >/dev/null \
#M#	  || (sed -e 's/\.o:/.lo:/' \
#M#	          -e 's/kpsewhich.lo:/kpsewhich.o:/' \
#M#	          -e 's/kpsestat.lo:/kpsestat.o:/' \
#M#	          -e 's/access.lo:/access.o:/' \
#M#	          -e 's/readlink.lo:/readlink.o:/' \
#M#	      <depend.make >depend-tmp.make; mv depend-tmp.make depend.make)
#M#.PHONY: depend

# Let's stick a rule for TAGS here, just in case someone wants them.
# (We don't put them in the distributions, to keep them smaller.)
TAGS: *.c *.h
	pwd | grep kpathsea >/dev/null && append=../kpathsea/TAGS; \
	  etags $$append *.[ch]

# Prevent GNU make 3.[59,63) from overflowing arg limit on system V.
.NOEXPORT:

# End of rdepend.make.
dt2dv.obj: dt2dv.c \
 dtl.h
dv2dt.obj: dv2dt.c \
 dtl.h
