# Generated automatically from Makefile.in by configure.
#
# Makefile for eptex -- ken-na@ascii.co.jp, Public domain.
version = 2012

kanjicode = SJIS

default : programs #formats

programs=eptex.dll
formats=eptex.fmt

# paths.mk -- installation directories.
#
# The compile-time paths are defined in kpathsea/paths.h, which is built
# from kpathsea/texmf.in and these definitions.  See kpathsea/INSTALL
# for how the various path-related files are used and created.

# Do not change prefix and exec_prefix in Makefile.in!
# configure doesn't propagate the change to the other Makefiles.
# Instead, give the -prefix/-exec-prefix options to configure.
# (See kpathsea/INSTALL for more details.) This is arguably
# a bug, but it's not likely to change soon.
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.mk.

# Used for triptrap.
DIFF = diff
DIFFFLAGS =

.SUFFIXES: # get rid of .p.obj
# common.mk -- used by all Makefiles.
SHELL = sh
MAKE=make
top_srcdir = .
srcdir = .

WD = setargv.obj
#
#
XDEFS = -DFAM256=1 -DWIN32=1 -DPTEX=1
CC = cl
#
# for Debug
#CFLAGS = -nologo -Od -Zi -MD -DDBW32=1 $(XCFLAGS)
#DBSTR = /DEBUG
#
CFLAGS = -nologo -W3 -O2 -MD $(XCFLAGS)
DBSTR =
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 = $(kpathsea_srcdir_parent)/klibtool

# 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.. -I../synctexdir -I../libmd5 \
  -I$(kpathsea_parent) -I$(kpathsea_srcdir_parent) \
  $(prog_cflags) $(CPPFLAGS) -I../../ptexenc -I$(ZLIBDIR)
ALL_CFLAGS = $(ALL_CPPFLAGS) $(CFLAGS) -c
compile = $(CC) $(ALL_CFLAGS)

.SUFFIXES:
.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_LIBTOOL_PROG =

# Creating (symbolic) links.
LN = cp

# 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 = -Wpointer-arith $(warn_more)
#M#CFLAGS = -pipe -g $(XCFLAGS)
#M#endif
# End of common.mk.
# programs.mk -- 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.
XLDFLAGS = -link /SUBSYSTEM:CONSOLE /OPT:NOREF /STACK:0x300000
LDFLAGS =  $(XLDFLAGS)

# proglib is for web2c; 
# XLOADLIBES is for the installer.
SYSLIBS = user32.lib advapi32.lib wsock32.lib
LIBS = ../../ptexenc/libptexenc.lib
LOADLIBES = $(proglib) $(kpathsea) $(LIBS) $(SYSLIBS) $(XLOADLIBES)

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

# When we link with Kpathsea, have to take account that it might be a
# shared library, etc.
kpathsea_link = $(link_command)
# End of programs.mk.
#M#ifeq ($(CC), gcc)
#M#XDEFS = -Wimplicit -Wreturn-type -Wcomment -Wformat -D__USE_FIXED_PROTOTYPES__
#M#endif

# With --enable-ipc, TeX may need to link with -lsocket.
socketlibs = 

common_makeargs = $(MFLAGS) CC='$(CC)' CFLAGS='$(CFLAGS)' $(XMAKEARGS)
install_makeargs = INSTALL='$(INSTALL)' INSTALL_DATA='$(INSTALL_DATA)' \
  INSTALL_PROGRAM='$(INSTALL_PROGRAM)' \
  $(makevars) $(common_makeargs)

proglib = ../lib/ptexlib.lib

# The sh script that does the conversion:
web2c = srcdir=$(thisdir) $(shared_env) $(SHELL) $(thisdir)/epconvert
# Additional dependencies:
web2c_aux = $(thisdir)/epconvert $(cwebdir)/common.defines \
	$(thisdir)/eptex.defines
web2c_programs = $(cwebdir)/fixwrites.exe $(cwebdir)/splitup.exe \
                 $(cwebdir)/web2c.exe
web2c_texmf = $(web2c_aux) $(web2c_programs)

# Unfortunately, suffix rules can't have dependencies, or multiple
# targets, and we can't assume all makes supports pattern rules.
.SUFFIXES: .p .c .ch .p
.p.c: # really depends on $(web2c_programs), and generates .h.
	 $(web2c) $*
.ch.p: # really depends on ../tangle; for eptex, also generates .pool
	$(shared_env) ../tangle $(thisdir)/$*.web $<

synctex-eptex-o = synctex-ep.obj

eptex_c = eptexini.c eptex0.c
eptex_o = eptexini.obj eptex0.obj eptexextra.obj \
         $(synctex-eptex-o) eptex-pool.obj md5.obj
dlleptex_o = eptexini.obj eptex0.obj eptexextra.obj \
         $(synctex-eptex-o) eptex-pool.obj md5.obj
plib_o = kanji.obj
kdmp_o = kanji_dump.obj

ZLIBDIR = ../../../libs/zlib
LDZLIB = $(ZLIBDIR)/libz.lib
#
# synctex
#
synctex_dir = ../synctexdir
synctex_common_texd = \
		echo "Enabling SyncTeX Support."

