#
# W32TeX Makefile
#
SHELL = sh
MAKE=make
top_srcdir = ..
srcdir = .

#OPTIMIZE = -Ob2 -Oi -Ot
OPTIMIZE = -O2

XDEFS = -DWIN32=1
CC = cl
CFLAGS = -nologo -W3 -favor:blend $(OPTIMIZE) -MD $(XCFLAGS)
CPPFLAGS = -I../../ptexenc $(XCPPFLAGS)

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

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

# 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) \
  -I$(kpathsea_parent) -I$(kpathsea_srcdir_parent) \
  $(prog_cflags) $(CPPFLAGS)
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}

# Creating copies.
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)/kpathsealibw64.lib

#
#
AR = lib
ARFLAGS = -out:

# web2c/kpathsea.mk -- In subdirectories of web2c, the build directory
# for kpathsea is one more level up.  c_auto_h_dir is used by make depend.
kpathsea_parent = ../..
c_auto_h_dir = ..

prog_cflags = -I.. -I$(srcdir)/..

library = lib

# We don't make `texmfmp.obj', since TeX, Metafont, and MetaPost need to
# use different routine names, hence they need different .obj files. Maybe
# we should change this via #define's someday ...
objects = alloca.obj basechsuffix.obj chartostring.obj coredump.obj \
  eofeoln.obj fprintreal.obj inputint.obj input2int.obj main.obj \
  openclose.obj printversion.obj setupvar.obj uexit.obj usage.obj \
  version.obj zround.obj

ptexobjects = alloca.obj basechsuffix.obj chartostring.obj coredump.obj \
  eofeoln.obj fprintreal.obj inputint.obj input2int.obj main.obj \
  ptexopenclose.obj ptexprintversion.obj setupvar.obj uexit.obj usage.obj \
  version.obj zround.obj

default all: $(library).lib ptexlib.lib
$(library).lib: $(objects)
	rm -f $@
	$(AR) $(ARFLAGS)$@ $(objects)

ptexlib.lib: $(ptexobjects)
	rm -f $@
	$(AR) $(ARFLAGS)$@ $(ptexobjects)

# Do not use CPPFLAGS for this, because including config.h might
# result in a conflicting decl of xmalloc. How annoying.
alloca.obj: alloca.c 
	$(CC) $(CFLAGS) -DHAVE_STDLIB_H -c $(srcdir)/alloca.c

# clean.mk -- cleaning.

clean::
	rm -f *.exe *.lib *.obj *~

# End of clean.mk.

# 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:

#
# dependencies
#
# DO NOT DELETE

alloca.obj: alloca.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h

basechsuffix.obj: basechsuffix.c ../../kpathsea/c-auto.h \
 ../../kpathsea/c-errno.h ../../kpathsea/c-fopen.h \
 ../../kpathsea/c-limits.h ../../kpathsea/c-memstr.h \
 ../../kpathsea/c-minmax.h ../../kpathsea/c-proto.h ../../kpathsea/c-std.h \
 ../../kpathsea/c-unistd.h ../../kpathsea/config.h ../../kpathsea/debug.h \
 ../../kpathsea/hash.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
 ../../kpathsea/str-list.h ../../kpathsea/str-llist.h \
 ../../kpathsea/systypes.h ../../kpathsea/types.h ../../kpathsea/win32lib.h \
 ../w2c/c-auto.h ../w2c/config.h lib.h

chartostring.obj: chartostring.c ../../kpathsea/c-auto.h \
 ../../kpathsea/c-errno.h ../../kpathsea/c-fopen.h \
 ../../kpathsea/c-limits.h ../../kpathsea/c-memstr.h \
 ../../kpathsea/c-minmax.h ../../kpathsea/c-proto.h ../../kpathsea/c-std.h \
 ../../kpathsea/c-unistd.h ../../kpathsea/config.h ../../kpathsea/debug.h \
 ../../kpathsea/hash.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
 ../../kpathsea/str-list.h ../../kpathsea/str-llist.h \
 ../../kpathsea/systypes.h ../../kpathsea/types.h ../../kpathsea/win32lib.h \
 ../w2c/c-auto.h ../w2c/config.h lib.h

coredump.obj: coredump.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h

eofeoln.obj: eofeoln.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h lib.h

fprintreal.obj: fprintreal.c ../../kpathsea/c-auto.h \
 ../../kpathsea/c-errno.h ../../kpathsea/c-fopen.h \
 ../../kpathsea/c-limits.h ../../kpathsea/c-memstr.h \
 ../../kpathsea/c-minmax.h ../../kpathsea/c-proto.h ../../kpathsea/c-std.h \
 ../../kpathsea/c-unistd.h ../../kpathsea/config.h ../../kpathsea/debug.h \
 ../../kpathsea/hash.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
 ../../kpathsea/str-list.h ../../kpathsea/str-llist.h \
 ../../kpathsea/systypes.h ../../kpathsea/types.h ../../kpathsea/win32lib.h \
 ../w2c/c-auto.h ../w2c/config.h lib.h

