# Generated automatically from Makefile.in by configure.
# Makefile for TeX-project WEB sources to C conversion programs.

# These get expanded from the parent directory, not this one.
# common.mk -- used by all Makefiles.
SHELL = sh
MAKE=make
top_srcdir = ..
srcdir = .

WD = setargv.obj
SYSLIBS = user32.lib advapi32.lib shell32.lib

XDEFS = -D__STDC_VERSION__=199901L -DWIN32=1 -DYY_NO_UNISTD_H=1 \
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \
-D_CRT_OBSOLETE_NO_DEPRECATE -DNO_KPSE_DLL=1

CC = cl

CFLAGS = -nologo -favor:blend -MT -O2 $(XCFLAGS)

DEBFLAGS = /MANIFEST
#CFLAGS = -nologo -MT -Od -Zi $(XCFLAGS)
#DEBFLAGS = /DEBUG /MANIFEST

CPPFLAGS =  $(XCPPFLAGS)
DEFS = -DHAVE_CONFIG_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) -I.. \
  $(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_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)/libkpathsea.lib

XLDFLAGS = -link /SUBSYSTEM:CONSOLE
LDFLAGS =  $(XLDFLAGS) $(DEBFLAGS)

LOADLIBES = $(proglib) $(kpathsea) $(SYSLIBS) $(XLOADLIBES)

CCLD = $(CC)
link_command = $(CCLD) -Fe$@

kpathsea_link = $(link_command)

kpathsea_parent = ../..
c_auto_h_dir = ..

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

LEX = win_flex
#LEXLIB = libfl.lib
LEXLIB =
LEX_OUTPUT_ROOT = web2c-lexer
YACC = win_bison -y

proglib = ../lib/lib.lib
programs = web2c.exe fixwrites.exe splitup.exe regfix.exe \
makecpool.exe

# web2c_objects = kps.obj main.obj y_tab.obj $(LEX_OUTPUT_ROOT).obj
web2c_objects = main.obj web2c-parser.obj web2c-lexer.obj

all: $(programs)

makecpool.exe: makecpool.obj
	$(kpathsea_link) makecpool.obj $(LDFLAGS)
	mt -manifest $@.manifest -outputresource:$@";"1

web2c.exe: $(web2c_objects)
	$(kpathsea_link) $(web2c_objects) $(WD) $(LEXLIB) $(LOADLIBES) \
           $(LDFLAGS)
	mt -manifest $@.manifest -outputresource:$@";"1

main.obj: main.c web2c-parser.h

#web2c-parser.c web2c-parser.h: web2c-parser.y
#	@echo Expect one shift/reduce conflict.
#	$(YACC) -v --output=web2c-parser.c --defines=web2c-parser.h $(srcdir)/web2c-parser.y

##web2c-parser.c web2c-parser.h: web2c-parser.y
##	@echo Expect one shift/reduce conflict.
##	$(YACC) -d -v $(srcdir)/web2c-parser.y
##	-test -f y.tab.c && mv -f y.tab.c web2c-parser.c
##	-test -f y.tab.h && mv -f y.tab.h web2c-parser.h

web2c-parser.c: web2c-parser.c.dist
	cp web2c-parser.c.dist $@
web2c-parser.h: web2c-parser.h.dist
	cp web2c-parser.h.dist $@


$(LEX_OUTPUT_ROOT).obj: web2c-parser.h

#$(LEX_OUTPUT_ROOT).c: web2c-lexer.l
#	$(LEX) -o $@ $(srcdir)/web2c-lexer.l

$(LEX_OUTPUT_ROOT).c: $(LEX_OUTPUT_ROOT).c.dist
	cp $(LEX_OUTPUT_ROOT).c.dist $@

#fixwrites.exe: fixwrites.obj kps.obj
#	$(kpathsea_link) fixwrites.obj kps.obj $(WD) $(LOADLIBES)
#splitup.exe: splitup.obj kps.obj
#	$(kpathsea_link) splitup.obj kps.obj $(WD) $(LOADLIBES)
#regfix.exe: regfix.obj kps.obj
#	$(kpathsea_link) regfix.obj kps.obj $(WD) $(LOADLIBES)

fixwrites.exe: fixwrites.obj
	$(kpathsea_link) fixwrites.obj $(WD) $(LOADLIBES) $(LDFLAGS)
	mt -manifest $@.manifest -outputresource:$@";"1

splitup.exe: splitup.obj
	$(kpathsea_link) splitup.obj $(WD) $(LOADLIBES) $(LDFLAGS)
	mt -manifest $@.manifest -outputresource:$@";"1