# Prevent Make from deleting the intermediate forms.
.PRECIOUS: %.p %.c

#  
# Rules for eptex, TFtoPL, PLtoTF.
# fix dir
thisdir = .
srcdir = ..
top_srcdir= ../..
cwebdir = ../web2c

kpathsea_parent = $(top_srcdir)
kpathsea_srcdir_parent = $(kpathsea_parent)

programs: $(programs)

### eptex
eptex.exe: $(eptex_o) $(plib_o) $(kpathsea) $(proglib)
	$(kpathsea_link) $(eptex_o) $(plib_o) $(WD) \
           $(socketlibs) $(LDZLIB) $(LOADLIBES) $(LDFLAGS) $(DBSTR)

eptex.dll: $(dlleptex_o) $(plib_o) $(kdmp_o) $(kpathsea) $(proglib)
	cl -LD -Fe$@ $(dlleptex_o) $(plib_o) $(kdmp_o) \
           $(socketlibs) $(LDZLIB) $(LOADLIBES) $(LDFLAGS)

$(eptex_o): $(eptex_c) eptexcoerce.h eptexd.h kanji.h 

$(eptex_c) eptexcoerce.h eptexd.h: eptex.p $(web2c_texmf)
	$(web2c) eptex
	$(eptexdh-with_synctex)

MAKECPOOL = ../web2c/makecpool.exe
eptex-pool.c: eptex.pool eptexd.h $(MAKECPOOL)
	$(MAKECPOOL) eptex >eptex-pool.c

eptex.p: eptex.web eptex.ch

eptex_ch_synctex = \
 ../synctexdir/synctex-def.ch0 \
 ../synctexdir/synctex-ep-mem.ch0 \
 ../synctexdir/synctex-mem.ch0 \
 ../synctexdir/synctex-e-mem.ch0 \
 ../synctexdir/synctex-ep-mem.ch1 \
 ../synctexdir/synctex-p-rec.ch0 \
 ../synctexdir/synctex-rec.ch0 \
 ../synctexdir/synctex-rec.ch1 \
 ../synctexdir/synctex-ep-rec.ch0 \
 ../synctexdir/synctex-e-rec.ch0 \
 ../synctexdir/synctex-p-rec.ch1

eptex_web_srcs = \
 ../tex.web \
 ../etexdir/etex.ch \
 ../etexdir/tex.ch0 \
 ../tex.ch \
 ../tracingstacklevels.ch \
 ../zlib-fmt.ch \
 ../etexdir/tex.ech

eptex_ch_srcs = \
 eptex.web \
 eptex-base.ch \
 etex.ch0 \
 ../ptexdir/ptex-base.ch \
 eptex.ech \
 etex.ch1 \
 $(eptex_ch_synctex) \
 fam256.ch \
 pdfutils.ch \
 char-warning-eptex.ch \
 ../tex-binpool.ch

synctex.h: $(synctex_dir)/synctex.h
	cp $(synctex_dir)/synctex.h $@
synctex-eptex.h: $(synctex_dir)/synctex-eptex.h
	cp -p $(synctex_dir)/synctex-eptex.h $@
$(synctex-eptex-o): synctex-ep.c
	$(compile) -DSYNCTEX_ENGINE_H='<synctex-eptex.h>' $<

synctex-ep.c: eptexd.h $(synctex_dir)/synctex.c synctex.h synctex-eptex.h
	cp $(synctex_dir)/synctex.c $@

eptexdh-with_synctex = if test -z "`grep __SyncTeX__ eptexd.h`";\
	then\
		$(synctex_common_texd);\
		sed -f ./synctex_sed_command.sed eptexd.h > synctex_eptexd.h;\
		mv synctex_eptexd.h eptexd.h;\
		if test -z "`grep __SyncTeX__ eptexd.h`";\
		then\
			echo "warning: SyncTeX activation FAILED";\
			exit 1;\
		fi;\
		echo "SyncTeX is enabled";\
	fi

eptex.web: ../tie.exe $(eptex_web_srcs)
	../tie -m $@ $(eptex_web_srcs)

eptex.ch: ../tie.exe $(eptex_ch_srcs)
	../tie -c $@ $(eptex_ch_srcs)

md5.obj: ../libmd5/md5.c ../libmd5/md5.h
	$(compile) -Fo$@ ../libmd5/md5.c

# Additional dependencies for recompiling the C code are generated
# automatically, included at the end.
kanji.obj: kanji.c kanji.h 
kanji_dump.obj: kanji_dump.c kanji.h 

eptexini.obj: eptexini.c eptexcoerce.h eptexd.h kanji.h ../texmfmp.h 
eptex0.obj: eptex0.c eptexcoerce.h eptexd.h kanji.h ../texmfmp.h
eptexextra.obj: eptexextra.c ../lib/texmfmp.c eptexextra.h \
eptexcoerce.h eptexd.h kanji.h ../texmfmp.h

