# 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 *~	

distclean:: extraclean clean
	rm -f Makefile
	rm -f config.status config.log config.cache c-auto.h
	rm -f stamp-auto stamp-tangle stamp-otangle

# 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