regfix.exe: regfix.obj
	$(kpathsea_link) regfix.obj $(WD) $(LOADLIBES) $(LDFLAGS)
	mt -manifest $@.manifest -outputresource:$@";"1

$(programs): $(proglib) $(kpathsea)

makeargs = $(MFLAGS) CC='$(CC)' CFLAGS='$(CFLAGS)' $(XMAKEARGS)

$(kpathsea): $(kpathsea_srcdir)/*.c $(kpathsea_srcdir)/*.h \
	     $(top_srcdir)/../make/paths.mk
	cd $(kpathsea_dir) && $(MAKE) $(makeargs)

clean::
	rm -f *~ *.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.

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

fixwrites.obj: fixwrites.c ../w2c/config.h $(kpathsea_srcdir)/config.h \
  $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
  $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
  $(kpathsea_srcdir)/c-memstr.h \
  $(kpathsea_srcdir)/c-errno.h \
  $(kpathsea_srcdir)/c-minmax.h \
  $(kpathsea_srcdir)/c-limits.h \
  $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
  $(kpathsea_srcdir)/types.h \
  $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
  ../../web2c/w2c/c-auto.h \
  $(kpathsea_srcdir)/c-fopen.h \
  $(kpathsea_srcdir)/c-pathmx.h
$(LEX_OUTPUT_ROOT).obj: $(LEX_OUTPUT_ROOT).c \
  web2c.h ../w2c/config.h \
  $(kpathsea_srcdir)/config.h $(kpathsea_dir)/c-auto.h \
  $(kpathsea_srcdir)/c-std.h \
  $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
  $(kpathsea_srcdir)/c-memstr.h $(kpathsea_srcdir)/c-errno.h \
  $(kpathsea_srcdir)/c-minmax.h $(kpathsea_srcdir)/c-limits.h \
  $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
  $(kpathsea_srcdir)/types.h \
  $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
  ../../web2c/w2c/c-auto.h \
  $(kpathsea_srcdir)/c-fopen.h \
  web2c-parser.h
main.obj: main.c web2c.h ../w2c/config.h $(kpathsea_srcdir)/config.h \
  $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
  $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
  $(kpathsea_srcdir)/c-memstr.h \
  $(kpathsea_srcdir)/c-errno.h \
  $(kpathsea_srcdir)/c-minmax.h \
  $(kpathsea_srcdir)/c-limits.h \
  $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
  $(kpathsea_srcdir)/types.h \
  $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
  ../../web2c/w2c/c-auto.h \
  $(kpathsea_srcdir)/c-fopen.h \
  web2c-parser.h
regfix.obj: regfix.c ../w2c/config.h $(kpathsea_srcdir)/config.h \
  $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
  $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
  $(kpathsea_srcdir)/c-memstr.h \
  $(kpathsea_srcdir)/c-errno.h \
  $(kpathsea_srcdir)/c-minmax.h \
  $(kpathsea_srcdir)/c-limits.h \
  $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
  $(kpathsea_srcdir)/types.h \
  $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
  ../../web2c/w2c/c-auto.h \
  $(kpathsea_srcdir)/c-fopen.h 
splitup.obj: splitup.c ../w2c/config.h $(kpathsea_srcdir)/config.h \
  $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
  $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
  $(kpathsea_srcdir)/c-memstr.h \
  $(kpathsea_srcdir)/c-errno.h \
  $(kpathsea_srcdir)/c-minmax.h \
  $(kpathsea_srcdir)/c-limits.h \
  $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
  $(kpathsea_srcdir)/types.h \
  $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
  ../../web2c/w2c/c-auto.h \
  $(kpathsea_srcdir)/c-fopen.h \
  $(kpathsea_srcdir)/getopt.h
web2c-parser.obj: web2c-parser.c web2c.h ../w2c/config.h \
  $(kpathsea_srcdir)/config.h \
  $(kpathsea_dir)/c-auto.h $(kpathsea_srcdir)/c-std.h \
  $(kpathsea_srcdir)/c-unistd.h $(kpathsea_srcdir)/systypes.h \
  $(kpathsea_srcdir)/c-memstr.h \
  $(kpathsea_srcdir)/c-errno.h \
  $(kpathsea_srcdir)/c-minmax.h \
  $(kpathsea_srcdir)/c-limits.h \
  $(kpathsea_srcdir)/c-proto.h $(kpathsea_srcdir)/debug.h \
  $(kpathsea_srcdir)/types.h \
  $(kpathsea_srcdir)/lib.h $(kpathsea_srcdir)/progname.h \
  ../../web2c/w2c/c-auto.h \
  $(kpathsea_srcdir)/c-fopen.h 
