# Makefile for the web2c library.

# common.mk -- used by all Makefiles.
SHELL = sh
MAKE=make
top_srcdir = ..
srcdir = .
OPTIMIZE = -O2

XDEFS = -DWIN32=1 -D_CRT_SECURE_NO_DEPRECATE=1 \
-D_CRT_SECURE_NO_WARNINGS=1 -wd4267
CC = cl
CFLAGS = -nologo $(OPTIMIZE) -W3 -favor:blend -MT $(XCFLAGS)
CPPFLAGS =  $(XCPPFLAGS)
DEFS = -DNO_KPSE_DLL=1 -DHAVE_CONFIG_H -DHAVE_STDLIB_H $(XDEFS)

# 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$(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}
INSTALL_LIBTOOL_LIBS =
INSTALL_LIBTOOL_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)/libkpathsea.lib

#M#ifeq ($(CC), gcc)
#M#XDEFS = -Wpointer-arith $(warn_more)
#M#CFLAGS = -pipe -g $(XCFLAGS)
#M#endif
# End of common.mk.
# library.mk -- stuff only useful for libraries.
AR = lib
ARFLAGS = -out:
RANLIB =
# End of library.mk.
# 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)/..
# End of web2c/kpathsea.mk.

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

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

# 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 *.lib *.obj *~

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

include depend.mk