kanji.h: ../ptexdir/kanji.h
	cp ../ptexdir/kanji.h $@
kanji.c: ../ptexdir/kanji.c
	cp ../ptexdir/kanji.c $@
kanji_dump.c: ../ptexdir/kanji_dump.c
	cp ../ptexdir/kanji_dump.c $@

# Additional dependencies for relinking.
../tangleboot.exe:
	cd .. && $(MAKE) tangleboot.exe
../tangle.exe:
	cd .. && $(MAKE) tangle.exe
$(cwebdir)/fixwrites.exe:
	cd $(cwebdir) && $(MAKE) fixwrites.exe
$(cwebdir)/splitup.exe:
	cd $(cwebdir) && $(MAKE) splitup.exe
$(cwebdir)/web2c.exe:
	cd $(cwebdir) && $(MAKE) web2c.exe
$(proglib):
	cd ../lib && $(MAKE) lib.lib
$(kpathsea):
	cd $(kpathsea_dir) && $(MAKE) kpathsealib.lib

# This is meant to be called recursively, with $(files) set.
prereq-check: $(kpathsea_dir)/kpsewhich
	$(dumpenv) $(kpathsea_dir)/kpsewhich $(files) >/dev/null \
		|| $(MAKE) prereq-lose >/dev/null

prereq-lose:
	@echo "You seem to be missing input files necessary to make the" >&2
	@echo "basic formats (some or all of: $(files))." >&2
	@echo "Perhaps you've defined the default paths incorrectly, or" >&2
	@echo "perhaps you have environment variables set pointing" >&2
	@echo "to an incorrect location.  See ../kpathsea/BUGS." >&2
	@echo >&2
	@echo "If you simply do not have the files, you can" >&2
	@echo "retrieve a minimal set of input files from" >&2
	@echo "ftp://ftp.tug.org/tex/lib.tar.gz, mirrored on" >&2
	@echo "CTAN hosts in systems/web2c." >&2
	false

install: eptex.dll
	cp -p eptex.dll c:/usr/local/txdir/w32tex/bin/
	cp -p eptex.dll c:/usr/work/edrive/wk/dist/PTEX/bin/

# Testing, including triptrap. The `x' filenames are for output.
check: pltotf-check tftopl-check pooltype-check ptex-check 

triptrap: trip
tripdir = $(srcdir)/triptrap
ptripdir = ./triptrap
testdir = $(srcdir)/tests
testenv = TEXMFCNF=$(ptripdir)
dvitype_args = -output-level=2 -dpi=72.27 -page-start='*.*.*.*.*.*.*.*.*.*'
trip: ptex pltotf tftopl ../dvitype
	@echo ">>> See $(tripdir)/trip.diffs for example of acceptable diffs." >&2
	./pltotf $(tripdir)/trip.pl trip.tfm
	./tftopl ./trip.tfm trip.pl
	-diff $(tripdir)/trip.pl trip.pl
	rm -f trip.tex; $(LN) $(tripdir)/trip.tex . # get same filename in log
	-$(SHELL) -c '$(testenv) ./ptex -ini <$(tripdir)/trip1.in >tripin.fot'
	mv trip.log tripin.log
	-diff $(tripdir)/tripin.log tripin.log
# May as well test non-ini second time through.
	-$(SHELL) -c '$(testenv) ./ptex <$(tripdir)/trip2.in >trip.fot'
	-diff $(tripdir)/trip.fot trip.fot
# We use $(DIFF) instead of `diff' only for those files where there
# might actually be legitimate numerical differences.
	-$(DIFF) $(DIFFFLAGS) $(tripdir)/trip.log trip.log
	$(SHELL) -c '$(testenv) ../dvitype $(dvitype_args) trip.dvi >trip.typ'
	-$(DIFF) $(DIFFFLAGS) $(tripdir)/trip.typ trip.typ

# 
# Cleaning.
mostryclean::
	rm -f *.obj

clean:: mostryclean
	rm -f texcoerce.h texd.h jbibd.h jbibtex.h
	rm -f $(ptex_c) $(ptex_o) $(plib_o) $(programs)
	rm -f tftopl.h tftopl.c tftopl.obj
	rm -f pltotf.h pltotf.c pltotf.obj
	rm -f pdvitype.h pdvitype.c pdvitype.obj
	rm -f jbibtex.c jbibtex.obj jbibextra.obj
distclean:: clean
	rm -fr failure
	rm -f ptex.web ptex.ch ptex.p eptex.pool
	rm -f tftopl.web tftopl.ch tftopl.p
	rm -f pltotf.web pltotf.ch pltotf.p
	rm -f pdvitype.web pdvitype.p
	rm -f jbibtex.web jbibtex.p
extraclean:: distclean
	rm -f ptex.fmt platex.fmt
	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.*
	rm -f trip.tex trap.mf mtrap.mp trap.mp trap.mpx
	rm -f trip.* tripin.* tripos.tex 8terminal.tex
	rm -f trap.* mftrap.* mftrapin.* mptrap.* mptrapin.*
	rm -f trapf.* mtrap.* writeo* missfont.log