input2int.obj: input2int.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h lib.h

inputint.obj: inputint.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h lib.h

main.obj: main.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h lib.h

openclose.obj: openclose.c ../../kpathsea/absolute.h \
 ../../kpathsea/c-auto.h ../../kpathsea/c-ctype.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-pathch.h ../../kpathsea/c-proto.h ../../kpathsea/c-std.h \
 ../../kpathsea/c-unistd.h ../../kpathsea/config.h ../../kpathsea/debug.h \
 ../../kpathsea/hash.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
 ../../kpathsea/str-list.h ../../kpathsea/str-llist.h \
 ../../kpathsea/systypes.h ../../kpathsea/tex-file.h ../../kpathsea/types.h \
 ../../kpathsea/variable.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h lib.h

ptexopenclose.obj: openclose.c ../../kpathsea/absolute.h \
 ../../kpathsea/c-auto.h ../../kpathsea/c-ctype.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-pathch.h ../../kpathsea/c-proto.h ../../kpathsea/c-std.h \
 ../../kpathsea/c-unistd.h ../../kpathsea/config.h ../../kpathsea/debug.h \
 ../../kpathsea/hash.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
 ../../kpathsea/str-list.h ../../kpathsea/str-llist.h \
 ../../kpathsea/systypes.h ../../kpathsea/tex-file.h ../../kpathsea/types.h \
 ../../kpathsea/variable.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h lib.h
	$(compile) -DKANJI=1 -DPTEX=1 -Fo$@ openclose.c

printversion.obj: printversion.c ../../kpathsea/c-auto.h \
 ../../kpathsea/c-errno.h ../../kpathsea/c-fopen.h \
 ../../kpathsea/c-limits.h ../../kpathsea/c-memstr.h \
 ../../kpathsea/c-minmax.h ../../kpathsea/c-proto.h ../../kpathsea/c-std.h \
 ../../kpathsea/c-unistd.h ../../kpathsea/config.h ../../kpathsea/debug.h \
 ../../kpathsea/hash.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
 ../../kpathsea/str-list.h ../../kpathsea/str-llist.h \
 ../../kpathsea/systypes.h ../../kpathsea/types.h ../../kpathsea/version.h \
 ../../kpathsea/win32lib.h ../w2c/c-auto.h ../w2c/config.h lib.h

ptexprintversion.obj: printversion.c ../../kpathsea/c-auto.h \
 ../../kpathsea/c-errno.h ../../kpathsea/c-fopen.h \
 ../../kpathsea/c-limits.h ../../kpathsea/c-memstr.h \
 ../../kpathsea/c-minmax.h ../../kpathsea/c-proto.h ../../kpathsea/c-std.h \
 ../../kpathsea/c-unistd.h ../../kpathsea/config.h ../../kpathsea/debug.h \
 ../../kpathsea/hash.h ../../kpathsea/lib.h ../../kpathsea/progname.h \
 ../../kpathsea/str-list.h ../../kpathsea/str-llist.h \
 ../../kpathsea/systypes.h ../../kpathsea/types.h ../../kpathsea/version.h \
 ../../kpathsea/win32lib.h ../w2c/c-auto.h ../w2c/config.h lib.h
	$(compile) -DKANJI=1 -DPTEX=1 -Fo$@ printversion.c

setupvar.obj: setupvar.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/variable.h ../../kpathsea/win32lib.h \
 ../w2c/c-auto.h ../w2c/config.h lib.h

uexit.obj: uexit.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h

usage.obj: usage.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h

version.obj: version.c ../w2c/c-auto.h

zround.obj: zround.c ../../kpathsea/c-auto.h ../../kpathsea/c-errno.h \
 ../../kpathsea/c-fopen.h ../../kpathsea/c-limits.h \
 ../../kpathsea/c-memstr.h ../../kpathsea/c-minmax.h \
 ../../kpathsea/c-proto.h ../../kpathsea/c-std.h ../../kpathsea/c-unistd.h \
 ../../kpathsea/config.h ../../kpathsea/debug.h ../../kpathsea/hash.h \
 ../../kpathsea/lib.h ../../kpathsea/progname.h ../../kpathsea/str-list.h \
 ../../kpathsea/str-llist.h ../../kpathsea/systypes.h \
 ../../kpathsea/types.h ../../kpathsea/win32lib.h ../w2c/c-auto.h \
 ../w2c/config.h lib.h
